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

Feature: have 'uv export' support --only-deps #6960

Closed
RomainBrault opened this issue Sep 3, 2024 · 6 comments · Fixed by #7110
Closed

Feature: have 'uv export' support --only-deps #6960

RomainBrault opened this issue Sep 3, 2024 · 6 comments · Fixed by #7110
Assignees
Labels
question Asking for clarification or support

Comments

@RomainBrault
Copy link

RomainBrault commented Sep 3, 2024

Have uv export support --only-deps

This would be useful to support building requirements.txt from uv.lock without including build dependencies.

Example: in a Dockerfile with a custom hatch build the following fails:

COPY pyproject.toml ./
RUN set -ex && \
    ${UV_BIN}/uv export \
        --format="requirements-txt" \
        --all-extras \
        --no-dev

So I must do

COPY pyproject.toml hatch.toml hatch_build.py ./
RUN set -ex && \
    ${UV_BIN}/uv export \
        --format="requirements-txt" \
        --all-extras \
        --no-dev

It would be nice to be able to have

COPY pyproject.toml ./
RUN set -ex && \
    ${UV_BIN}/uv export \
        --format="requirements-txt" \
        --all-extras \
        --no-dev \
        --only-deps

working.

This would also enable doing

uv pip install --require-hashes

without uv complaining about

error: In `--require-hashes` mode, all requirement must have a hash, but none were provided for: file:///src
@RomainBrault RomainBrault changed the title Feature: have 'uv export' support --no-install-project and --no-install-workspace Feature: have 'uv export' support --no-install-project Sep 3, 2024
@RomainBrault
Copy link
Author

RomainBrault commented Sep 3, 2024

Related: #6573

If I was unclear, I think it would be nice to convert the uv.lock to a requirements.txt trough uv export with only the dependencies (not the project). I guess I would be really useful if in that case uv would ignore the project's build configuration (otherwise I could just "sed" out the line corresponding to the project in the requirements.txt).

E.g. in my example the project's build use hatch-vcs (with dynamic field + a custom build script) that are not useful to convert the dependencies in uv.lock to requirements.txt.

@RomainBrault RomainBrault changed the title Feature: have 'uv export' support --no-install-project Feature: have 'uv export' support --only-deps Sep 3, 2024
@charliermarsh
Copy link
Member

Do you need --frozen for these commands, so that you don't resolve?

@charliermarsh charliermarsh added the question Asking for clarification or support label Sep 4, 2024
@charliermarsh
Copy link
Member

In other words: if you add --frozen to the above examples, do the commands execute without error?

@RomainBrault
Copy link
Author

RomainBrault commented Sep 4, 2024

Thanks, this solve the build problem; with --frozen I am able to generate the requirements.txt from the uv.lock.

However I am unable to pip install --require-hashes due to the line -e . in the requirements.txt.

So the final solution is to use --frozen as suggested and to remove the line in a post-processing step.

A flag to avoid this line would still be useful as well as a flag to save the result to a file. (This would avoid post-processing and stream redirections).

I don't mind closing the issue now.

@RomainBrault
Copy link
Author

RomainBrault commented Sep 4, 2024

Related: #6995 #7058

@RomainBrault
Copy link
Author

I think the feature could be seen another way:

Be able to do uv pip compile uv.lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants