-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Request for uv.lock
to support different index urls across different developer machines and CI environments
#6349
Comments
I've tested it further and confirmed that With that that, I think this is a request to enable not writing the index url into the lock files via and to be more specific, this is about
fields |
uv.lock
, custom index urls, and its usage by the different commandsuv.lock
to not include the index url
I discovered Now, coming to the topic, I think this becomes important given the ability to setup Right now if you have a user-level config pointing at a package repository that acts as proxy to PyPI (that might add private pacakges on top) you will record that url in any lock file you generate. So if you want to work on some public project where
Option 2 might not seem that bad, but then that defies the purpose of being able to define user-level or system-level configs. Plus, it might not be the ideal setup ideal to take advantage of |
Just adding a couple more comments
This determinism, can actually lead to a simpler handling of this, where I tested with
All of this, makes me wonder if there's some solution to cases like mine, along the lines of
|
What follows is a +1 comment you should all ignore, but I'm writing it to include some keywords in this issue so other people who run into this can find it more easily than I just did (took me a while): Having the same issue because I fetch all my PyPI packages through a local devpi(keyword 1) installation, so all |
The more comments this gets, the more I think there needs to be an option for the lock file to not include any index information. This way, all those use cases that use local proxies, different on developer machines from those in CI environments, and the likelihood that those different proxies having different conventions for their asset (wheel/sdist) URLs, that a general simple solution to exclude those index/asset URLs would be very useful and enable them to adopt |
We could really also use this to be able to have lock-files without disclosing internal urls. |
I'm not sure that a lockfile without URLs is a good idea. One of the goals of the lockfile is to be hermetic: you can install from just the lockfile without making any queries or relying on any external sources. If you're going to omit source information like that, why not just export to |
@charliermarsh That may very well work for our requirements but it looks like the uv lockfile is richer (all the extras are declared). Otherwise it would just be a convenience to not have someone outside (that don't have access to internal dns-names) being able to use the lock-file without having to regenerate it from the requirements.txt (pardon me if I've missed a quicker way to handle that). Basically my thought was that the hashes should be enough to guarantee that it's indeed the same packages that are being installed even if the urll has to be found again. That said if it doesn't feel like the right way to do it and the recommended way is to manage that with requirements.txt exports we'll try that and raise a more specific issue or discussion if a showstopper or question regarding that comes up. (feel free to edit/move/hide post if it derails original thread) |
At the moment, I'm actually using The main thing I don't like about it, is keeping the lockfile up to date with So, I'd say that's not on par with the experience of something like The other thing I like about Omitting the URLs is one potential solution - me thinking out loud. In the case of my proxy, given that the @task
def update_lock_index_url(ctx):
"""
Workaround for `uv lock` writing the index url to the lock file.
Update `source` and `url` fields with values based on `UV_INDEX_URL` environment variable.
"""
with open("uv.lock", "r+") as file:
contents = file.read()
pattern = r"http://127.0.0.1:\d+/[^/]+/[^/]+/[^/]+/pypi/simple"
replacement = os.environ.get("UV_INDEX_URL", "NO_INDEX_OVERRIDE_SET")
new_contents = re.sub(pattern, replacement, contents)
file.seek(0)
file.truncate()
file.write(new_contents) Downside for this, is that any dev on my team will end up having modifying
I thought the simplest of all of the above would be this whole omission of URLs from the file tbh. |
As far as I can see, poetry records the file name and the hash, which should be enough to ensure that you are getting exactly the same files without relying on external sources. On the other hand, by including the URLs you are coupling the lock file with the specific path of the package repository that you are using. And while this might remove the need of interacting with the package index, it also seems that adding a proxy package repository on the working environment should be transparent to the dependency specification of my project. |
I consider it fairly critical that the lockfile includes the URLs directly and I suspect that the lockfile standard (should it be accepted) will do the same. We do have a plan to support these use-cases though. After #7481, we'll add something like: [[tool.uv.index]]
name = "private"
url = "https://private.org/simple"
proxy = "http://<omitted>/pypi/simple" So you can set the index URL (which will appear in the lockfile) and then the proxy separately. You'll also be able to set the proxy as an environment variable, like |
Hey @charliermarsh, Just to make sure I understand this, and try to assess whether it'd work.
|
|
Great... then I look forwards to that :) |
Sorry! Actually, reading about the proposed standard I found this comment that properly describes what was my concern, and then the answer to it. The point that I was missing is in fact addressed in the PEP draft:
So yeah, I understood that URLs would be assumed to work, and that didn't seem a great idea. I see that's not the case, so nothing to object! What got me confused is that apparently Thanks for the answers! |
I saw that the revamped index support got released in 0.4.23. Is there any separate issues to track the proxy/env variables support, or is this issue itself that? |
I think it’s ok to track it here. |
uv.lock
to not include the index urluv.lock
to not include the index url
uv.lock
to not include the index urluv.lock
to support different index urls across different developer machines and CI environments
May I ask what's the current status of the issue? What aspects remain unclear? Currently I use a workaround (Run |
I don't know if anything is unclear, it's more that it hasn't been prioritized. |
Any updates on this? This is critical for us to ship |
Hello team,
Many thanks for the awesome work you're doing, and the countless amounts of time you've saved everyone using
uv
(andruff
).I've seen the recent blog post about 0.3.0 and the accompanying documentation update, and from playing a bit to test commands like
uv lock
anduv sync
, I actually have a question aboutuv.lock
.I've described the setup I use in #1710 (a proxy, and using
invoke
, etc.). That setup means that on different team member's machine's, each is likely to have a differentINDEX_URL
and even the CI/CD system we use would have a different one.I've generated the
uv.lock
file usingUV_INDEX_URL=... uv lock
, and the main thing I noticed is that the index url is included in the lock file e.g.I have not tried using that file across our different machines yet, but I suspect it's going to cause problems so I wanted to confirm with you folks
UV_INDEX_URL
?The text was updated successfully, but these errors were encountered: