def _install_requirements( pip_runnable: str, finder: "PackageFinder", requirements: Iterable[str], prefix: _Prefix, *, kind: str, ) -> None: sys_executable = os.environ.get('PIP_PYTHON_PATH', sys.executable) args: List[str] = [ sys_executable, pip_runnable, "install", "--ignore-installed", "--no-user", "--prefix", prefix.path, "--no-warn-script-location", ] if logger.getEffectiveLevel() <= logging.DEBUG: args.append("-v") for format_control in ("no_binary", "only_binary"): formats = getattr(finder.format_control, format_control) args.extend(( "--" + format_control.replace("_", "-"), ",".join(sorted(formats or {":none:"})), )) index_urls = finder.index_urls if index_urls: args.extend(["-i", index_urls[0]]) for extra_index in index_urls[1:]: args.extend(["--extra-index-url", extra_index]) else: args.append("--no-index") for link in finder.find_links: args.extend(["--find-links", link]) for host in finder.trusted_hosts: args.extend(["--trusted-host", host]) if finder.allow_all_prereleases: args.append("--pre") if finder.prefer_binary: args.append("--prefer-binary") args.append("--") args.extend(requirements) extra_environ = {"_PIP_STANDALONE_CERT": where()} with open_spinner(f"Installing {kind}") as spinner: call_subprocess( args, command_desc=f"pip subprocess to install {kind}", spinner=spinner, extra_environ=extra_environ, )
def runner( cmd, # type: List[str] cwd=None, # type: Optional[str] extra_environ=None, # type: Optional[Mapping[str, Any]] ): # type: (...) -> None with open_spinner(message) as spinner: call_subprocess( cmd, cwd=cwd, extra_environ=extra_environ, spinner=spinner, )
def runner( cmd: List[str], cwd: Optional[str] = None, extra_environ: Optional[Mapping[str, Any]] = None, ) -> None: with open_spinner(message) as spinner: call_subprocess( cmd, command_desc=message, cwd=cwd, extra_environ=extra_environ, spinner=spinner, )
def _install_requirements( pip_runnable: str, finder: "PackageFinder", requirements: Iterable[str], prefix: _Prefix, message: str, ) -> None: sys_executable = os.environ.get('PIP_PYTHON_PATH', sys.executable) args = [ sys_executable, pip_runnable, 'install', '--ignore-installed', '--no-user', '--prefix', prefix.path, '--no-warn-script-location', ] # type: List[str] if logger.getEffectiveLevel() <= logging.DEBUG: args.append('-v') for format_control in ('no_binary', 'only_binary'): formats = getattr(finder.format_control, format_control) args.extend(('--' + format_control.replace('_', '-'), ','.join(sorted(formats or {':none:'})))) index_urls = finder.index_urls if index_urls: args.extend(['-i', index_urls[0]]) for extra_index in index_urls[1:]: args.extend(['--extra-index-url', extra_index]) else: args.append('--no-index') for link in finder.find_links: args.extend(['--find-links', link]) for host in finder.trusted_hosts: args.extend(['--trusted-host', host]) if finder.allow_all_prereleases: args.append('--pre') if finder.prefer_binary: args.append('--prefer-binary') args.append('--') args.extend(requirements) extra_environ = {"_PIP_STANDALONE_CERT": where()} with open_spinner(message) as spinner: call_subprocess(args, spinner=spinner, extra_environ=extra_environ)
def build_wheel_legacy( name: str, setup_py_path: str, source_dir: str, global_options: List[str], build_options: List[str], tempd: str, ) -> Optional[str]: """Build one unpacked package using the "legacy" build process. Returns path to wheel if successfully built. Otherwise, returns None. """ wheel_args = make_setuptools_bdist_wheel_args( setup_py_path, global_options=global_options, build_options=build_options, destination_dir=tempd, ) spin_message = f"Building wheel for {name} (setup.py)" with open_spinner(spin_message) as spinner: logger.debug("Destination directory: %s", tempd) try: output = call_subprocess( wheel_args, command_desc="python setup.py bdist_wheel", cwd=source_dir, spinner=spinner, ) except Exception: spinner.finish("error") logger.error("Failed building wheel for %s", name) return None names = os.listdir(tempd) wheel_path = get_legacy_build_wheel_path( names=names, temp_dir=tempd, name=name, command_args=wheel_args, command_output=output, ) return wheel_path
def generate_metadata( build_env: BuildEnvironment, setup_py_path: str, source_dir: str, isolated: bool, details: str, ) -> str: """Generate metadata using setup.py-based defacto mechanisms. Returns the generated metadata directory. """ logger.debug( "Running setup.py (path:%s) egg_info for package %s", setup_py_path, details, ) egg_info_dir = TempDirectory(kind="pip-egg-info", globally_managed=True).path args = make_setuptools_egg_info_args( setup_py_path, egg_info_dir=egg_info_dir, no_user_config=isolated, ) with build_env: with open_spinner("Preparing metadata (setup.py)") as spinner: try: call_subprocess( args, cwd=source_dir, command_desc="python setup.py egg_info", spinner=spinner, ) except InstallationSubprocessError as error: raise MetadataGenerationFailed(package_details=details) from error # Return the .egg-info directory. return _find_egg_info(egg_info_dir)