mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
@@ -29,4 +29,6 @@ from .pip_compat import (
|
||||
PyPI,
|
||||
SafeFileCache,
|
||||
InstallationError,
|
||||
install_req_from_line,
|
||||
install_req_from_editable,
|
||||
)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# -*- coding=utf-8 -*-
|
||||
import importlib
|
||||
|
||||
from pip_shims import pip_version
|
||||
import pkg_resources
|
||||
|
||||
def do_import(module_path, subimport=None, old_path=None, vendored_name=None):
|
||||
old_path = old_path or module_path
|
||||
prefix = vendored_name if vendored_name else "pip"
|
||||
@@ -35,3 +38,12 @@ get_installed_distributions = do_import('utils.misc', 'get_installed_distributio
|
||||
PyPI = do_import('models.index', 'PyPI', vendored_name='notpip')
|
||||
SafeFileCache = do_import('download', 'SafeFileCache', vendored_name='notpip')
|
||||
InstallationError = do_import('exceptions', 'InstallationError', vendored_name='notpip')
|
||||
|
||||
# pip 18.1 has refactored InstallRequirement constructors use by pip-tools.
|
||||
if pkg_resources.parse_version(pip_version) < pkg_resources.parse_version('18.1'):
|
||||
install_req_from_line = InstallRequirement.from_line
|
||||
install_req_from_editable = InstallRequirement.from_editable
|
||||
else:
|
||||
install_req_from_line = do_import('req.constructors', 'install_req_from_line', vendored_name="notpip")
|
||||
install_req_from_editable = do_import('req.constructors', 'install_req_from_editable', vendored_name="notpip")
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ from packaging.requirements import Requirement
|
||||
from packaging.specifiers import SpecifierSet, Specifier
|
||||
from packaging.markers import Op, Value, Variable, Marker
|
||||
InstallationError = do_import(("exceptions.InstallationError", "7.0", "9999"))
|
||||
from notpip._internal.resolve import Resolver as PipResolver
|
||||
from pipenv.patched.notpip._internal.resolve import Resolver as PipResolver
|
||||
|
||||
|
||||
from pipenv.environments import PIPENV_CACHE_DIR as CACHE_DIR
|
||||
@@ -35,7 +35,7 @@ from ..utils import (fs_str, is_pinned_requirement, lookup_table, dedup,
|
||||
from .base import BaseRepository
|
||||
|
||||
try:
|
||||
from notpip._internal.req.req_tracker import RequirementTracker
|
||||
from pipenv.patched.notpip._internal.req.req_tracker import RequirementTracker
|
||||
except ImportError:
|
||||
@contextmanager
|
||||
def RequirementTracker():
|
||||
@@ -242,7 +242,7 @@ class PyPIRepository(BaseRepository):
|
||||
setup_requires = {}
|
||||
dist = None
|
||||
try:
|
||||
from notpip._internal.operations.prepare import RequirementPreparer
|
||||
from pipenv.patched.notpip._internal.operations.prepare import RequirementPreparer
|
||||
except ImportError:
|
||||
# Pip 9 and below
|
||||
reqset = RequirementSet(
|
||||
|
||||
@@ -7,7 +7,7 @@ from functools import partial
|
||||
from itertools import chain, count
|
||||
import os
|
||||
|
||||
from ._compat import InstallRequirement
|
||||
from ._compat import install_req_from_line
|
||||
|
||||
from . import click
|
||||
from .cache import DependencyCache
|
||||
@@ -306,7 +306,7 @@ class Resolver(object):
|
||||
log.debug(' {:25} requires {}'.format(format_requirement(ireq),
|
||||
', '.join(sorted(dependency_strings, key=lambda s: s.lower())) or '-'))
|
||||
for dependency_string in dependency_strings:
|
||||
yield InstallRequirement.from_line(dependency_string, constraint=ireq.constraint)
|
||||
yield install_req_from_line(dependency_string, constraint=ireq.constraint)
|
||||
|
||||
def reverse_dependencies(self, ireqs):
|
||||
non_editable = [ireq for ireq in ireqs if not ireq.editable]
|
||||
|
||||
@@ -8,7 +8,7 @@ import sys
|
||||
import tempfile
|
||||
|
||||
from .._compat import (
|
||||
InstallRequirement,
|
||||
install_req_from_line,
|
||||
parse_requirements,
|
||||
cmdoptions,
|
||||
Command,
|
||||
@@ -134,7 +134,7 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url,
|
||||
if not upgrade and os.path.exists(dst_file):
|
||||
ireqs = parse_requirements(dst_file, finder=repository.finder, session=repository.session, options=pip_options)
|
||||
# Exclude packages from --upgrade-package/-P from the existing pins: We want to upgrade.
|
||||
upgrade_pkgs_key = {key_from_req(InstallRequirement.from_line(pkg).req) for pkg in upgrade_packages}
|
||||
upgrade_pkgs_key = {key_from_req(install_req_from_line(pkg).req) for pkg in upgrade_packages}
|
||||
existing_pins = {key_from_req(ireq.req): ireq
|
||||
for ireq in ireqs
|
||||
if is_pinned_requirement(ireq) and key_from_req(ireq.req) not in upgrade_pkgs_key}
|
||||
|
||||
@@ -9,7 +9,7 @@ from itertools import chain, groupby
|
||||
from collections import OrderedDict
|
||||
from contextlib import contextmanager
|
||||
|
||||
from ._compat import InstallRequirement
|
||||
from ._compat import install_req_from_line
|
||||
|
||||
from .click import style
|
||||
from pipenv.patched.notpip._vendor.packaging.specifiers import SpecifierSet, InvalidSpecifier
|
||||
@@ -57,7 +57,7 @@ def simplify_markers(ireq):
|
||||
marker_str = ' and '.join(list(dedup(tuple(marker_list,)))) if marker_list else ''
|
||||
new_markers = Marker(marker_str)
|
||||
ireq.markers = new_markers
|
||||
new_ireq = InstallRequirement.from_line(format_requirement(ireq))
|
||||
new_ireq = install_req_from_line(format_requirement(ireq))
|
||||
if ireq.constraint:
|
||||
new_ireq.constraint = ireq.constraint
|
||||
return new_ireq
|
||||
@@ -117,11 +117,11 @@ def make_install_requirement(name, version, extras, markers, constraint=False):
|
||||
extras_string = "[{}]".format(",".join(sorted(extras)))
|
||||
|
||||
if not markers:
|
||||
return InstallRequirement.from_line(
|
||||
return install_req_from_line(
|
||||
str('{}{}=={}'.format(name, extras_string, version)),
|
||||
constraint=constraint)
|
||||
else:
|
||||
return InstallRequirement.from_line(
|
||||
return install_req_from_line(
|
||||
str('{}{}=={}; {}'.format(name, extras_string, version, str(markers))),
|
||||
constraint=constraint)
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ index 28da51f..de9b435 100644
|
||||
- install_req_from_editable = do_import('req.constructors', 'install_req_from_editable')
|
||||
+ install_req_from_line = do_import('req.constructors', 'install_req_from_line', vendored_name="notpip")
|
||||
+ install_req_from_editable = do_import('req.constructors', 'install_req_from_editable', vendored_name="notpip")
|
||||
+
|
||||
diff --git a/pipenv/patched/piptools/repositories/local.py b/pipenv/patched/piptools/repositories/local.py
|
||||
index 08dabe1..480ad1e 100644
|
||||
--- a/pipenv/patched/piptools/repositories/local.py
|
||||
@@ -112,7 +113,7 @@ index bf69803..163d510 100644
|
||||
+ InstallRequirement,
|
||||
+ SafeFileCache
|
||||
)
|
||||
+os.environ["PIP_SHIMS_BASE_MODULE"] = "pip"
|
||||
+os.environ["PIP_SHIMS_BASE_MODULE"] = "notpip"
|
||||
+from pip_shims.shims import do_import, VcsSupport, WheelCache
|
||||
+from packaging.requirements import Requirement
|
||||
+from packaging.specifiers import SpecifierSet, Specifier
|
||||
@@ -239,7 +240,7 @@ index bf69803..163d510 100644
|
||||
+ if self.DEFAULT_INDEX_URL not in self.finder.index_urls:
|
||||
+ return
|
||||
+
|
||||
+ url = 'https:/pypi.org/pypi/{0}/json'.format(ireq.req.name)
|
||||
+ url = 'https://pypi.org/pypi/{0}/json'.format(ireq.req.name)
|
||||
+ releases = self.session.get(url).json()['releases']
|
||||
+
|
||||
+ matches = [
|
||||
@@ -250,7 +251,7 @@ index bf69803..163d510 100644
|
||||
+ return
|
||||
+
|
||||
+ release_requires = self.session.get(
|
||||
+ 'https:/pypi.org/pypi/{0}/{1}/json'.format(
|
||||
+ 'https://pypi.org/pypi/{0}/{1}/json'.format(
|
||||
+ ireq.req.name, matches[0],
|
||||
+ ),
|
||||
+ ).json()
|
||||
|
||||
Reference in New Issue
Block a user