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

Transitive workspace dependencies with dynamic package versioning #8802

Closed
ajohnson5 opened this issue Nov 4, 2024 · 3 comments
Closed

Transitive workspace dependencies with dynamic package versioning #8802

ajohnson5 opened this issue Nov 4, 2024 · 3 comments

Comments

@ajohnson5
Copy link

UV Version

0.4.29

Issue

Currently I am experiencing an issue with transitive dependencies in workspaces when using a dynamic version. I have created a minimal example with a fork of https://github.com/konstin/workspace-git-path-dep-test. The fork is here https://github.com/ajohnson5/workspace-git-path-dep-test/tree/dynamic-version.

I am trying to import two modules (which are workspaces), one of which depends on the other, similar to packages c and d (in the above) into another repository.

Reproduction

In the above fork there are two branches:

  1. static-version: Same as the main branch with each package having an explicit version number defined in their pyproject.toml files such as version="0.1.0".
  2. dynamic-version: Each package has a dynamic version, similar to below with a __about__.py file in the root of the project. In this file we have __version__=="1.0.0"
[project]
name = "d"
dynamic=["version"]

[tool.hatch.version]
path = "../../__about__.py"

Now in a different project, I am trying to import both packages c and d. The pyproject.toml is shown below:

[project]
name = "example-project"
version = "0.1.0"
requires-python=">=3.11, <=3.12"

dependencies = [
  "c",
  "d",
]

[tool.uv.sources]
c = { git = "https://github.com/ajohnson5/workspace-git-path-dep-test.git", subdirectory="packages/c", branch="dynamic-version"}
d = { git = "https://github.com/ajohnson5/workspace-git-path-dep-test.git", subdirectory="packages/d", branch="dynamic-version"}


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

[tool.hatch.build.targets.wheel]
packages = ["src/example_project"]

Note that between any uv commands I am doing a complete fresh run, uv cache clean, rm -rf .venv and removing the uv lock.
If I use the dynamic-version branch I get the following error when running uv sync or uv lock

error: Requirements contain conflicting URLs for package `d`:
- file:///Users/a-user/.cache/uv/git-v0/checkouts/c63672d311baa9b4/d116d88/packages/d
- git+https://github.com/ajohnson5/workspace-git-path-dep-test.git@dynamic-version#subdirectory=packages/d

After if I change the branch to static-version in the above toml then the install works completely fine.

Related Issues

#8665

@charliermarsh
Copy link
Member

\cc @konstin

@konstin
Copy link
Member

konstin commented Nov 5, 2024

We currently don't support dynamic versions in workspaces. They have a number of disadvantages, e.g., we have to run python code each time we want to determine the version of a package in the workspace, instead of just reading pyproject.toml, and we can't see when the version changes (there's no way for uv to tell that's it's about.py that changes the version). Instead of defining the version in about.py and having it dynamic in pyproject.toml, I recommend setting the version in pyproject.toml and reading it in about.py with importlib.metadata.version.

@ajohnson5
Copy link
Author

Makes sense, thanks for getting back to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants