Skip to content

Commit

Permalink
solves the locally built git wheel wheres the ref? mystery
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius committed Oct 26, 2024
1 parent 354220b commit e8a0dd0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
44 changes: 18 additions & 26 deletions news/6281.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 10 additions & 8 deletions pipenv/utils/locking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8a0dd0

Please sign in to comment.