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

Fix regression where wheel path is not included in the lockfile #5523

Merged
merged 4 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions news/5479.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression where ``path`` is not propagated to the ``Pipfile.lock``.
21 changes: 10 additions & 11 deletions pipenv/utils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
21 changes: 6 additions & 15 deletions pipenv/utils/locking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/test_install_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down