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 complains when using 3.12 with requires-python >=3.10 #2347

Closed
1 task done
lmmx opened this issue Oct 29, 2023 · 5 comments
Closed
1 task done

PDM complains when using 3.12 with requires-python >=3.10 #2347

lmmx opened this issue Oct 29, 2023 · 5 comments
Labels
🐛 bug Something isn't working

Comments

@lmmx
Copy link

lmmx commented Oct 29, 2023

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

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

Steps to reproduce

I had a numpy dependency which wouldn't install, it turned out to be a 3.12 requirement to use numpy>=1.26 (see).

When I installed a package with the following TOML sections

dependencies = [
    "numpy>=1.26",
    "transformers",
    "pydantic>=2.4.2",
    "defopt",
]
requires-python = ">=3.10,<3.13"

I got the error:

$ python --version
Python 3.12.0
$ pdm install
Lock file does not exist
Updating the lock file...
🔒 Lock failed
Unable to find a resolution because the following dependencies don't work on all Python versions in the range of the project's `requires-python`: >=3.10.
  python>=3.9,<3.13 (from <Candidate numpy@1.26.0 from https://pypi.org/simple/numpy/>)
  python>=3.9,<3.13 (from <Candidate numpy@1.26.1 from https://pypi.org/simple/numpy/>)
A possible solution is to change the value of `requires-python` in pyproject.toml to >=3.10,<3.13.
See /tmp/pdm-lock-h1jlyfvt.log for detailed debug log.
[ResolutionImpossible]: Unable to find a resolution
Add '-v' to see the detailed traceback

Actual behavior

Installation fails.

Expected behavior

I presume it should be able to resolve the Python version without pinning the range like this?

If I have 3.12 and the Python version TOML config says >=3.10 then I would expect it to install for 3.12 without failing.

Environment Information

pdm info && pdm info --env
PDM version:
  2.10.0
Python Interpreter:
  /home/louis/miniconda3/envs/classipypi/bin/python (3.12)
Project Root:
  /home/louis/dev/classipypi
Local Packages:
  
{
  "implementation_name": "cpython",
  "implementation_version": "3.12.0",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "5.15.0-60-generic",
  "platform_system": "Linux",
  "platform_version": "#66~20.04.1-Ubuntu SMP Wed Jan 25 09:41:30 UTC 2023",
  "python_full_version": "3.12.0",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "linux"
}
@lmmx lmmx added the 🐛 bug Something isn't working label Oct 29, 2023
@xzmeng
Copy link
Contributor

xzmeng commented Oct 29, 2023

I've encoutered this problem several times recently, and it seems to be caused by numpy 1.26 pinning its maximum python version.

https://github.com/numpy/numpy/blob/411a55b9ec084c3315fe5f199351c31d0eb3c352/pyproject.toml#L29C19-L29C19

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Oct 29, 2023

Yes. As hinted in the error message, you have to add the upper bound to requires-python so that it is a subset of what your dependencies support.

The example you gave should work:

dependencies = [
    "numpy>=1.26",
    "transformers",
    "pydantic>=2.4.2",
    "defopt",
]
requires-python = ">=3.10,<3.13"

I suspect you didn't save before running pdm lock again?

@frostming
Copy link
Collaborator

In fact, version 2.10.0 introduced a new warning message that explicitly tells you how to fix it. It should have been shown but I don't know why it didn't appear in the output you pasted.

@sr-murthy
Copy link
Sponsor Contributor

I've encoutered this problem several times recently, and it seems to be caused by numpy 1.26 pinning its maximum python version.

https://github.com/numpy/numpy/blob/411a55b9ec084c3315fe5f199351c31d0eb3c352/pyproject.toml#L29C19-L29C19

I think Numpy applied this pin via a release branch - it doesn't appear in the main project TOML.

@xzmeng
Copy link
Contributor

xzmeng commented Nov 1, 2023

So numpy 1.26.2 will not complain it any more. Thanks for the information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants