-
-
Notifications
You must be signed in to change notification settings - Fork 449
Description
Describe the bug
I am on macos and want to install torch. Both torch and apple says to use the nightly builds of pytorch. Coincidentally, i also need a bugfix that's not in stable yet.
Torch docs say to use pip with --index-url https://download.pytorch.org/whl/nightly/cpu/
, which is not a thing in PDM as far as i could read. Instead i edited my project.toml like this:
[tool.pdm.resolution.overrides]
"torch" = "2.9.0.dev20250731"
[[tool.pdm.source]]
name = "nightly torch mps"
url = "https://download.pytorch.org/whl/nightly/cpu/torch/"
type = "find_links"
include_packages = ["torch"]
Notice the resolution override - "torch" = "2.9.0.dev20250731".
Now, if i try to install torch, it fails because it can't resolve a slightly different version of torch, for my platform:
bjorne-mbp % pdm list | grep "torch"
bjorne-mbp % pdm add "torch==2.9.0.dev20250731"
Adding packages to default dependencies: torch==2.9.0.dev20250731
0:00:02 🔒 Lock successful.
Changes are written to pyproject.toml.
Synchronizing working set with resolved packages: 1 to add, 0 to update, 0 to remove
✖ Install torch 2.9.0.dev20250731+cpu failed
Notice that last error message - it has failed to install a version with +cpu postfixed.
To reproduce
- be on macos, i suppose
pdm init
(with a venv too)- config project.toml as above (add tool.pdm.resolution.overrides and tool.pdm.source)
- pdm install torch
Expected Behavior
I expect the overriden version-pin not to be tampered with. I want to say, "don't add any version identifiers or stuff to my configured version".
Environment Information
PDM version:
2.25.6
Python Interpreter:
/Users/-----/PycharmProjects/-----/.venv/bin/python (3.13)
Project Root:
/Users/-----/PycharmProjects/-----
Local Packages:
{
"implementation_name": "cpython",
"implementation_version": "3.13.6",
"os_name": "posix",
"platform_machine": "arm64",
"platform_release": "24.6.0",
"platform_system": "Darwin",
"platform_version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000",
"python_full_version": "3.13.3",
"platform_python_implementation": "CPython",
"python_version": "3.13",
"sys_platform": "darwin"
}
Verbose Command Output
bjorne-mbp % pdm add -v torch
Adding packages to default dependencies: torch
pdm.termui: ======== Start resolving requirements ========
pdm.termui: torch
pdm.termui: Adding requirement python==3.13.*
pdm.termui: Adding requirement torch
pdm.termui: ======== Starting round 0 ========
pdm.termui: Adding new pin: python None
pdm.termui: ======== Starting round 1 ========
pdm.termui: Adding requirement filelock(from torch 2.9.0.dev20250731+cpu)
pdm.termui: Adding requirement typing-extensions>=4.10.0(from torch 2.9.0.dev20250731+cpu)
pdm.termui: Adding requirement setuptools; python_version >= "3.12"(from torch 2.9.0.dev20250731+cpu)
pdm.termui: Adding requirement sympy>=1.13.3(from torch 2.9.0.dev20250731+cpu)
pdm.termui: Adding requirement networkx>=2.5.1(from torch 2.9.0.dev20250731+cpu)
pdm.termui: Adding requirement jinja2(from torch 2.9.0.dev20250731+cpu)
pdm.termui: Adding requirement fsspec>=0.8.5(from torch 2.9.0.dev20250731+cpu)
pdm.termui: Adding new pin: torch 2.9.0.dev20250731+cpu
pdm.termui: ======== Starting round 2 ========
pdm.termui: Adding new pin: fsspec 2025.7.0
pdm.termui: ======== Starting round 3 ========
pdm.termui: Adding new pin: networkx 3.5
pdm.termui: ======== Starting round 4 ========
pdm.termui: Adding requirement mpmath<1.4,>=1.1.0(from sympy 1.14.0)
pdm.termui: Adding new pin: sympy 1.14.0
pdm.termui: ======== Starting round 5 ========
pdm.termui: Adding new pin: mpmath 1.3.0
pdm.termui: ======== Starting round 6 ========
pdm.termui: Adding new pin: typing-extensions 4.14.1
pdm.termui: ======== Starting round 7 ========
pdm.termui: Adding new pin: filelock 3.18.0
pdm.termui: ======== Starting round 8 ========
pdm.termui: Adding requirement MarkupSafe>=2.0(from jinja2 3.1.6)
pdm.termui: Adding new pin: jinja2 3.1.6
pdm.termui: ======== Starting round 9 ========
pdm.termui: Adding new pin: MarkupSafe 3.0.2
pdm.termui: ======== Starting round 10 ========
pdm.termui: Adding new pin: setuptools 80.9.0
pdm.termui: ======== Starting round 11 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: python None
pdm.termui: torch 2.9.0.dev20250731+cpu
pdm.termui: fsspec 2025.7.0
pdm.termui: networkx 3.5
pdm.termui: sympy 1.14.0
pdm.termui: mpmath 1.3.0
pdm.termui: typing-extensions 4.14.1
pdm.termui: filelock 3.18.0
pdm.termui: jinja2 3.1.6
pdm.termui: markupsafe 3.0.2
pdm.termui: setuptools 80.9.0
pdm.termui: Fetching hashes for torch@2.9.0.dev20250731+cpu
pdm.termui: Fetching hashes for typing-extensions@4.14.1
pdm.termui: Fetching hashes for setuptools@80.9.0
pdm.termui: Fetching hashes for mpmath@1.3.0
pdm.termui: Fetching hashes for fsspec@2025.7.0
pdm.termui: Fetching hashes for networkx@3.5
pdm.termui: Fetching hashes for sympy@1.14.0
pdm.termui: Fetching hashes for filelock@3.18.0
pdm.termui: Fetching hashes for jinja2@3.1.6
pdm.termui: Fetching hashes for MarkupSafe@3.0.2
Changes are written to pyproject.toml.
STATUS: Resolving packages from lockfile...
Synchronizing working set with resolved packages: 9 to add, 0 to update, 0 to remove
✖ Install torch 2.9.0.dev20250731+cpu failed
pdm.termui: Error occurs adding torch:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.13/3.13.6/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/installers/synchronizers.py", line 29, in install_candidate
self.manager.install(can)
~~~~~~~~~~~~~~~~~~~~^^^^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/installers/manager.py", line 33, in install
prepared.build(),
~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/models/candidates.py", line 406, in build
self._obtain(allow_all=False)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/models/candidates.py", line 447, in _obtain
raise CandidateNotFound(
f"No candidate is found for `{self.req.project_name}` that matches the environment or hashes"
)
pdm.exceptions.CandidateNotFound: No candidate is found for `torch` that matches the environment or hashes
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/2f/e0/014d5d9d7a4564cf1c40b5039bc882db69fd881111e03ab3657ac0b218e2/fsspec-2025.7.0-py3-none-any.whl
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/2f/e0/014d5d9d7a4564cf1c40b5039bc882db69fd881111e03ab3657ac0b218e2/fsspec-2025.7.0-py3-none-any.whl (from https://pypi.org/simple/fsspec/)>
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/4d/36/2a115987e2d8c300a974597416d9de88f2444426de9571f4b59b2cca3acc/filelock-3.18.0-py3-none-any.whl
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/4d/36/2a115987e2d8c300a974597416d9de88f2444426de9571f4b59b2cca3acc/filelock-3.18.0-py3-none-any.whl (from https://pypi.org/simple/filelock/)>
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl (from https://pypi.org/simple/sympy/)>
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/2b/6d/9409f3684d3335375d04e5f05744dfe7e9f120062c9857df4ab490a1031a/MarkupSafe-3.0.2-cp313-cp313-macosx_11_0_arm64.whl
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/2b/6d/9409f3684d3335375d04e5f05744dfe7e9f120062c9857df4ab490a1031a/MarkupSafe-3.0.2-cp313-cp313-macosx_11_0_arm64.whl (from https://pypi.org/simple/markupsafe/)>
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/eb/8d/776adee7bbf76365fdd7f2552710282c79a4ead5d2a46408c9043a2b70ba/networkx-3.5-py3-none-any.whl
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/eb/8d/776adee7bbf76365fdd7f2552710282c79a4ead5d2a46408c9043a2b70ba/networkx-3.5-py3-none-any.whl (from https://pypi.org/simple/networkx/)>
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl (from https://pypi.org/simple/mpmath/)>
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/b5/00/d631e67a838026495268c2f6884f3711a15a9a2a96cd244fdaea53b823fb/typing_extensions-4.14.1-py3-none-any.whl
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/b5/00/d631e67a838026495268c2f6884f3711a15a9a2a96cd244fdaea53b823fb/typing_extensions-4.14.1-py3-none-any.whl (from https://pypi.org/simple/typing-extensions/)>
pdm.termui: Using cached response for https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl
unearth.preparer: Using cached <Link https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl (from https://pypi.org/simple/jinja2/)>
✔ Install filelock 3.18.0 successful
✔ Install markupsafe 3.0.2 successful
✔ Install typing-extensions 4.14.1 successful
✔ Install fsspec 2025.7.0 successful
✔ Install jinja2 3.1.6 successful
✔ Install mpmath 1.3.0 successful
✔ Install networkx 3.5 successful
✔ Install sympy 1.14.0 successful
Retry failed jobs(2/2)
✖ Install torch 2.9.0.dev20250731+cpu failed
pdm.termui: Error occurs adding torch:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.13/3.13.6/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/installers/synchronizers.py", line 29, in install_candidate
self.manager.install(can)
~~~~~~~~~~~~~~~~~~~~^^^^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/installers/manager.py", line 33, in install
prepared.build(),
~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/models/candidates.py", line 406, in build
self._obtain(allow_all=False)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/models/candidates.py", line 447, in _obtain
raise CandidateNotFound(
f"No candidate is found for `{self.req.project_name}` that matches the environment or hashes"
)
pdm.exceptions.CandidateNotFound: No candidate is found for `torch` that matches the environment or hashes
✖ Some package operations failed.
Traceback (most recent call last):
File "/opt/homebrew/bin/pdm", line 7, in <module>
sys.exit(main())
~~~~^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/core.py", line 391, in main
return core.main(args or sys.argv[1:])
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/core.py", line 270, in main
raise cast(Exception, err).with_traceback(traceback) from None
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/core.py", line 265, in main
self.handle(project, options)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/core.py", line 195, in handle
command.handle(project, options)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/cli/commands/add.py", line 71, in handle
self.do_add(
~~~~~~~~~~~^
project,
^^^^^^^^
...<12 lines>...
hooks=HookManager(project, options.skip),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/cli/commands/add.py", line 177, in do_add
do_sync(
~~~~~~~^
project,
^^^^^^^^
...<6 lines>...
hooks=hooks,
^^^^^^^^^^^^
)
^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/cli/actions.py", line 311, in do_sync
synchronizer.synchronize()
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/pdm/2.25.6/libexec/lib/python3.13/site-packages/pdm/installers/synchronizers.py", line 227, in synchronize
raise InstallationError("Some package operations failed.")
pdm.exceptions.InstallationError: Some package operations failed.
Additional Context
That +cpu might come from other builds? I looked at https://download.pytorch.org/whl/nightly/cpu/torch and found a pattern:
- windows builds always have a +cpu identifier for the wheels,
- macos builds never have it,
- "manylinux" has both.
The torch version i want is present at the nightly source url as "torch-2.9.0.dev20250731-cp313-none-macosx_11_0_arm64".
If i run (in my original environment, where i have pip inside pdm) pdm run python -m pip debug --verbose | grep "cp313-none-macosx_11_0_arm64"
it does indeed give me cp313-none-macosx_11_0_arm64
back, so i should support it. (Right?)
Looking in the lockfile, though:
[[package]]
name = "torch"
version = "2.9.0.dev20250731+cpu"
requires_python = ">=3.9"
summary = "Tensors and Dynamic neural networks in Python with strong GPU acceleration"
groups = ["default"]
dependencies = [
"filelock",
"fsspec>=0.8.5",
"jinja2",
"networkx>=2.5.1",
"setuptools; python_version >= \"3.12\"",
"sympy>=1.13.3",
"typing-extensions>=4.10.0",
]
files = [
{file = "torch-2.9.0.dev20250731+cpu-cp313-cp313-linux_s390x.whl", hash = "sha256:57f6ca7da40c5fc762e43f9a58b98cbfdaf6df843ff27710ba7ff1f7bf5654a4"},
{file = "torch-2.9.0.dev20250731+cpu-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:d2ed4c0904b5f0864b855fbec8612e2c4c0d9d87609355119c4344f6d0410d59"},
{file = "torch-2.9.0.dev20250731+cpu-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:1917b38c907b231232ed8453edde9973e9280070444295c34a9815fba6371bc8"},
{file = "torch-2.9.0.dev20250731+cpu-cp313-cp313-win_amd64.whl", hash = "sha256:01a9fada705b463d03db943059a97be392649bc5a886c6ef15a05108519876b0"},
{file = "torch-2.9.0.dev20250731+cpu-cp313-cp313-win_arm64.whl", hash = "sha256:7e08ba1f63461383d95aea16ae1779a96cf4cef59e0a1429b1702ab6b5787ef3"},
{file = "torch-2.9.0.dev20250731+cpu-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:ee9e621a608b93660bbb8d071d2b33a334b9fe1e451e3eeb6912e94f58d942d6"},
{file = "torch-2.9.0.dev20250731+cpu-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:26af3d0831b2992fd621570808ecb9bffb406a348ac5487b535d065964f486d5"},
{file = "torch-2.9.0.dev20250731+cpu-cp313-cp313t-win_amd64.whl", hash = "sha256:d4dfac26541626c732e16c2d02032b0bbe1dcca08361dfed1c92006502b2dd3b"},
{file = "torch-2.9.0.dev20250731-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:41689883bcf05e64a59309b119774a7f92e814a88af0632b1cf7801f0532d6c0"},
{file = "torch-2.9.0.dev20250731-cp313-none-macosx_11_0_arm64.whl", hash = "sha256:142deb055683927a759e255ca3a2a4fc2829756fa63985c8ce71cfee0c27d018"},
]
It DOES list all the wheels, including the one i want, but the "version" key for torch has the +cpu added.
I am somewhat new to pdm/python usage advanced enough to warrant a package manager, so maybe there are some subtleities that i am missing.
Are you willing to submit a PR to fix this bug?
- Yes, I would like to submit a PR.