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

pdm gets stuck in an infinite loop resolving packages when use_uv is true and using dynamic version number #3207

Closed
1 task done
DetachHead opened this issue Oct 12, 2024 · 2 comments · Fixed by #3220
Closed
1 task done
Assignees
Labels
🐛 bug Something isn't working 🤔 waiting for feedback Requires more information to clarify the issue

Comments

@DetachHead
Copy link
Contributor

DetachHead commented Oct 12, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

when using a dynamic version number ([tool.pdm.version]), it seems to get caught in an infinite loop when resolving packages.

Steps to reproduce

  1. create a script to return a version number:
    # get_version.py
    def get_version() -> str:
        return '1.0.0'
  2. add a dynamic version to pyproject.toml:
    [tool.pdm]
    distribution = false
    
    [tool.pdm.version]
    source = "call"
    getter = "get_version:get_version"
    
    [project]
    name = "asdfads"
    description = "Default template for PDM package"
    authors = [
        {name = "detachhead", email = "detachhead@users.noreply.github.com"},
    ]
    dependencies = []
    requires-python = "==3.13.*"
    readme = "README.md"
    license = {text = "MIT"}
    dynamic = ["version"]
  3. pdm config -l use_uv true
  4. pdm sync -v

Actual behavior

gets stuck in an infinite loop

output of `pdm sync -v`

> .\pw pdm sync -v
WARNING: Lockfile hash doesn't match pyproject.toml, packages may be outdated
STATUS: Resolving packages from lockfile...
WARNING: inherit_metadata strategy is not supported by uv resolver, it will be ignored
unearth.preparer: The file . is a local directory, use it directly
pdm.termui: Running PEP 517 backend to get metadata for <Link file:///C:/Users/user/Documents/asdfads (from None)>
pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
INFO: Using uv is experimental and might break due to uv updates.
Running uv lock command: ['C:\\Users\\user\\Documents\\asdfads\\.pyprojectx\\venvs\\main-5a0cff5c796261630b53b6bc411b2e24-py3.13\\Scripts\\python.exe', '-m', 'uv', 'lock', '-p', 
'C:\\Users\\user\\Documents\\asdfads\\.venv\\Scripts\\python.exe', '--verbose', '--index-url', 'https://pypi.org/simple', '--index-strategy=unsafe-best-match']
DEBUG uv 0.4.20
DEBUG Found workspace root: `C:\Users\user\Documents\asdfads`
DEBUG Adding current workspace member: `C:\Users\user\Documents\asdfads`
DEBUG The virtual environment's Python version satisfies `path `.venv\Scripts\python.exe``
DEBUG Using request timeout of 30s
DEBUG Starting clean resolution
DEBUG No static `pyproject.toml` available for: asdfads @ file:///C:/Users/user/Documents/asdfads (PyprojectToml(DynamicField("version")))
DEBUG Acquired lock for `C:\Users\user\AppData\Local\uv\cache\sdists-v4\path\2649c157ce7a43fa`
WARN Failed to read metadata for file: The system cannot find the file specified. (os error 2)
WARN Failed to read metadata for file: The system cannot find the file specified. (os error 2)
DEBUG Preparing metadata for: asdfads @ file:///C:/Users/user/Documents/asdfads
DEBUG Ignoring empty directory
DEBUG Resolving build requirements
DEBUG Solving with installed Python version: 3.13.0
DEBUG Solving with target Python version: >=3.13.0
DEBUG Adding direct dependency: setuptools>=40.8.0
DEBUG Found stale response for: https://pypi.org/simple/setuptools/
DEBUG Sending revalidation request for: https://pypi.org/simple/setuptools/
DEBUG Found not-modified response for: https://pypi.org/simple/setuptools/
DEBUG Searching for a compatible version of setuptools (>=40.8.0)
DEBUG Selecting: setuptools==75.1.0 [compatible] (setuptools-75.1.0-py3-none-any.whl)
DEBUG Found fresh response for: https://files.pythonhosted.org/packages/ff/ae/f19306b5a221f6a436d8f2238d5b80925004093fa3edea59835b514d9057/setuptools-75.1.0-py3-none-any.whl.metadata    
DEBUG Tried 1 versions: setuptools 1
DEBUG Split specific environment resolution took 0.065s
DEBUG Installing in setuptools==75.1.0 in C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM
DEBUG Requirement already cached: setuptools==75.1.0
DEBUG Installing build requirement: setuptools==75.1.0
DEBUG Extracting file name=PackageName("setuptools")
DEBUG Extracted 554 files name=PackageName("setuptools")
DEBUG No entrypoints name=PackageName("setuptools")
DEBUG No data name=PackageName("setuptools")
DEBUG Writing extra metadata name=PackageName("setuptools")
DEBUG Writing record name=PackageName("setuptools")
DEBUG Creating PEP 517 build environment
DEBUG Calling `setuptools.build_meta:__legacy__.get_requires_for_build_wheel()`
DEBUG running egg_info
DEBUG writing src\asdfads.egg-info\PKG-INFO
DEBUG writing dependency_links to src\asdfads.egg-info\dependency_links.txt
DEBUG writing top-level names to src\asdfads.egg-info\top_level.txt
DEBUG reading manifest file 'src\asdfads.egg-info\SOURCES.txt'
DEBUG writing manifest file 'src\asdfads.egg-info\SOURCES.txt'
DEBUG Calling `setuptools.build_meta:__legacy__.prepare_metadata_for_build_wheel()`
DEBUG running dist_info
DEBUG creating C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM\metadata_directory\asdfads.egg-info
DEBUG writing C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM\metadata_directory\asdfads.egg-info\PKG-INFO
DEBUG writing dependency_links to C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM\metadata_directory\asdfads.egg-info\dependency_links.txt
DEBUG writing top-level names to C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM\metadata_directory\asdfads.egg-info\top_level.txt
DEBUG writing manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG reading manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG writing manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG creating 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp0RtzeM\metadata_directory\asdfads-0.0.0.dist-info'
DEBUG Prepared metadata for: asdfads @ file:///C:/Users/user/Documents/asdfads
DEBUG No workspace root found, using project root
DEBUG Released lock at `C:\Users\user\AppData\Local\uv\cache\sdists-v4\path\2649c157ce7a43fa\.lock`
DEBUG Solving with installed Python version: 3.13.0
DEBUG Solving with target Python version: ==3.13.0
DEBUG Adding direct dependency: asdfads*
DEBUG Searching for a compatible version of asdfads @ file:///C:/Users/user/Documents/asdfads (*)
DEBUG Tried 1 versions: asdfads 1
DEBUG Split universal resolution took 0.001s
Resolved 1 package in 3.12s
unearth.preparer: The file . is a local directory, use it directly
pdm.termui: Running PEP 517 backend to get metadata for <Link file:///C:/Users/user/Documents/asdfads (from None)>
pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
Running uv lock command: ['C:\\Users\\user\\Documents\\asdfads\\.pyprojectx\\venvs\\main-5a0cff5c796261630b53b6bc411b2e24-py3.13\\Scripts\\python.exe', '-m', 'uv', 'lock', '-p', 
'C:\\Users\\user\\Documents\\asdfads\\.venv\\Scripts\\python.exe', '--verbose', '--index-url', 'https://pypi.org/simple', '--index-strategy=unsafe-best-match']
DEBUG uv 0.4.20
DEBUG Found workspace root: `C:\Users\user\Documents\asdfads`
DEBUG Adding current workspace member: `C:\Users\user\Documents\asdfads`
DEBUG The virtual environment's Python version satisfies `path `.venv\Scripts\python.exe``
DEBUG Using request timeout of 30s
DEBUG Starting clean resolution
DEBUG No static `pyproject.toml` available for: asdfads @ file:///C:/Users/user/Documents/asdfads (PyprojectToml(DynamicField("version")))
DEBUG Acquired lock for `C:\Users\user\AppData\Local\uv\cache\sdists-v4\path\2649c157ce7a43fa`
WARN Failed to read metadata for file: The system cannot find the file specified. (os error 2)
WARN Failed to read metadata for file: The system cannot find the file specified. (os error 2)
DEBUG Preparing metadata for: asdfads @ file:///C:/Users/user/Documents/asdfads
DEBUG Ignoring empty directory
DEBUG Resolving build requirements
DEBUG Solving with installed Python version: 3.13.0
DEBUG Solving with target Python version: >=3.13.0
DEBUG Adding direct dependency: setuptools>=40.8.0
DEBUG Found fresh response for: https://pypi.org/simple/setuptools/
DEBUG Searching for a compatible version of setuptools (>=40.8.0)
DEBUG Selecting: setuptools==75.1.0 [compatible] (setuptools-75.1.0-py3-none-any.whl)
DEBUG Found fresh response for: https://files.pythonhosted.org/packages/ff/ae/f19306b5a221f6a436d8f2238d5b80925004093fa3edea59835b514d9057/setuptools-75.1.0-py3-none-any.whl.metadata    
DEBUG Tried 1 versions: setuptools 1
DEBUG Split specific environment resolution took 0.054s
DEBUG Installing in setuptools==75.1.0 in C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB
DEBUG Requirement already cached: setuptools==75.1.0
DEBUG Installing build requirement: setuptools==75.1.0
DEBUG Extracting file name=PackageName("setuptools")
DEBUG Extracted 554 files name=PackageName("setuptools")
DEBUG No entrypoints name=PackageName("setuptools")
DEBUG No data name=PackageName("setuptools")
DEBUG Writing extra metadata name=PackageName("setuptools")
DEBUG Writing record name=PackageName("setuptools")
DEBUG Creating PEP 517 build environment
DEBUG Calling `setuptools.build_meta:__legacy__.get_requires_for_build_wheel()`
DEBUG running egg_info
DEBUG writing src\asdfads.egg-info\PKG-INFO
DEBUG writing dependency_links to src\asdfads.egg-info\dependency_links.txt
DEBUG writing top-level names to src\asdfads.egg-info\top_level.txt
DEBUG reading manifest file 'src\asdfads.egg-info\SOURCES.txt'
DEBUG writing manifest file 'src\asdfads.egg-info\SOURCES.txt'
DEBUG Calling `setuptools.build_meta:__legacy__.prepare_metadata_for_build_wheel()`
DEBUG running dist_info
DEBUG creating C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB\metadata_directory\asdfads.egg-info
DEBUG writing C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB\metadata_directory\asdfads.egg-info\PKG-INFO
DEBUG writing dependency_links to C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB\metadata_directory\asdfads.egg-info\dependency_links.txt
DEBUG writing top-level names to C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB\metadata_directory\asdfads.egg-info\top_level.txt
DEBUG writing manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG reading manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG writing manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG creating 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpvDUaVB\metadata_directory\asdfads-0.0.0.dist-info'
DEBUG Prepared metadata for: asdfads @ file:///C:/Users/user/Documents/asdfads
DEBUG No workspace root found, using project root
DEBUG Released lock at `C:\Users\user\AppData\Local\uv\cache\sdists-v4\path\2649c157ce7a43fa\.lock`
DEBUG Solving with installed Python version: 3.13.0
DEBUG Solving with target Python version: ==3.13.0
DEBUG Adding direct dependency: asdfads*
DEBUG Searching for a compatible version of asdfads @ file:///C:/Users/user/Documents/asdfads (*)
DEBUG Tried 1 versions: asdfads 1
DEBUG Split universal resolution took 0.001s
Resolved 1 package in 3.72s
unearth.preparer: The file . is a local directory, use it directly
pdm.termui: Running PEP 517 backend to get metadata for <Link file:///C:/Users/user/Documents/asdfads (from None)>
pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
Running uv lock command: ['C:\\Users\\user\\Documents\\asdfads\\.pyprojectx\\venvs\\main-5a0cff5c796261630b53b6bc411b2e24-py3.13\\Scripts\\python.exe', '-m', 'uv', 'lock', '-p', 
'C:\\Users\\user\\Documents\\asdfads\\.venv\\Scripts\\python.exe', '--verbose', '--index-url', 'https://pypi.org/simple', '--index-strategy=unsafe-best-match']
DEBUG uv 0.4.20
DEBUG Found workspace root: `C:\Users\user\Documents\asdfads`
DEBUG Adding current workspace member: `C:\Users\user\Documents\asdfads`
DEBUG The virtual environment's Python version satisfies `path `.venv\Scripts\python.exe``
DEBUG Using request timeout of 30s
DEBUG Starting clean resolution
DEBUG No static `pyproject.toml` available for: asdfads @ file:///C:/Users/user/Documents/asdfads (PyprojectToml(DynamicField("version")))
DEBUG Acquired lock for `C:\Users\user\AppData\Local\uv\cache\sdists-v4\path\2649c157ce7a43fa`
WARN Failed to read metadata for file: The system cannot find the file specified. (os error 2)
WARN Failed to read metadata for file: The system cannot find the file specified. (os error 2)
DEBUG Preparing metadata for: asdfads @ file:///C:/Users/user/Documents/asdfads
DEBUG Ignoring empty directory
DEBUG Resolving build requirements
DEBUG Solving with installed Python version: 3.13.0
DEBUG Solving with target Python version: >=3.13.0
DEBUG Adding direct dependency: setuptools>=40.8.0
DEBUG Found fresh response for: https://pypi.org/simple/setuptools/
DEBUG Searching for a compatible version of setuptools (>=40.8.0)
DEBUG Selecting: setuptools==75.1.0 [compatible] (setuptools-75.1.0-py3-none-any.whl)
DEBUG Found fresh response for: https://files.pythonhosted.org/packages/ff/ae/f19306b5a221f6a436d8f2238d5b80925004093fa3edea59835b514d9057/setuptools-75.1.0-py3-none-any.whl.metadata    
DEBUG Tried 1 versions: setuptools 1
DEBUG Split specific environment resolution took 0.019s
DEBUG Installing in setuptools==75.1.0 in C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl
DEBUG Requirement already cached: setuptools==75.1.0
DEBUG Installing build requirement: setuptools==75.1.0
DEBUG Extracting file name=PackageName("setuptools")
DEBUG Extracted 554 files name=PackageName("setuptools")
DEBUG No entrypoints name=PackageName("setuptools")
DEBUG No data name=PackageName("setuptools")
DEBUG Writing extra metadata name=PackageName("setuptools")
DEBUG Writing record name=PackageName("setuptools")
DEBUG Creating PEP 517 build environment
DEBUG Calling `setuptools.build_meta:__legacy__.get_requires_for_build_wheel()`
DEBUG running egg_info
DEBUG writing src\asdfads.egg-info\PKG-INFO
DEBUG writing dependency_links to src\asdfads.egg-info\dependency_links.txt
DEBUG writing top-level names to src\asdfads.egg-info\top_level.txt
DEBUG reading manifest file 'src\asdfads.egg-info\SOURCES.txt'
DEBUG writing manifest file 'src\asdfads.egg-info\SOURCES.txt'
DEBUG Calling `setuptools.build_meta:__legacy__.prepare_metadata_for_build_wheel()`
DEBUG running dist_info
DEBUG creating C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl\metadata_directory\asdfads.egg-info
DEBUG writing C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl\metadata_directory\asdfads.egg-info\PKG-INFO
DEBUG writing dependency_links to C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl\metadata_directory\asdfads.egg-info\dependency_links.txt
DEBUG writing top-level names to C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl\metadata_directory\asdfads.egg-info\top_level.txt
DEBUG writing manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG reading manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG writing manifest file 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl\metadata_directory\asdfads.egg-info\SOURCES.txt'
DEBUG creating 'C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpoQtzYl\metadata_directory\asdfads-0.0.0.dist-info'
DEBUG Prepared metadata for: asdfads @ file:///C:/Users/user/Documents/asdfads
DEBUG No workspace root found, using project root
DEBUG Released lock at `C:\Users\user\AppData\Local\uv\cache\sdists-v4\path\2649c157ce7a43fa\.lock`
DEBUG Solving with installed Python version: 3.13.0
DEBUG Solving with target Python version: ==3.13.0
DEBUG Adding direct dependency: asdfads*
DEBUG Searching for a compatible version of asdfads @ file:///C:/Users/user/Documents/asdfads (*)
DEBUG Tried 1 versions: asdfads 1
DEBUG Split universal resolution took 0.001s
Resolved 1 package in 3.37s
unearth.preparer: The file . is a local directory, use it directly
pdm.termui: Running PEP 517 backend to get metadata for <Link file:///C:/Users/user/Documents/asdfads (from None)>
pdm.termui: Preparing environment(Isolated mode) for PEP 517 build...
Running uv lock command: ['C:\\Users\\user\\Documents\\asdfads\\.pyprojectx\\venvs\\main-5a0cff5c796261630b53b6bc411b2e24-py3.13\\Scripts\\python.exe', '-m', 'uv', 'lock', '-p', 
'C:\\Users\\user\\Documents\\asdfads\\.venv\\Scripts\\python.exe', '--verbose', '--index-url', 'https://pypi.org/simple', '--index-strategy=unsafe-best-match']
DEBUG uv 0.4.20

