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 pip compile does not include local package #6317

Closed
joellidin opened this issue Aug 21, 2024 · 6 comments
Closed

uv pip compile does not include local package #6317

joellidin opened this issue Aug 21, 2024 · 6 comments
Assignees
Labels
question Asking for clarification or support

Comments

@joellidin
Copy link

I am playing around a bit with uv and its features and got interested in the uv pip compile for platform agnostic lock files. I set up a very basic project with this pyproject.toml:

[project]
name = "test-uv"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12.4"
dependencies = [
    "ruff>=0.6.1",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

Later I ran uv pip compile --universal pyproject.toml -o requirements.lock which resulted in:

# This file was autogenerated by uv via the following command:
#    uv pip compile --universal pyproject.toml -o requirements.lock
ruff==0.6.1
    # via test-uv (pyproject.toml)

However, my local package is not included in this lockfile which is a bit weird to me. For example if I run rye sync instead I get the following:

# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
#   pre: false
#   features: []
#   all-features: false
#   with-sources: false
#   generate-hashes: false
#   universal: false

-e file:.
ruff==0.6.1
    # via test-uv

Moreover, when doing uv sync it actually installs my test-uv package in editable mode. But, I want to explore an option where you can just use normal pip install -r requirements.lock and not forced to use uv.

Am I missing something from the documentation or is this intended behavior?

I am on Ubuntu 22.04 with the latest version of uv 0.3.0.

@charliermarsh
Copy link
Member

So, if you pass a pyproject.toml, we lock the dependencies but not the project itself.

But if you pass a source tree, we'll lock the project.

In other words, you can put ./test-uv (or ./ if in the same directory) in a requirements.in, then run uv pip compile --universal requirements.in, and you should see the result you're looking for.

@charliermarsh
Copy link
Member

For example:

❯ uv pip compile req.in
Resolved 4 packages in 62ms
# This file was autogenerated by uv via the following command:
#    uv pip compile req.in
anyio==4.4.0
    # via black
./
    # via -r req.in
idna==3.7
    # via anyio
sniffio==1.3.1
    # via anyio

@charliermarsh charliermarsh added the question Asking for clarification or support label Aug 21, 2024
@joellidin
Copy link
Author

How can I lock dependencies with extras? I'm encountering the following error:

error: Requesting extras requires a `pyproject.toml`, `setup.cfg`, or `setup.py` file.

I'd prefer not to specify dependencies in multiple files.

rye sync --features test --universal works perfectly for me, creating both requirements.lock and requirements-dev.lock. I was just curious if this is possible with uv as well, but it seems like it doesn't work the same way.

@charliermarsh
Copy link
Member

Yeah totally -- you can add the following requirements.in to include the dev extra:

.[dev]

Is the main issue with uv sync just that you don't want the project to be installed as editable?

@joellidin
Copy link
Author

joellidin commented Aug 21, 2024

Okay! I understand better how it works then. I would want to have a lock file that is not only usable with uv. If I have the output from the compile I get a file I can install with the normal pip? For example if someone is not using uv. If that makes sense.

@charliermarsh
Copy link
Member

Makes sense. We will probably add support for exporting uv.lock to requirements.txt, which could be useful for you in the future.

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

No branches or pull requests

2 participants