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

mono-repo with multiple linked modules #189

Open
wabiloo opened this issue Aug 15, 2024 · 5 comments
Open

mono-repo with multiple linked modules #189

wabiloo opened this issue Aug 15, 2024 · 5 comments
Labels
blocked Waiting on a dependency

Comments

@wabiloo
Copy link

wabiloo commented Aug 15, 2024

Hi,

I have a mono repo "mono-repo" which contains 2 subfolders "cli" and "sdk".
Both are intrinsically linked (the cli uses the sdk) and therefore I decided to have a common version number (hence the mono-repo, using git tag versions)

However they can be built and deployed independently.

The pyproject.toml for the cli is as follows:

[tool.poetry]
name = "my-cli"
version = "0.0.0"
description = "A command line interface to..."
readme = "README.md"
packages = [{ include = "my-cli" }]

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"

[tool.poetry-dynamic-versioning.substitution]
files = ["*/__init__.py", "*/__version__.py", "*/_version.py"]

[tool.poetry.dependencies]
my-sdk = "0.0.0"
python = "^3.10"
click = "^8.1.3"

[tool.poetry.scripts]
cli = "my_cli.app:safe_entry_point"

[tool.poetry.group.dev.dependencies]
my-sdk = { path = "../my-sdk", develop = true }
pytest = "^7.2.2"
black = "^23.1.0"
isort = "^5.12.0"
flake8 = "^6.0.0"

[build-system]
requires = ["poetry-core", "poetry-dynamic-versioning"]
build-backend = "poetry_dynamic_versioning.backend"

When I try to build it fails due to the first dependency set to 0.0.0 (which does not exist).
Is there a way to have this updated as well as the tool.poetry.version?

@mtkennerly
Copy link
Owner

Hi! I just tested this out, and I'm not sure there's a good way to make it work :/ There are a few problems:

I tried doing this, but it doesn't work, because Poetry has already analyzed the versions before this substitution occurs:

[[tool.poetry-dynamic-versioning.substitution.folders]]
path = "."
files = ["pyproject.toml"]
patterns = ["(my-sdk = \")0.0.0(\")"]

It should work if you relax the dependency constraint, but that depends on what backwards compatibility guarantees you're comfortable making:

[tool.poetry.dependencies]
my-sdk = ">= 1.0.0, < 2.0.0"

Maybe the plugin could directly modify the version constraints in memory after Poetry has already parsed them, but I haven't explored how complicated/feasible that would be.

@wabiloo
Copy link
Author

wabiloo commented Aug 17, 2024 via email

@mtkennerly
Copy link
Owner

Unfortunately, at the moment, I don't think you can use this plugin with your setup 😞

@vs-artian
Copy link

I'm trying a very similar setup but I'm also using another plugin https://github.com/gerbenoostra/poetry-plugin-mono-repo-deps/ for a monorepo with multiple python projects that depend on each other. It rewrites the version # of path depenencies prior to build. I'm still working through other issues in my setup but I wonder if it might help to use both.

@vs-artian
Copy link

Actually I think I have similar problem. Unfortunately it's writing out the real version to poetry.lock file . So it would be unrealistic to update it every time. If I don't specify version depenency, it gets stuck on the older one.

@mtkennerly mtkennerly added the blocked Waiting on a dependency label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Waiting on a dependency
Projects
None yet
Development

No branches or pull requests

3 participants