(it continues like this forever)

Expected behavior

it syncs successfully

Environment Information

PDM version:
  2.19.2    
Python Interpreter:
  C:\Users\user\Documents\asdfads\.venv\Scripts\python.exe (3.13)
Project Root:
  C:/Users/user/Documents/asdfads
Local Packages:
  
{
  "implementation_name": "cpython",  
  "implementation_version": "3.13.0",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.19045",
  "python_full_version": "3.13.0",
  "platform_python_implementation": "CPython",
  "python_version": "3.13",
  "sys_platform": "win32"
}
@DetachHead DetachHead added the 🐛 bug Something isn't working label Oct 12, 2024
@frostming
Copy link
Collaborator

Did you forget to add the [build-system] table?

@frostming frostming added the 🤔 waiting for feedback Requires more information to clarify the issue label Oct 18, 2024
@DetachHead
Copy link
Contributor Author

sorry forgot to add that part. i'm using pdm's build backend, but the same issue occurs even if the build-system section is not included:

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

@frostming frostming self-assigned this Oct 18, 2024
frostming added a commit that referenced this issue Oct 18, 2024
Fixes #3207

Signed-off-by: Frost Ming <me@frostming.com>
frostming added a commit that referenced this issue Oct 18, 2024
* fix: infinite loop in uv mode
Fixes #3207

Signed-off-by: Frost Ming <me@frostming.com>

* fix: uv install include self

Signed-off-by: Frost Ming <me@frostming.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🤔 waiting for feedback Requires more information to clarify the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants