astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.6k stars 466 forks source link

Failed installation of `pytorch` causes stale pyproject.toml #1234

Open kevinli1993 opened 2 months ago

kevinli1993 commented 2 months ago

Steps to Reproduce

  1. rye add pytorch This fails because the package is called "torch" -- there is an error message informing the user of this fact.

  2. rye add torch This fails due to the same error! Again there is an error message informing the user that the package is called torch.

The issue is that after step #1, pytorch is added to pyproject.toml and thereafter rye add will fail.

Expected Result

rye add pytorch should inform the user to install torch, and then rye add torch would succeed.

I am not sure what is a general solution to this problem --- but I think pytorch is a common enough use-case that it deserves special treatment even if a general solution is not applicable.

Actual Result

$ rye add pytorch
Added pytorch>=1.0.2 as regular dependency
Reusing already existing virtualenv
Generating production lockfile: .../requirements.lock
Generating dev lockfile: .../requirements-dev.lock
Installing dependencies
Resolved 2 packages in 1ms
   Built ... @ file://...
error: Failed to prepare distributions
  Caused by: Failed to fetch wheel: pytorch==1.0.2
  Caused by: Failed to build: `pytorch==1.0.2`
  Caused by: Build backend failed to build wheel through `build_wheel()` with exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "/Users/.../Library/Caches/uv/builds-v0/.tmpkGJsSr/lib/python3.12/site-packages/setuptools/build_meta.py", line 415, in build_wheel
    return self._build_with_temp_dir(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../Library/Caches/uv/builds-v0/.tmpkGJsSr/lib/python3.12/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
    self.run_setup()
  File "/Users/.../Library/Caches/uv/builds-v0/.tmpkGJsSr/lib/python3.12/site-packages/setuptools/build_meta.py", line 497, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/Users/.../Library/Caches/uv/builds-v0/.tmpkGJsSr/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
    exec(code, locals())
  File "<string>", line 15, in <module>
Exception: You tried to install "pytorch". The package named for PyTorch is "torch"
---
error: Installation of dependencies failed in venv at .../.venv. uv exited with status: exit status: 2
$ rye add torch
Added torch>=2.3.1 as regular dependency
Reusing already existing virtualenv
Generating production lockfile: .../requirements.lock
Generating dev lockfile: .../requirements-dev.lock
Installing dependencies
Resolved 11 packages in 3ms
   Built ... @ file://...
error: Failed to prepare distributions
  Caused by: Failed to fetch wheel: pytorch==1.0.2
  Caused by: Failed to build: `pytorch==1.0.2`
  Caused by: Build backend failed to build wheel through `build_wheel()` with exit status: 1
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "/Users/.../Library/Caches/uv/builds-v0/.tmpdmzLiI/lib/python3.12/site-packages/setuptools/build_meta.py", line 415, in build_wheel
    return self._build_with_temp_dir(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../Library/Caches/uv/builds-v0/.tmpdmzLiI/lib/python3.12/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
    self.run_setup()
  File "/Users/.../Library/Caches/uv/builds-v0/.tmpdmzLiI/lib/python3.12/site-packages/setuptools/build_meta.py", line 497, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/Users/.../Library/Caches/uv/builds-v0/.tmpdmzLiI/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
    exec(code, locals())
  File "<string>", line 15, in <module>
Exception: You tried to install "pytorch". The package named for PyTorch is "torch"
---
error: Installation of dependencies failed in venv at .../.venv. uv exited with status: exit status: 2

Version Info

rye 0.36.0
commit: 0.36.0 (12c024c7c 2024-07-07)
platform: macos (aarch64)
self-python: cpython@3.12.3
symlink support: true
uv enabled: true

Stacktrace

No response