From 7227c9b2c925564f4c5397cd11d736831d71eae3 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Thu, 17 May 2018 18:51:53 -0400 Subject: [PATCH] Fix pip compat imports for piptools Signed-off-by: Dan Ryan --- pipenv/patched/piptools/_compat/pip_compat.py | 8 ++-- pipenv/patched/piptools/repositories/pypi.py | 6 +-- .../vendoring/patches/patched/piptools.patch | 48 ++++++++++++------- tests/integration/test_project.py | 2 +- 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/pipenv/patched/piptools/_compat/pip_compat.py b/pipenv/patched/piptools/_compat/pip_compat.py index 2b5c12a2..96c8a1ea 100644 --- a/pipenv/patched/piptools/_compat/pip_compat.py +++ b/pipenv/patched/piptools/_compat/pip_compat.py @@ -31,10 +31,10 @@ FAVORITE_HASH = do_import('utils.hashes', 'FAVORITE_HASH', vendored_name='notpip is_file_url = do_import('download', 'is_file_url', vendored_name='notpip') url_to_path = do_import('download', 'url_to_path', vendored_name='notpip') PackageFinder = do_import('index', 'PackageFinder', vendored_name='notpip') -FormatControl = do_import('index', 'FormatControl') +FormatControl = do_import('index', 'FormatControl', vendored_name='notpip') Wheel = do_import('wheel', 'Wheel', vendored_name='notpip') -Command = do_import('basecommand', 'Command') -cmdoptions = do_import('cmdoptions') -get_installed_distributions = do_import('utils.misc', 'get_installed_distributions', old_path='utils') +Command = do_import('basecommand', 'Command', vendored_name='pip9') +cmdoptions = do_import('cmdoptions', vendored_name='pip9') +get_installed_distributions = do_import('utils.misc', 'get_installed_distributions', old_path='utils', vendored_name='pip9') PyPI = do_import('models.index', 'PyPI', vendored_name='notpip') SafeFileCache = do_import('download', 'SafeFileCache', vendored_name='notpip') diff --git a/pipenv/patched/piptools/repositories/pypi.py b/pipenv/patched/piptools/repositories/pypi.py index a2607446..1c808f36 100644 --- a/pipenv/patched/piptools/repositories/pypi.py +++ b/pipenv/patched/piptools/repositories/pypi.py @@ -90,7 +90,7 @@ class PyPIRepository(BaseRepository): self.session = session self.use_json = use_json self.pip_options = pip_options - self.wheel_cache = WheelCache(CACHE_DIR, pip_options.format_control) + self.wheel_cache = WheelCache(PIPENV_CACHE_DIR, pip_options.format_control) index_urls = [pip_options.index_url] + pip_options.extra_index_urls if pip_options.no_index: @@ -122,8 +122,8 @@ class PyPIRepository(BaseRepository): # Setup file paths self.freshen_build_caches() - self._download_dir = fs_str(os.path.join(CACHE_DIR, 'pkgs')) - self._wheel_download_dir = fs_str(os.path.join(CACHE_DIR, 'wheels')) + self._download_dir = fs_str(os.path.join(PIPENV_CACHE_DIR, 'pkgs')) + self._wheel_download_dir = fs_str(os.path.join(PIPENV_CACHE_DIR, 'wheels')) def freshen_build_caches(self): """ diff --git a/tasks/vendoring/patches/patched/piptools.patch b/tasks/vendoring/patches/patched/piptools.patch index 6f14002e..678a1bfd 100644 --- a/tasks/vendoring/patches/patched/piptools.patch +++ b/tasks/vendoring/patches/patched/piptools.patch @@ -18,10 +18,10 @@ index 4e6174c..75f9b49 100644 # NOTE # We used to store the cache dir under ~/.pip-tools, which is not the -diff --git a/pipenv/patched/piptools/repositories/pypi.py b/pipenv/patched/piptools/repositories/pypi.py -index 1c4b943..39a285b 100644 ---- a/pipenv/patched/piptools/repositories/pypi.py -+++ b/pipenv/patched/piptools/repositories/pypi.py +diff --git a/piptools/repositories/pypi.py b/piptools/repositories/pypi.py +index 1c4b943..1c808f3 100644 +--- a/piptools/repositories/pypi.py ++++ b/piptools/repositories/pypi.py @@ -15,10 +15,16 @@ from .._compat import ( Wheel, FAVORITE_HASH, @@ -81,7 +81,7 @@ index 1c4b943..39a285b 100644 class PyPIRepository(BaseRepository): DEFAULT_INDEX_URL = PyPI.simple_url -@@ -46,8 +86,9 @@ class PyPIRepository(BaseRepository): +@@ -46,10 +86,11 @@ class PyPIRepository(BaseRepository): config), but any other PyPI mirror can be used if index_urls is changed/configured on the Finder. """ @@ -90,9 +90,12 @@ index 1c4b943..39a285b 100644 self.session = session + self.use_json = use_json self.pip_options = pip_options - self.wheel_cache = WheelCache(CACHE_DIR, pip_options.format_control) +- self.wheel_cache = WheelCache(CACHE_DIR, pip_options.format_control) ++ self.wheel_cache = WheelCache(PIPENV_CACHE_DIR, pip_options.format_control) -@@ -74,6 +115,10 @@ class PyPIRepository(BaseRepository): + index_urls = [pip_options.index_url] + pip_options.extra_index_urls + if pip_options.no_index: +@@ -74,11 +115,15 @@ class PyPIRepository(BaseRepository): # of all secondary dependencies for the given requirement, so we # only have to go to disk once for each requirement self._dependencies_cache = {} @@ -103,6 +106,13 @@ index 1c4b943..39a285b 100644 # Setup file paths self.freshen_build_caches() +- self._download_dir = fs_str(os.path.join(CACHE_DIR, 'pkgs')) +- self._wheel_download_dir = fs_str(os.path.join(CACHE_DIR, 'wheels')) ++ self._download_dir = fs_str(os.path.join(PIPENV_CACHE_DIR, 'pkgs')) ++ self._wheel_download_dir = fs_str(os.path.join(PIPENV_CACHE_DIR, 'wheels')) + + def freshen_build_caches(self): + """ @@ -126,11 +171,60 @@ class PyPIRepository(BaseRepository): best_candidate = max(matching_candidates, key=self.finder._candidate_sort_key) @@ -394,10 +404,10 @@ index fde5816..d76695d 100644 return line -diff --git a/pipenv/patched/piptools/_compat/pip_compat.py b/pipenv/patched/piptools/_compat/pip_compat.py -index 7e8cdf3..2b5c12a 100644 ---- a/pipenv/patched/piptools/_compat/pip_compat.py -+++ b/pipenv/patched/piptools/_compat/pip_compat.py +diff --git a/piptools/_compat/pip_compat.py b/piptools/_compat/pip_compat.py +index 7e8cdf3..96c8a1e 100644 +--- a/piptools/_compat/pip_compat.py ++++ b/piptools/_compat/pip_compat.py @@ -1,30 +1,40 @@ # -*- coding=utf-8 -*- import importlib @@ -437,6 +447,12 @@ index 7e8cdf3..2b5c12a 100644 -is_file_url = do_import('download', 'is_file_url') -url_to_path = do_import('download', 'url_to_path') -PackageFinder = do_import('index', 'PackageFinder') +-FormatControl = do_import('index', 'FormatControl') +-Wheel = do_import('wheel', 'Wheel') +-Command = do_import('basecommand', 'Command') +-cmdoptions = do_import('cmdoptions') +-get_installed_distributions = do_import('utils.misc', 'get_installed_distributions', old_path='utils') +-PyPI = do_import('models.index', 'PyPI') +InstallRequirement = do_import('req.req_install', 'InstallRequirement', vendored_name='notpip') +parse_requirements = do_import('req.req_file', 'parse_requirements', vendored_name='notpip') +RequirementSet = do_import('req.req_set', 'RequirementSet', vendored_name='notpip') @@ -445,13 +461,11 @@ index 7e8cdf3..2b5c12a 100644 +is_file_url = do_import('download', 'is_file_url', vendored_name='notpip') +url_to_path = do_import('download', 'url_to_path', vendored_name='notpip') +PackageFinder = do_import('index', 'PackageFinder', vendored_name='notpip') - FormatControl = do_import('index', 'FormatControl') --Wheel = do_import('wheel', 'Wheel') ++FormatControl = do_import('index', 'FormatControl', vendored_name='notpip') +Wheel = do_import('wheel', 'Wheel', vendored_name='notpip') - Command = do_import('basecommand', 'Command') - cmdoptions = do_import('cmdoptions') - get_installed_distributions = do_import('utils.misc', 'get_installed_distributions', old_path='utils') --PyPI = do_import('models.index', 'PyPI') ++Command = do_import('basecommand', 'Command', vendored_name='pip9') ++cmdoptions = do_import('cmdoptions', vendored_name='pip9') ++get_installed_distributions = do_import('utils.misc', 'get_installed_distributions', old_path='utils', vendored_name='pip9') +PyPI = do_import('models.index', 'PyPI', vendored_name='notpip') +SafeFileCache = do_import('download', 'SafeFileCache', vendored_name='notpip') diff --git a/pipenv/patched/piptools/_compat/__init__.py b/piptools/_compat/__init__.py diff --git a/tests/integration/test_project.py b/tests/integration/test_project.py index 3419d4c7..5deccc84 100644 --- a/tests/integration/test_project.py +++ b/tests/integration/test_project.py @@ -130,7 +130,7 @@ verify_ssl = "true" name = "pypi" [[source]] -url = "https://pypi.org/simple" +url = "https://pypi.python.org/simple" verify_ssl = "true" name = "legacy"