def effective_package(self, template): """ :param str template: Template describing how to name delivered files, example: {meta}/{name}-{version} """ folder = os.path.join(self.dist_folder, template.format(name=self.package_spec.dashed, version=self.desired.version)) clean_folder(folder) python = system.target_python(package_spec=self.package_spec) if not python.has_builtin_venv or self.relocatable: venv = "virtualenv==16.7.7" else: venv = "venv" vrun(self.package_spec, venv, folder) bin_folder = os.path.join(folder, "bin") pip = os.path.join(bin_folder, "pip") spec = self.source_folder if self.source_folder else "%s==%s" % (self.package_spec.dashed, self.desired.version) runez.run(pip, "install", "-i", system.SETTINGS.index, "-f", self.build_folder, spec) if self.relocatable: python = system.target_python(package_spec=self.package_spec).executable vrun(self.package_spec, "virtualenv", "--relocatable", "--python=%s" % python, folder) runez.run(os.path.join(bin_folder, "python"), "-mcompileall") self.packaged.append(folder) self.executables = [os.path.join(bin_folder, name) for name in self.entry_points]
def pex_build(self, name, destination): """ Run pex build :param str name: Name of entry point :param str destination: Path to file where to produce pex :return str: None if successful, error message otherwise """ runez.ensure_folder(self.build_folder, folder=True) runez.delete(destination) args = ["--cache-dir", self.build_folder, "--repo", self.build_folder] args.extend([ "-c%s" % name, "-o%s" % destination, "%s==%s" % (self.name, self.version) ]) python = system.target_python(package_name=self.name) shebang = python.shebang( universal=system.is_universal(self.build_folder)) if shebang: args.append("--python-shebang") args.append(shebang) vrun(self.name, self.specced_command(), *args, path_env=C_COMPILATION_HELP)
def effective_package(self, template): """ :param str template: Template describing how to name delivered files, example: {meta}/{name}-{version} """ folder = os.path.join( self.dist_folder, template.format(name=self.name, version=self.version)) runez.delete(folder, logger=None) runez.ensure_folder(folder, folder=True, logger=None) vrun(self.name, "virtualenv", folder) bin_folder = os.path.join(folder, "bin") pip = os.path.join(bin_folder, "pip") spec = self.source_folder if self.source_folder else "%s==%s" % ( self.name, self.version) runez.run(pip, "install", "-i", system.SETTINGS.index, "-f", self.build_folder, spec) if self.relocatable: python = system.target_python(package_name=self.name).executable vrun(self.name, "virtualenv", "--relocatable", "--python=%s" % python, folder) self.packaged.append(folder) self.executables = [ os.path.join(bin_folder, name) for name in self.entry_points ]
def pip_wheel(self): """ Run pip wheel :return str: None if successful, error message otherwise """ runez.ensure_folder(self.build_folder, folder=True) return vrun( self.name, "pip", "wheel", "-i", system.SETTINGS.index, "--cache-dir", self.build_folder, "--wheel-dir", self.build_folder, self.source_folder if self.source_folder else "%s==%s" % (self.name, self.version))