xformers
xformers copied to clipboard
importing torch in setup.py will cause arcane exceptions when xformers is added without versions
https://github.com/facebookresearch/xformers/blame/0ec6aa244f3fbf1a077782bbf3ac8e6f2e4d1d16/setup.py#L23C5-L23C5
setup logs:
INFO: pip is looking at multiple versions of xformers to determine which version is compatible with other requirements. This could take a while.
Collecting xformers (from sd-scripts@ file://C:/Users/bberman/Documents/sd-scripts->artworkspace==0.1)
Downloading xformers-0.0.22.post4-cp311-cp311-win_amd64.whl (97.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 MB 11.9 MB/s eta 0:00:00
Using cached xformers-0.0.22-cp311-cp311-win_amd64.whl (97.6 MB)
Downloading xformers-0.0.21-cp311-cp311-win_amd64.whl (97.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.5/97.5 MB 18.7 MB/s eta 0:00:00
Using cached xformers-0.0.20-cp311-cp311-win_amd64.whl (97.6 MB)
Collecting pyre-extensions==0.0.29 (from xformers->sd-scripts@ file://C:/Users/bberman/Documents/sd-scripts->artworkspace==0.1)
Using cached pyre_extensions-0.0.29-py3-none-any.whl (12 kB)
Collecting xformers (from sd-scripts@ file://C:/Users/bberman/Documents/sd-scripts->artworkspace==0.1)
Downloading xformers-0.0.16.tar.gz (7.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.3/7.3 MB 17.2 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
Traceback (most recent call last):
File "C:\Users\bberman\Documents\Art-Workspace\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\bberman\Documents\Art-Workspace\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bberman\Documents\Art-Workspace\venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bberman\AppData\Local\Temp\1\pip-build-env-b9gnoz9z\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bberman\AppData\Local\Temp\1\pip-build-env-b9gnoz9z\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "C:\Users\bberman\AppData\Local\Temp\1\pip-build-env-b9gnoz9z\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
File "C:\Users\bberman\AppData\Local\Temp\1\pip-build-env-b9gnoz9z\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 23, in <module>
ModuleNotFoundError: No module named 'torch'
[end of output]
Observe setup.py
imports torch
, but my pyproject.toml
has:
[build-system]
requires = ["setuptools", "wheel", "pip"]
build-backend = "setuptools.build_meta"
aka requires does not contain torch, so your setup.py cannot import it. You will have to do something else. I understand the import torch
line has been around since this package was authored, but it looks like pip
has changed in the meantime to start this isolation process. There will be a lot of inertia on your team around this code. Nonetheless, fixing it will probably resolve a lot of issues people are reporting.