mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #5523 from pypa/issue-5479
Fix regression where wheel path is not included in the lockfile
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Fix regression where ``path`` is not propagated to the ``Pipfile.lock``.
|
||||
@@ -208,17 +208,16 @@ def clean_resolved_dep(dep, is_top_level=False, pipfile_entry=None):
|
||||
lockfile[key] = dep[key]
|
||||
# In case we lock a uri or a file when the user supplied a path
|
||||
# remove the uri or file keys from the entry and keep the path
|
||||
fs_key = next(iter(k for k in ["path", "file"] if k in dep), None)
|
||||
pipfile_fs_key = None
|
||||
if pipfile_entry:
|
||||
pipfile_fs_key = next(
|
||||
iter(k for k in ["path", "file"] if k in pipfile_entry), None
|
||||
)
|
||||
if fs_key and pipfile_fs_key and fs_key != pipfile_fs_key:
|
||||
lockfile[pipfile_fs_key] = pipfile_entry[pipfile_fs_key]
|
||||
elif fs_key is not None:
|
||||
lockfile[fs_key] = dep[fs_key]
|
||||
|
||||
preferred_file_keys = ["path", "file"]
|
||||
dependency_file_key = next(iter(k for k in preferred_file_keys if k in dep), None)
|
||||
if dependency_file_key:
|
||||
lockfile[dependency_file_key] = dep[dependency_file_key]
|
||||
# Pipfile entry overrides path/file from resolver
|
||||
if pipfile_entry and isinstance(pipfile_entry, dict):
|
||||
for k in preferred_file_keys:
|
||||
if k in pipfile_entry.keys():
|
||||
lockfile[k] = pipfile_entry[k]
|
||||
break
|
||||
# If a package is **PRESENT** in the pipfile but has no markers, make sure we
|
||||
# **NEVER** include markers in the lockfile
|
||||
if "markers" in dep and dep.get("markers", "").strip():
|
||||
|
||||
+6
-15
@@ -39,18 +39,14 @@ def format_requirement_for_lockfile(req, markers_lookup, index_lookup, hashes=No
|
||||
return name, entry
|
||||
|
||||
|
||||
def get_locked_dep(dep, pipfile_section, prefer_pipfile=True):
|
||||
# the prefer pipfile flag is not used yet, but we are introducing
|
||||
# it now for development purposes
|
||||
# TODO: Is this implementation clear? How can it be improved?
|
||||
def get_locked_dep(dep, pipfile_section):
|
||||
entry = None
|
||||
cleaner_kwargs = {"is_top_level": False, "pipfile_entry": None}
|
||||
if isinstance(dep, Mapping) and dep.get("name", ""):
|
||||
if isinstance(dep, Mapping) and dep.get("name"):
|
||||
dep_name = pep423_name(dep["name"])
|
||||
name = next(
|
||||
iter(k for k in pipfile_section.keys() if pep423_name(k) == dep_name), None
|
||||
)
|
||||
entry = pipfile_section[name] if name else None
|
||||
for pipfile_key, pipfile_entry in pipfile_section.items():
|
||||
if pep423_name(pipfile_key) == dep_name:
|
||||
entry = pipfile_entry
|
||||
|
||||
if entry:
|
||||
cleaner_kwargs.update({"is_top_level": True, "pipfile_entry": entry})
|
||||
@@ -62,12 +58,7 @@ def get_locked_dep(dep, pipfile_section, prefer_pipfile=True):
|
||||
lockfile_name, lockfile_dict = lockfile_entry.copy().popitem()
|
||||
lockfile_version = lockfile_dict.get("version", "")
|
||||
# Keep pins from the lockfile
|
||||
if (
|
||||
prefer_pipfile
|
||||
and lockfile_version != version
|
||||
and version.startswith("==")
|
||||
and "*" not in version
|
||||
):
|
||||
if lockfile_version != version and version.startswith("==") and "*" not in version:
|
||||
lockfile_dict["version"] = version
|
||||
lockfile_entry[lockfile_name] = lockfile_dict
|
||||
return lockfile_entry
|
||||
|
||||
@@ -60,6 +60,10 @@ def test_file_urls_work(pipenv_instance_pypi, pip_src_dir):
|
||||
assert c.returncode == 0
|
||||
assert "six" in p.pipfile["packages"]
|
||||
assert "file" in p.pipfile["packages"]["six"]
|
||||
assert 'six' in p.lockfile["default"]
|
||||
assert 'file' in p.lockfile["default"]["six"]
|
||||
assert "six-1.11.0-py2.py3-none-any.whl" in p.lockfile["default"]["six"]["file"]
|
||||
|
||||
|
||||
|
||||
@pytest.mark.e
|
||||
|
||||
Reference in New Issue
Block a user