uv: Packages that fail to install under PEP 517 with build isolation

I don’t know that an issue is the right home for this, but I want to track the packages we know can’t be installed under PEP 517 when build isolation is enforced. In all cases, these packages also fail under pip install --use-pep517.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 8
  • Comments: 30 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I was having problems with packages flash-attn and auto-gptq, as they both require torch and setuptools to be installed before their build begins. I tried many things (tool.uv.dependency-metadata, following that page in the docs and playing around with pyproject.toml), but the only thing that worked and seems like a nice solution is using dependency groups.

So my final pyproject.toml looks similar to this

[project]
name = "project"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"

[dependency-groups]
build = [
    "setuptools>=75.8.0",
]
direct = [
    "torch>=2.5.1",
]
main = [
    "flash-attn>=2.7.3",
    "auto-gptq",
    # And all of your other dependencies
]

[tool.uv]
default-groups = ["build", "direct", "main"]
no-build-isolation-package = ["flash-attn", "auto-gptq"]

[tool.uv.sources]
auto-gptq = { git = "https://github.com/PanQiWei/AutoGPTQ.git" }

And then you can just do

Install build time dependencies (that are also used in project and should not be deleted after build, such as torch)

uv sync --no-group main 

Install the whole project (including all groups declared in default-groups)

uv sync

In my opinion, this is much better than declaring dependencies through optional-dependencies as suggested by docs, because they are actually not optional - someone using flash-attn will most likely use torch in the project (not just at the build phase) and the solution with groups won’t require to add --extra to every uv sync call and making sure that we retain the build dependencies

@charliermarsh @zanieb Perhaps we can update the documentation with this solution for build isolation?

Hope this helps someone

Yeah we should add a nice message for “missing wheel”. We have that for a few other failures. \cc @konstin

@amanmibra – The solution is generally to do something like:

uv venv
uv pip install torch setuptools
uv pip install --no-build-isolation ${package}

I.e., you create a virtual environment, “manually” install any build dependencies, then install the package in question with --no-build-isolation, so that it’s built in your virtual environment and has access to the installed dependencies.

@amanmibra – The solution is generally to do something like:

uv venv
uv pip install torch setuptools
uv pip install --no-build-isolation ${package}

I.e., you create a virtual environment, “manually” install any build dependencies, then install the package in question with --no-build-isolation, so that it’s built in your virtual environment and has access to the installed dependencies.

Is there a workaround for playsound? I had to use real pip instead of uv, which I’d like to avoid.

pip install cchardet==2.1.7 --use-pep517 does not work for me actually.

@baggiponte – I think you need to install wheel as well – that’s the trace you get when you’re missing wheel (e.g., uv pip install wheel).

That solves it - then I get weird C errors but definitely not uv-related.

Do you think uv should automatically recommend this kind of suggestions? A bit like the Rust compiler, that has wonderfully helpful error messages.

@baggiponte – I think you need to install wheel as well – that’s the trace you get when you’re missing wheel (e.g., uv pip install wheel).

chumpy

❯ pip install -e . --use-pep517
Obtaining file:///Users/crmarsh/workspace/puffin/chumpy
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      Traceback (most recent call last):
        File "<string>", line 9, in <module>
      ModuleNotFoundError: No module named 'pip'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/Users/crmarsh/.local/share/rtx/installs/python/3.12.1/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/crmarsh/.local/share/rtx/installs/python/3.12.1/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/crmarsh/.local/share/rtx/installs/python/3.12.1/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/pip-build-env-31a60nip/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 448, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/pip-build-env-31a60nip/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/pip-build-env-31a60nip/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/pip-build-env-31a60nip/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/pip-build-env-31a60nip/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 11, in <module>
      ModuleNotFoundError: No module named 'pip'
      [end of output]

This also causes ViTPose to fail.