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

FR: add --check-only flag to pip sync command #3021

Open
ofek opened this issue Apr 14, 2024 · 9 comments
Open

FR: add --check-only flag to pip sync command #3021

ofek opened this issue Apr 14, 2024 · 9 comments
Labels
enhancement New feature or improvement to existing functionality

Comments

@ofek
Copy link
Contributor

ofek commented Apr 14, 2024

We have a need to check whether environments are synchronized without performing action so it would be nice to have such a flag that would produce JSON output like:

{
    "in-sync": false
}
@charliermarsh
Copy link
Member

Can we resolve this by adding --dry-run to uv pip sync (which already exists on uv pip install)?

@ofek
Copy link
Contributor Author

ofek commented Apr 15, 2024

Probably! What would the output be if everything is synchronized already?

@charliermarsh
Copy link
Member

Right now it ends with "Would make no changes" but we could consider using separate exit codes.

@ofek
Copy link
Contributor Author

ofek commented Apr 15, 2024

I think it would be preferable to have an additional --json flag to not be reliant upon exit codes.

@charliermarsh
Copy link
Member

Can consider it but will take a lot more time and work given that it's committing to a public API that we'll need to build and maintain in perpetuity.

@ofek
Copy link
Contributor Author

ofek commented Apr 15, 2024

Then I'm definitely fine with the quicker solution 🙂

@charliermarsh
Copy link
Member

I do think we want JSON output: #411. At least for resolution. But we haven't figured it out yet :) \cc @konstin

@charliermarsh charliermarsh added the enhancement New feature or improvement to existing functionality label Apr 20, 2024
@Rogdham
Copy link

Rogdham commented May 3, 2024

This feature seems related to the recurring usecase of the CI checking that the committed requirements.in and requirements.txt files match each other. In that case, we are only interested in the exit code (the output does not matter much). This would be similar to the --check parameter of ruff format.

A workaround looks like the following:

uv pip compile requirements.in -o requirements.txt && git diff --exit-code requirements.txt

For reference, the feature has been asked for pip-tools in jazzband/pip-tools#882, which might provide more context.

@FlorianKoegler
Copy link

Right now it ends with "Would make no changes" but we could consider using separate exit codes.

Hi,
i found this issue, because I'm trying to use uv pip sync --dry-run to test if a virtual environment matches it's lock file.

It would be great if it would have a non-zero return code, in case there are deviations.
This would make parsing much more reliable than evaluating the output message. :)

For comparison, pip-sync --dry-run also returns an non-zero return code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants