Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only install packages for current python version #2076

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Only install packages for current python version
- Still resolve all packages to lockfile
- Fixes #1952

Signed-off-by: Dan Ryan <dan@danryan.co>
  • Loading branch information
techalchemy committed Apr 27, 2018
commit 903ad383729a47f6b7a10b59cba96cb39c58db09
4 changes: 3 additions & 1 deletion pipenv/patched/notpip/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,9 @@ def _link_package_versions(self, link, search, ignore_compatibility=True):
link.filename, link.requires_python)
support_this_python = True

if not support_this_python and not ignore_compatibility:
# Normally we would keep this the same, but instead we always
# want to include only things that support this python version
if not support_this_python: # and not ignore_compatibility:
logger.debug("The package %s is incompatible with the python"
"version in use. Acceptable python versions are:%s",
link, link.requires_python)
Expand Down
28 changes: 19 additions & 9 deletions pipenv/patched/piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,28 @@ def get_json_dependencies(self, ireq):
def gen(ireq):
if self.DEFAULT_INDEX_URL in self.finder.index_urls:

url = 'https://pypi.org/pypi/{0}/json'.format(ireq.req.name)
url = 'https://pypi.org/pypi/{0}/{1}/json'.format(
ireq.req.name,
str(ireq.req.specifier),
)
r = self.session.get(url)
if not r:
r = self.session.get(
'https://pypi.org/pypi/{0}/json'.format(
ireq.req.name,
)
)
json = r.json()

# TODO: Latest isn't always latest.
latest = list(r.json()['releases'].keys())[-1]
if str(ireq.req.specifier) == '=={0}'.format(latest):

for requires in r.json().get('info', {}).get('requires_dist', {}):
i = InstallRequirement.from_line(requires)

if 'extra' not in repr(i.markers):
yield i
version = json['version']
if str(ireq.req.specifier) == '=={0}'.format(version):
dependencies = json.get('info', {}).get('requires_dist', {})
for dep in dependencies:
req = InstallRequirement.from_line(dep)

if 'extra' not in repr(req.markers):
yield req

try:
if ireq not in self._json_dep_cache:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/pipenv/patched/notpip/index.py b/pipenv/patched/notpip/index.py
index bf1cba9..42968a5 100644
--- a/pipenv/patched/notpip/index.py
+++ b/pipenv/patched/notpip/index.py
@@ -711,7 +711,9 @@ class PackageFinder(object):
link.filename, link.requires_python)
support_this_python = True

- if not support_this_python and not ignore_compatibility:
+ # Normally we would keep this the same, but instead we always
+ # want to include only things that support this python version
+ if not support_this_python: # and not ignore_compatibility:
logger.debug("The package %s is incompatible with the python"
"version in use. Acceptable python versions are:%s",
link, link.requires_python)
42 changes: 42 additions & 0 deletions tasks/vendoring/patches/patched/piptools-update-json-search.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/pipenv/patched/piptools/repositories/pypi.py b/pipenv/patched/piptools/repositories/pypi.py
index e503197..ce78e8a 100644
--- a/pipenv/patched/piptools/repositories/pypi.py
+++ b/pipenv/patched/piptools/repositories/pypi.py
@@ -168,18 +168,28 @@ class PyPIRepository(BaseRepository):
def gen(ireq):
if self.DEFAULT_INDEX_URL in self.finder.index_urls:

- url = 'https://pypi.org/pypi/{0}/json'.format(ireq.req.name)
+ url = 'https://pypi.org/pypi/{0}/{1}/json'.format(
+ ireq.req.name,
+ str(ireq.req.specifier),
+ )
r = self.session.get(url)
+ if not r:
+ r = self.session.get(
+ 'https://pypi.org/pypi/{0}/json'.format(
+ ireq.req.name,
+ )
+ )
+ json = r.json()

# TODO: Latest isn't always latest.
- latest = list(r.json()['releases'].keys())[-1]
- if str(ireq.req.specifier) == '=={0}'.format(latest):
-
- for requires in r.json().get('info', {}).get('requires_dist', {}):
- i = InstallRequirement.from_line(requires)
-
- if 'extra' not in repr(i.markers):
- yield i
+ version = json['version']
+ if str(ireq.req.specifier) == '=={0}'.format(version):
+ dependencies = json.get('info', {}).get('requires_dist', {})
+ for dep in dependencies:
+ req = InstallRequirement.from_line(dep)
+
+ if 'extra' not in repr(req.markers):
+ yield req

try:
if ireq not in self._json_dep_cache: