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

pw --lock with lock-python-version attempts to install dependency on python 3.8 that should only be installed on newer versions of python #112

Closed
DetachHead opened this issue Aug 5, 2024 · 2 comments

Comments

@DetachHead
Copy link
Contributor

Describe the bug
thanks for adding the lock-python-version option!

i'm on python 3.12 and trying to target 3.8 when running pw --lock to install pdm. pdm depends on truststore on python 3.10 and above, but it seems to be trying to install it anyway which causes it to fail:

./pw --lock 

locking main requirements
warning: The requested Python version 3.9 is not available; 3.12.0 will be used to build dependencies instead.
  × No solution found when resolving dependencies:
  ╰─▶ Because truststore{python_version >= '3.10'}==0.9.0 was yanked (reason:
      Doesn't work for CPython 3.13, upgrade to 0.9.1) and the requested
      Python version (>=3.9) does not satisfy Python>=3.10, we can conclude
      that any of:
          truststore{python_version >= '3.10'}==0.1.0
          truststore{python_version >= '3.10'}==0.2.0
          truststore{python_version >= '3.10'}==0.3.0
          truststore{python_version >= '3.10'}==0.4.0
          truststore{python_version >= '3.10'}==0.5.0
          truststore{python_version >= '3.10'}==0.6.0
          truststore{python_version >= '3.10'}==0.6.1
          truststore{python_version >= '3.10'}==0.7.0
          truststore{python_version >= '3.10'}==0.8.0
          truststore{python_version >= '3.10'}==0.9.0
          truststore{python_version >= '3.10'}==0.9.1
       are incompatible.
      And because only the following versions of truststore{python_version >=
      '3.10'} are available:
          truststore{python_version >= '3.10'}==0.1.0
          truststore{python_version >= '3.10'}==0.2.0
          truststore{python_version >= '3.10'}==0.3.0
          truststore{python_version >= '3.10'}==0.4.0
          truststore{python_version >= '3.10'}==0.5.0
          truststore{python_version >= '3.10'}==0.6.0
          truststore{python_version >= '3.10'}==0.6.1
          truststore{python_version >= '3.10'}==0.7.0
          truststore{python_version >= '3.10'}==0.8.0
          truststore{python_version >= '3.10'}==0.9.0
          truststore{python_version >= '3.10'}==0.9.1
      and pdm>=2.16.1 depends on truststore{python_version >= '3.10'}, we can
      conclude that pdm>=2.16.1 cannot be used.
      And because only the following versions of pdm are available:
          pdm<=2.16.1
          pdm==2.17.0
          pdm==2.17.1
          pdm==2.17.2
          pdm==2.17.3
      and you require pdm>=2.16.1, we can conclude that the requirements are
      unsatisfiable.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\project\.pyprojectx\pyprojectx\3.0.3-py3.12\Scripts\pyprojectx.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\project\.pyprojectx\pyprojectx\3.0.3-py3.12\Lib\site-packages\pyprojectx\cli.py", line 21, in main
    _run(sys.argv)
  File "C:\Users\user\project\.pyprojectx\pyprojectx\3.0.3-py3.12\Lib\site-packages\pyprojectx\cli.py", line 46, in _run
    _lock_requirements(argv, config, options)
  File "C:\Users\user\project\.pyprojectx\pyprojectx\3.0.3-py3.12\Lib\site-packages\pyprojectx\cli.py", line 288, in _lock_requirements
    _ensure_ctx(config, ctx, env=config.env, options=options, pw_args=argv)
  File "C:\Users\user\project\.pyprojectx\pyprojectx\3.0.3-py3.12\Lib\site-packages\pyprojectx\cli.py", line 191, in _ensure_ctx
    requirements, modified = get_or_update_locked_requirements(ctx, config, options.quiet)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\project\.pyprojectx\pyprojectx\3.0.3-py3.12\Lib\site-packages\pyprojectx\lock.py", line 51, in get_or_update_locked_requirements    
    locked_requirements = _freeze(ctx, requirements, config.lock_python_version, quiet)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\project\.pyprojectx\pyprojectx\3.0.3-py3.12\Lib\site-packages\pyprojectx\lock.py", line 75, in _freeze
    raise Warning(f"Failed to lock {ctx_name} requirements.")
Warning: Failed to lock main requirements.

To Reproduce

  1. in pyrpoject.toml:
    [tool.pyprojectx]
    lock-python-version = "3.8"
    main = ["pdm>=2.16.1"]
  2. run ./pw --lock

Expected behavior
no error

Desktop (please complete the following information):

  • Python version: 3.12
  • OS: windows 11

Additional context
could this be because the version of python i'm using doesn't match the version i'm targeting? should lock-python-version support a range? eg. ">=3.8,<3.13"

@houbie
Copy link
Collaborator

houbie commented Aug 5, 2024

This seems like a uv issue, it should indeed only consider truststore if python >=3.10
See astral-sh/uv#4668 and astral-sh/uv#5647

Until this gets resolved, you can try a manual workaround:

  • execute ./pw --lock using python>=3.10 (without specifying lock-python-version)
  • locate the truststore dependency in pw.lock and add ; python_version >= '3.10'
  • if you have a dependency on backports.strenum in your lock file, you also need to add ; python_version < '3.11' to it
  • now the lockfile should also be usable with python <3.10

@charliermarsh
Copy link

The uv issue is fixed in the next release (see: astral-sh/uv#8628).

houbie pushed a commit that referenced this issue Nov 5, 2024
@houbie houbie closed this as completed in 615a0e8 Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants