From e8a0dd043ad8947bdc1df738dd89f54a8f48ed81 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Fri, 25 Oct 2024 21:25:26 -0400 Subject: [PATCH] solves the locally built git wheel wheres the ref? mystery --- news/6281.bugfix.rst | 44 +++++++++++++++++------------------------ pipenv/utils/locking.py | 18 +++++++++-------- pyproject.toml | 2 +- 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/news/6281.bugfix.rst b/news/6281.bugfix.rst index 9ad06b5ba..de5467bc9 100644 --- a/news/6281.bugfix.rst +++ b/news/6281.bugfix.rst @@ -1,26 +1,18 @@ -# This patch series improves Pipenv's reverse dependency handling, JSON output support, and upgrade routines, ensuring more accurate dependency management and better error handling. - -## Key Changes - -* **Reverse Dependency Graph**: - * ``graph --reverse`` now supports JSON output, consistent with ``pipdeptree``. - * Enhanced JSON-tree format for reverse dependencies, improving compatibility with JSON-processing tools. - -* **Improved Upgrade Logic**: - * Pre-sync step added before conflict analysis to ensure accurate dependency resolution. - * Early conflict detection prevents incompatible upgrades, improving lock file integrity. - * Enhanced handling of reverse dependencies to avoid unintended conflicts during updates. - -* **Refactoring & Consistent Output**: - * Replaced ``click.echo`` calls with ``console`` and ``err`` utilities for consistent output and error handling. - * Streamlined upgrade logic to reduce installation phases and improve performance. - -## Bug Fixes - -* Fixed incompatibility when using both ``--json`` and ``--json-tree`` flags simultaneously. -* Addressed #6281: Resolved transitive dependency conflicts (e.g., ``google-api-core`` vs. ``protobuf``). -* Updated tests to cover new JSON outputs and compatibility checks. - -## Impact - -These changes improve accuracy and reliability in complex dependency trees, ensuring robust updates and clearer error reporting. +Fix dependency resolution edge cases and versioning constraints handling: +* Allow JSON format options for ``--reverse`` dependency graph output matching pipdeptree +* Improve installation and upgrade routines to better handle dependencies +* Add ability to specify json output as pipdeptree does +* Add more consistent handling of VCS dependencies and references +* Fix synchronization of development and default dependencies during updates +* Ensure proper propagation of version constraints during updates +* Fix handling of ``~=`` and other version specifiers during updates + +Key Changes: +* Improved reverse dependency analysis to catch conflicts earlier in resolution +* Better handling of VCS package lock data, preserving refs and subdirectories +* Fixed issue where VCS references could be lost in lock file when installed via commit hash +* Better handling of pipfile categories during installation and updates +* Corrected logic for development dependency resolution and constraint propagation +* Improved validation and preservation of version specifiers during updates + +This improves stability when working with complex dependency trees and version constraints. diff --git a/pipenv/utils/locking.py b/pipenv/utils/locking.py index 8e180b9b4..413e2fc86 100644 --- a/pipenv/utils/locking.py +++ b/pipenv/utils/locking.py @@ -10,6 +10,7 @@ from typing import Any, Dict, Iterator, List, Optional, Set, Tuple from pipenv.patched.pip._internal.req.req_install import InstallRequirement +from pipenv.utils.constants import VCS_LIST from pipenv.utils.dependencies import ( clean_resolved_dep, determine_vcs_revision_hash, @@ -54,12 +55,14 @@ def format_requirement_for_lockfile( entry: Dict[str, Any] = {"name": name} pipfile_entry = pipfile_entries.get(name, pipfile_entries.get(req.name, {})) # Handle VCS requirements - link = None + is_vcs_dep = next(iter([vcs for vcs in VCS_LIST if vcs in pipfile_entry]), None) if req.link and req.link.is_vcs: - link = req.link - elif req.cached_wheel_source_link: - link = req.cached_wheel_source_link - if link: + is_vcs_dep = True + if is_vcs_dep: + if req.link and req.link.is_vcs: + link = req.link + else: + link = req.cached_wheel_source_link vcs = link.scheme.split("+", 1)[0] # Get VCS URL from original deps or normalize the link URL @@ -72,7 +75,7 @@ def format_requirement_for_lockfile( # Handle subdirectory information if pipfile_entry.get("subdirectory"): entry["subdirectory"] = pipfile_entry["subdirectory"] - elif req.link.subdirectory_fragment: + elif link.subdirectory_fragment: entry["subdirectory"] = link.subdirectory_fragment # Handle reference information - try multiple sources @@ -85,9 +88,8 @@ def format_requirement_for_lockfile( entry["version"] = str(req.req.specifier) elif req.specifier: entry["version"] = str(req.specifier) - elif req.link and req.link.is_file: + if req.link and req.link.is_file: entry["file"] = req.link.url - # Add index information if name in index_lookup: entry["index"] = index_lookup[name] diff --git a/pyproject.toml b/pyproject.toml index 325381e01..f93da5ed6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -198,7 +198,7 @@ keep_full_version = true max_supported_python = "3.13" [tool.pytest.ini_options] -addopts = "-ra" +addopts = "-ra --no-cov" plugins = "xdist" testpaths = [ "tests" ] # Add vendor and patched in addition to the default list of ignored dirs