-
Notifications
You must be signed in to change notification settings - Fork 1.5k
How to create a lock file from installed packages (or from requirements.txt file) #13300
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
Comments
In practice, for the first option I would install the packages based on the rm -rf .venv
uv venv
uv pip install -r requirements.txt
uv lock --something? |
You can use |
That is not what I'm going for - I already have the dependencies I want to keep available as |
You can pass the
|
Thanks, @charliermarsh, that is an interesting approach but gets me forward, thanks! # Create a backup of pyproject.toml
cp pyproject.toml pyproject.backup
# Set the pinned requirements to be the constraints in pyproject.toml
uv add -r requirements.txt -c requirements.txt
# uv.lock is now created
# Now that we have a lock file, let's revert the original config file
mv pyproject.backup pyproject.toml |
This is also covered in #12382, to an extent. |
That will be a useful part of the docs, @zanieb, thanks! |
Question
When I'm creating a lock file with
uv lock
, it will always lock the newest available versions. Is it possible to create a lock file which matches the versions installed in the venv? I have not been able to find a combination of options which would achieve this.Alternatively, can I create a lock file from requirements.txt file?
I would need this for the process of migrating to uv: I would like to keep the pinned versions the same as before to keep the change minimal.
Platform
No response
Version
No response
The text was updated successfully, but these errors were encountered: