-
Notifications
You must be signed in to change notification settings - Fork 863
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
Modifying tool.uv.sources
between production and development
#7945
Comments
Are you developing on a different platform than your Docker container? Like developing on macOS but using Linux for Docker? |
No, all in Ubuntu. I have a script that changes dependencies when I'm on one branch or another, for example: What I want to know is if there is a way to avoid using the script I have, and for example, reading an environment variable, and thus using a group of dependencies (Git) over others (Local) dev branch:
run script (and change to main):
|
You might be able to do this with [project]
name = "quickbio"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"data-management-tools @ git+ GITPATH",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.uv.sources]
data-management-tools = { path = "../../data_management_tools", editable = true } Then |
@charliermarsh hi!
|
\cc @konstin -- do you think we should allow this? I kind of do. |
For example. quickbio_book depends on dev_tools but right now the limitation I have is that if I wanted to test it in docker, I would have to manually change all the local paths to the github repositories, and once tested, if I wanted to change something I would have to change it back to the local paths and then (again) change it to github to test it again in docker (so, for each of my libraries). I do all of this with a script, which is responsible for making all the changes and even uploading them to github, but I was wondering if there is a way for UV to take care of it. Maybe by creating a group where the libraries are specified in editable mode (dev) and in production mode, or by allowing you to read an environment variable with which UV allows you to use one over the other (like the marker platform).
If I set the environment variable "custom_env_var" == "dev" it would use the local. Of course, this is thought from my point of view in the development of my application (I am not a programmer as such, I am a Biologist who learned to program, maybe I am missing some more efficient way of doing it according to good practices) but it is what I have seen that has limited me and that perhaps UV can handle it. Thank you for your time :) |
From a technical perspective, yes we can support this.
I'm trying to understand how the path/git workflow works in practice, specifically keeping things in sync. E.g., how are you making sure that quickbio and data-management-tools are in sync when deploying? Let's say you add a function |
First I will explain the way I do it currently, which is a bit complicated since there are several steps (although I have it automated and it works well for me) What I do is.
I have to create another branch called "prod" where I merge the "dev" branch to change the dependency paths here
So far, I have two branches, "dev" and "prod" both, with the same code, the only difference is the path of each dependency. In docker, I use the "prod" branch so that the dependencies are installed from github using the gitpath Now, we added a new feature
So, in docker, the dependencies would be installed from github since the gitpath is still the same (and is updated with the latest commit) Now, how do I see that this is solved? I specify the paths for the same dependency
Note: The branch should be specified to avoid conflicts By default, the custom_env_var would be "dev", but in docker, if I wanted to use the git path, I would set custom_env_var = "prod" |
I also tried to do this in an example for someone today [project]
name = "example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"httpx @ git+https://github.com/encode/httpx",
]
[tool.uv.sources]
httpx = { path = "../../httpx", editable = true } There was a discussion in Discord in which someone wants to use a workspace source during development but a built wheel path in production. We don't have a dev / prod toggle, you'd have to hack |
I second the need for this functionality. Having some libraries as editable during development and correctly packaging them from git sources for CI/CD pipelines would be great. Right now there's no solution for this. |
tool.uv.sources
between production and development
Another example here would be: using a |
It doesn't solve the broader "prod vs. dev" problem, but I think we should allow conflicting URLs between |
…urces` (#9718) ## Summary This PR allows users to specify a source both in `project.dependencies` ("production") and `tool.uv.sources` ("development"). It's not intended as a holistic fix for "production" vs. "development" dependencies, but in some cases this is good enough with `--no-sources`, and I don't see a great reason for enforcing it right now. Closes: #9682 Ref: #7945 (but I'll leave this open?)
Hi!
this is my pyproject.toml
There is any way to use
with git urls at the same time as local path.
What I mean is that I want to specify both paths, but for example when I'm working locally I use ../path, but when I use docker I use the git paths.
Is there a way to do that?
The text was updated successfully, but these errors were encountered: