Imagine we possess an individual, private Git repository that's included in the pyproject.toml file as a dependency in a second repo, managed by python-poetry. The development branch of this repository should be pulled by default, except when installing dependencies specifically for the main (master) branch. In that situation, Poetry should resolve the main branch of the dependency instead.
This is needed during the deployment to both staging and production environments. If the present repository is pushed to the staging server, both the 'develop' branch of this repository and the corresponding 'develop' branch of the dependent Git repository should be deployed. Conversely, when deploying to the production server, the 'main' branch of the current repository along with the 'main' branch of the dependent Git repository should be the ones deployed.
I've previously attempted to include it in the pyproject.toml file, aiming to place it under two distinct groups:
[tool.poetry.group.master.dependencies]
private-repo = {git = "[email protected]/someone/some-package.git", rev = "master"}
[tool.poetry.group.dev.dependencies]
private-repo = {git = "[email protected]/someone/some-package.git", rev = "develop"}
So I could install the two different versions using these commands:
poetry install --with master
poetry install --with dev
But I get the following error message:
Because repo depends on both private-repo @ git+ssh://[email protected]/someone/some-package.git@master and private-repo @ [email protected]/someone/some-package.git@develop, version solving failed.
Is there a way to add it like this:
[tool.poetry.dependencies]
private-repo = {git = "[email protected]/someone/some-package.git", rev = "master if branch == 'master' else develop"}