pdm-project / pdm

A modern Python package and dependency manager supporting the latest PEP standards
https://pdm-project.org
MIT License
7.03k stars 352 forks source link

pdm lock --update-reuse expands the $PROJECT_ROOT variable when extra dependencies are included #2852

Closed jakubman1 closed 3 weeks ago

jakubman1 commented 1 month ago

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

Suppose you have a local library and a main app in a monorepo as such:

my-repo
- app
-- pyproject.toml
-- pdm.lock
-- myapp/
- lib
-- pyproject.toml
-- pdm.lock
-- lib/

The app has the library listed as a dependency with extra dependencies using the $PROJECT_ROOT variable as: "lib[test] @ file:///${PROJECT_ROOT}/../lib" Try calling pdm lock, then pdm lock --update-reuse for the app, observe the library in the app pdm.lock file.

Actual behavior

After calling pdm lock, the pdm.lock file contains the following section:

[[package]]
name = "lib"
version = "0.1.0"
extras = ["test"]
requires_python = ">=3.8"
path = "../lib"
summary = "Library"
groups = ["default"]
dependencies = [
    "lib @ file:///${PROJECT_ROOT}/../lib",
    "pytest",
]

When calling pdm lock --update-reuse, the PROJECT_ROOT variable gets expanded to the actual path:

[[package]]
name = "lib"
version = "0.1.0"
extras = ["test"]
requires_python = ">=3.8"
path = "../lib"
summary = "Library"
groups = ["default"]
dependencies = [
    "lib @ file:///mnt/c/pdm-minimal/lib",
    "pytest",
]

Expected behavior

The pdm.lock file should be the same when calling pdm lock and then pdm lock --update-reuse immediately after, the PROJECT_ROOT variable should not get expanded.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.15.0
Python Interpreter:
  /mnt/c/pdm-minimal/app/.venv/bin/python (3.8)
Project Root:
  /mnt/c/pdm-minimal/app
Local Packages:

{
  "implementation_name": "cpython",
  "implementation_version": "3.8.10",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.146.1-microsoft-standard-WSL2",
  "platform_system": "Linux",
  "platform_version": "#1 SMP Thu Jan 11 04:09:03 UTC 2024",
  "python_full_version": "3.8.10",
  "platform_python_implementation": "CPython",
  "python_version": "3.8",
  "sys_platform": "linux"
}