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

How to use different index url with pyproject.toml when using uv pip compile #4173

Closed
SamComber opened this issue Jun 9, 2024 · 5 comments
Closed
Assignees
Labels
question Asking for clarification or support

Comments

@SamComber
Copy link

SamComber commented Jun 9, 2024

I'm trying to convert my Pipfile to a pyproject.toml, so that I can run:

uv pip compile pyproject.toml --generate-hashes -o requirements-lock.txt

The issue is I have a package, torch, that uses a different index in my Pipfile

[dev-packages]
torch = { index = "pytorch_cpu"}

[[source]]
url = "https://download.pytorch.org/whl/cpu"
verify_ssl = true
name = "pytorch_cpu"

How can I reproduce what my Pipfile is achieving here, and specify a different index url to install torch here? Ideally I'd like to keep this all contained within pyproject.toml - is this possible?

P.S. loving the blazing speed of uv!

@charliermarsh
Copy link
Member

charliermarsh commented Jun 9, 2024

You should be able to do:

[tool.uv.pip]
extra-index-url = ["https://download.pytorch.org/whl/cpu"]

...in your pyproject.toml. We don't support assigning a package to a specific index yet but it's on the roadmap (#171).

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

If you need Torch to be an optional dependency, we don't yet support development dependencies like that though it's coming soon (and already supported in preview mode but not everywhere you'd need it). So you would need to use extras, like:

[project.optional-dependencies]
dev = ["torch"]

And then uv pip compile pyproject.toml --extra dev --generate-hashes -o requirements-lock.txt.

@SamComber
Copy link
Author

SamComber commented Jun 10, 2024

Thank you @charliermarsh, will give this a whirl.

One last blocker if you would care to help me out..

Would you know how to install your project in editable mode? Is this possible?

[dev-packages]
my_project = {editable = true, path = "."}

I've been trying

[dev-packages]
"my_project@file:///Users/sam.comber/Documents/kraken/my_project"

uv pip compile pyproject.toml --extra dev --generate-hashes -o requirements-lock.txt

But I can't see the project as editable inside the requirements-lock.txt?

uv pip install --compile-bytecode -r requirements.lock -e . works for me, but i need my project inside the lock file, otherwise uv pip sync requirements.lock will remove it and ill need to reinstall each time. Is this possible?

@patrick-kidger
Copy link

patrick-kidger commented Jun 12, 2024

I can answer this one. You want printf '-e .' | uv pip sync - requirements.lock.

@charliermarsh
Copy link
Member

Thanks @patrick-kidger :)

@charliermarsh charliermarsh self-assigned this Jun 24, 2024
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

3 participants