mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Convert off the shims package finder.
This commit is contained in:
@@ -627,18 +627,20 @@ class Environment:
|
||||
|
||||
@contextlib.contextmanager
|
||||
def get_finder(self, pre: bool = False) -> ContextManager[PackageFinder]:
|
||||
from .vendor.pip_shims.shims import get_package_finder
|
||||
from .utils.resolver import get_package_finder
|
||||
|
||||
pip_command = InstallCommand()
|
||||
pip_command = InstallCommand(
|
||||
name="InstallCommand", summary="pip Install command."
|
||||
)
|
||||
pip_args = prepare_pip_source_args(self.sources)
|
||||
pip_options, _ = pip_command.parser.parse_args(pip_args)
|
||||
pip_options.cache_dir = self.project.s.PIPENV_CACHE_DIR
|
||||
pip_options.pre = self.pipfile.get("pre", pre)
|
||||
with pip_command._build_session(pip_options) as session:
|
||||
finder = get_package_finder(
|
||||
install_cmd=pip_command, options=pip_options, session=session
|
||||
)
|
||||
yield finder
|
||||
session = pip_command._build_session(self.pip_options)
|
||||
finder = get_package_finder(
|
||||
install_cmd=pip_command, options=pip_options, session=session
|
||||
)
|
||||
yield finder
|
||||
|
||||
def get_package_info(
|
||||
self, pre: bool = False
|
||||
|
||||
+1
-1
@@ -643,7 +643,7 @@ class Project:
|
||||
def create_pipfile(self, python=None):
|
||||
"""Creates the Pipfile, filled with juicy defaults."""
|
||||
# Inherit the pip's index configuration of install command.
|
||||
command = InstallCommand()
|
||||
command = InstallCommand(name="InstallCommand", summary="pip Install command.")
|
||||
indexes = command.cmd_opts.get_option("--extra-index-url").default
|
||||
sources = [self.default_source]
|
||||
for i, index in enumerate(indexes):
|
||||
|
||||
@@ -12,6 +12,7 @@ from pipenv.exceptions import RequirementError, ResolutionFailure
|
||||
from pipenv.patched.pip._internal.cache import WheelCache
|
||||
from pipenv.patched.pip._internal.commands.install import InstallCommand
|
||||
from pipenv.patched.pip._internal.exceptions import InstallationError
|
||||
from pipenv.patched.pip._internal.models.target_python import TargetPython
|
||||
from pipenv.patched.pip._internal.network.cache import SafeFileCache
|
||||
from pipenv.patched.pip._internal.operations.build.build_tracker import (
|
||||
get_build_tracker,
|
||||
@@ -43,6 +44,35 @@ from .shell import make_posix, subprocess_run, temp_environ
|
||||
from .spinner import create_spinner
|
||||
|
||||
|
||||
def get_package_finder(
|
||||
install_cmd=None,
|
||||
options=None,
|
||||
session=None,
|
||||
platform=None,
|
||||
python_versions=None,
|
||||
abi=None,
|
||||
implementation=None,
|
||||
ignore_requires_python=None,
|
||||
):
|
||||
"""Reduced Shim for compatibility to generate package finders."""
|
||||
py_version_info = None
|
||||
if python_versions:
|
||||
py_version_info_python = max(python_versions)
|
||||
py_version_info = tuple([int(part) for part in py_version_info_python])
|
||||
target_python = TargetPython(
|
||||
platforms=[platform] if platform else None,
|
||||
py_version_info=py_version_info,
|
||||
abis=[abi] if abi else None,
|
||||
implementation=implementation,
|
||||
)
|
||||
return install_cmd._build_package_finder(
|
||||
options=options,
|
||||
session=session,
|
||||
target_python=target_python,
|
||||
ignore_requires_python=ignore_requires_python,
|
||||
)
|
||||
|
||||
|
||||
class HashCacheMixin:
|
||||
|
||||
"""Caches hashes of PyPI artifacts so we do not need to re-download them.
|
||||
@@ -556,10 +586,8 @@ class Resolver:
|
||||
|
||||
@property
|
||||
def finder(self):
|
||||
from pipenv.vendor.pip_shims import shims
|
||||
|
||||
if self._finder is None:
|
||||
self._finder = shims.get_package_finder(
|
||||
self._finder = get_package_finder(
|
||||
install_cmd=self.pip_command,
|
||||
options=self.pip_options,
|
||||
session=self.session,
|
||||
@@ -571,10 +599,8 @@ class Resolver:
|
||||
|
||||
@property
|
||||
def ignore_compatibility_finder(self):
|
||||
from pipenv.vendor.pip_shims import shims
|
||||
|
||||
if self._ignore_compatibility_finder is None:
|
||||
ignore_compatibility_finder = shims.get_package_finder(
|
||||
ignore_compatibility_finder = get_package_finder(
|
||||
install_cmd=self.pip_command,
|
||||
options=self.pip_options,
|
||||
session=self.session,
|
||||
|
||||
Reference in New Issue
Block a user