Skip to content

Commit

Permalink
Merge pull request #4593 from pypa/bugfix/4549
Browse files Browse the repository at this point in the history
Fix #4549: Ignore incompatibilities when resolve dist
  • Loading branch information
frostming authored Jan 20, 2021
2 parents 3ba0232 + db5e0c1 commit 5f91369
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions news/4549.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that ``importlib-metadata`` from the project's dependencies conflicts with that from ``pipenv``'s.
Empty file.
7 changes: 6 additions & 1 deletion pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ def resolve_dist(cls, dist, working_set):
except (KeyError, AttributeError, OSError, IOError): # The METADATA file can't be found
return deps
for req in reqs:
dist = working_set.find(req)
try:
dist = working_set.find(req)
except pkg_resources.VersionConflict:
# https://github.com/pypa/pipenv/issues/4549
# The requirement is already present with incompatible version.
continue
deps |= cls.resolve_dist(dist, working_set)
return deps

Expand Down
2 changes: 1 addition & 1 deletion pipenv/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def find_site_path(pkg, site_dir=None):
import pkg_resources
if site_dir is not None:
if site_dir is None:
site_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
working_set = pkg_resources.WorkingSet([site_dir] + sys.path[:])
for dist in working_set:
Expand Down
20 changes: 9 additions & 11 deletions tasks/vendoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io
import itertools
import json
import os
import re
import shutil

Expand All @@ -21,7 +22,7 @@

from urllib3.util import parse_url as urllib3_parse

from pipenv.vendor.vistir.compat import NamedTemporaryFile, TemporaryDirectory
from pipenv.vendor.vistir.compat import TemporaryDirectory
from pipenv.vendor.vistir.contextmanagers import open_file
from pipenv.vendor.requirementslib.models.lockfile import Lockfile, merge_items
import pipenv.vendor.parse as parse
Expand Down Expand Up @@ -205,14 +206,10 @@ def _recursive_write_to_zip(zf, path, root=None):

@invoke.task
def update_safety(ctx):
ignore_subdeps = ["pip", "pip-egg-info", "bin", "pipenv", "virtualenv", "virtualenv-clone", "setuptools",]
ignore_subdeps = ["pip", "pip-egg-info", "bin", "pipenv", "virtualenv", "virtualenv-clone", "setuptools"]
ignore_files = ["pip-delete-this-directory.txt", "PKG-INFO", "easy_install.py", "clonevirtualenv.py"]
ignore_patterns = ["*.pyd", "*.so", "**/*.pyc", "*.pyc"]
cmd_envvars = {
"PIPENV_NO_INHERIT": "true",
"PIPENV_IGNORE_VIRTUALENVS": "true",
"PIPENV_VENV_IN_PROJECT": "true"
}

patched_dir = _get_patched_dir(ctx)
vendor_dir = _get_vendor_dir(ctx)
safety_dir = Path(__file__).absolute().parent.joinpath("safety")
Expand Down Expand Up @@ -264,7 +261,7 @@ def update_safety(ctx):
)
log("downloading deps via pip: {0}".format(pip_command))
ctx.run(pip_command)
safety_build_dir = build_dir / "safety"

yaml_build_dir = build_dir / "pyyaml"
lib_dir = safety_dir.joinpath("lib")

Expand Down Expand Up @@ -384,14 +381,15 @@ def install_pyyaml(ctx, vendor_dir):
if build_dir.exists() and build_dir.is_dir():
log("dropping pre-existing build dir at {0}".format(build_dir.as_posix()))
drop_dir(build_dir)
build_dir.mkdir()
with TemporaryDirectory(prefix="pipenv-", suffix="-safety") as download_dir:
pip_command = "pip download -b {0} --no-binary=:all: --no-clean --no-deps -d {1} pyyaml safety".format(
build_dir.absolute().as_posix(), str(download_dir.name),
)
temp_env = "TEMP" if os.name == "nt" else "TMPDIR"
log("downloading deps via pip: {0}".format(pip_command))
ctx.run(pip_command)
safety_build_dir = build_dir / "safety"
yaml_build_dir = build_dir / "pyyaml"
ctx.run(pip_command, env={temp_env: str(build_dir)})
yaml_build_dir = next(build_dir.glob('pip-download-*/pyyaml_*'))
yaml_dir = vendor_dir / "yaml"
yaml_lib_dir_map = {
"2": {
Expand Down

0 comments on commit 5f91369

Please sign in to comment.