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

Transfering requirements from pyproject.toml to script drops index #11053

Open
BenediktMaag opened this issue Jan 29, 2025 · 1 comment
Open
Labels
needs-design Needs discussion, investigation, or design

Comments

@BenediktMaag
Copy link

BenediktMaag commented Jan 29, 2025

Summary

Use case: I have a folder where i write and keep my script relevant to a certain project / dependency setup which references a local index. I want to share a script with a colleague for him to reproduce but I want to share only one necessary file and not a full folder with all the other files he doesnt need.

Setup of the folder:

uv init
cd
uv add --index internal=

Before sending him the script, I need to copy the dependencies into the script. There are two possible ways i would solve this, both not working as expected:

❯ : uv add --script .py -r pyproject.toml
error: Adding requirements from a pyproject.toml is not supported in uv add

❯ : uv export | uv add --script .py -r -
Resolved 3 packages in 194ms
Updated <script-name>.py

uv export creates an requirements-txt format which does not include the index nor the linking of the dependency to this index.
When running the script with uv run without it being located in this project folder it will not be able to resolve the dependency as it is missing the index information.

Platform

Windows 11 x86_64

Version

uv 0.5.24 (42fae92 2025-01-23)

Python version

Python 3.12.5

@BenediktMaag BenediktMaag added the bug Something isn't working label Jan 29, 2025
@charliermarsh charliermarsh added needs-design Needs discussion, investigation, or design and removed bug Something isn't working labels Jan 29, 2025
@charliermarsh
Copy link
Member

It's intentional that uv export drops the index information. requirements.txt is much more restrictive, and we can't represent things like explicit or assigned indexes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-design Needs discussion, investigation, or design
Projects
None yet
Development

No branches or pull requests

2 participants