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

uv does not install dynamic build dependencies before preparing metadata #1582

Closed
sbidoul opened this issue Feb 17, 2024 · 7 comments · Fixed by #1590
Closed

uv does not install dynamic build dependencies before preparing metadata #1582

sbidoul opened this issue Feb 17, 2024 · 7 comments · Fixed by #1590
Assignees
Labels
bug Something isn't working

Comments

@sbidoul
Copy link

sbidoul commented Feb 17, 2024

It seems get_requires_for_build_wheel is not invoked before prepare_metadata_for_build_wheel.

This means dynamic build dependencies are not installed before preparing metadata.

Here is a reproducer.

uv pip install -v --no-deps "odoo-addon-mis_builder @ git+https://github.com/OCA/mis-builder@16.0#subdirectory=setup/mis_builder"

This fails about an invalid Name metadata, where it should succeed. This is most likely because the dynamic build dependency setuptools-odoo which is declared in setup.py has not been installed in the build environment.

With setuptools, setup_requires entries are returned by get_requires_for_build_wheel and must be installed before preparing metadata.

@halflings
Copy link

This is maybe related to an issue I'm encountering (trying to install the LLM finetuning lib axolotl):

(.venv) ➜  axolotl-finetuning uv pip install "axolotl[flash-attn,deepspeed] @ git+https://github.com/OpenAccess-AI-Collective/axolotl"
 Updated https://github.com/OpenAccess-AI-Collective/axolotl (5a5d474)
 Updated https://github.com/huggingface/peft.git (8db74d4)                      error: Failed to download and build: flash-attn==2.5.0
  Caused by: Failed to build: flash-attn==2.5.0
  Caused by: Build backend failed to determine metadata through `prepare_metadata_for_build_wheel`:
--- stdout:

--- stderr:
Traceback (most recent call last):
  File "<string>", line 10, in <module>
  File "/tmp/.tmpSjTNqD/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 366, in prepare_metadata_for_build_wheel
    self.run_setup()
  File "/tmp/.tmpSjTNqD/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 480, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/tmp/.tmpSjTNqD/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
    exec(code, locals())
  File "<string>", line 9, in <module>
ModuleNotFoundError: No module named 'packaging'
---

Running "uv pip install packaging" separately doesn't resolve this.

@charliermarsh
Copy link
Member

@sbidoul - Thank you for this. I thought it was safe to skip get_requires_for_build_wheel when using the default backend but clearly not! Will fix.

@charliermarsh charliermarsh added the bug Something isn't working label Feb 17, 2024
@charliermarsh charliermarsh self-assigned this Feb 17, 2024
@stillmatic
Copy link

@charliermarsh
Copy link
Member

I think the solutions may be different. mis_builder I can fix trivially by ensuring we call get_requires_for_build_wheel in all cases. But flash-attn is still failing...

python -m build . also fails on flash-attn, which makes me think it's a problem with the package's declared metadata. And in fact, it looks like their setup script requires packaging (https://github.com/Dao-AILab/flash-attention/blob/5cdabc2809095b98c311283125c05d222500c8ff/setup.py#L9C6-L9C15), but that's not going to be available at the time the script runs (since the script itself declares it as a dependency at the very bottom).

charliermarsh added a commit that referenced this issue Feb 17, 2024
## Summary

I want to revisit this as I think it's still skippable in some cases,
but for now, let's be more conservative.

Closes #1582.

## Test Plan

Cloned
`https://github.com/OCA/mis-builder/blob/3aea4235697bac0f74d446e610e2b934b0994e06/setup/mis_builder/setup.py#L4`,
and ran `cargo run pip install -e mis_builder`.
@ilkersigirci
Copy link

ilkersigirci commented Feb 17, 2024

The official way to install flash-attn is using pip install flash-attn --no-build-isolation. Will there be similar feature for uv? I can't use the current state of uv for my ML projects, because it doesn't allow me to install flash-attn

@zanieb
Copy link
Member

zanieb commented Feb 18, 2024

We might want to track that use-case in a separate issue.

@Taytay
Copy link

Taytay commented Feb 19, 2024

@zanieb : Done here: #1715

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

Successfully merging a pull request may close this issue.

7 participants