python-poetry / python-poetry/poetry

Inject local dependency version during publish/build

Open
#9,147 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Issue Kind

Change in current behaviour

Description

Support injecting dependency versions during publish/build for multi-project releases.

My usecase

I have a multi-project, single repo situation. The separate projects share a single venv and a top level pyproject.toml that has dev dependencies and configuration for linters/cqa - so that these standards are shared.

the top-level pyproject.toml has
./pyproject.toml

[tool.poetry.dependencies]
product-one = { path = "./product-one", develop = true }
product-two = { path = "./product-two", develop = true }
...

That's all well and good, but product-two depends on product-one. We manage this by using the same release cycle for both.
./product-one/pyproject.toml

version = "1.2.0-dev"
...

./product-two/pyproject.toml

version = "1.2.0-dev"

[tool.poetry.dependencies]
product-one = "~1.2.0"
...

Now, using ~1.2.0 doesn't work for poetry install, with or without allow-prereleases. Specifying "1.2.0-dev" does work, but we'd like to allow different patch/build version differences just to be flexible, and not have to set the version in so many places. The best would be to leave this version as * everywhere, and then have a dependency version inject parameter at build time. This would play nice with versioning plugins too.

Example implementation:

pyproject.toml

[tool.poetry.dependencies]
product-one = { inject-version = true }  # alternatively, inject-version = "tag"
then publish:
poetry publish --inject-version "product-one='~1.2.0'"
# OR
poetry publish --inject-version "~1.2.0'"  # apply same version to every dependency that needs it

This could have the caveat that it only works for path and git dependencies.

Impact

Better multi-project release processes

Workarounds

using sed to fix versions before release pipelines run, modifying build artifacts

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the top-level and project-specific pyproject.toml examples, then trace the poetry publish and build flows for path and git dependencies. Define the supported injection syntax and verify that dependency versions are correctly applied during publishing and that existing versioning workflows remain compatible.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, release
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.