mtkennerly / poetry-dynamic-versioning

Plugin for Poetry to enable dynamic versioning based on VCS tags
MIT License
588 stars 36 forks source link

Building requires poetry-dynamic-versioning to be previously installed. #126

Closed BrianPugh closed 1 year ago

BrianPugh commented 1 year ago

Currently, I'm trying to run poetry build --format=sdist in a github action, but the resulting tar.gz file has version 0.0.0. This is right after installing via snok/install-poetry. Point is, this is from a very clean poetry installation (I am also able to reproduce in a docker container).

My pyproject.toml contains:

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=0.21.5", "cython", "setuptools>=61.0"]
build-backend = "poetry_dynamic_versioning.backend"

I would expect for the poetry build-system (or is actually upstream to poetry?) to install poetry-dynamic-versioning for me since it's listed in requires. If I explicitly install poetry-dynamic-versioning (admittedly, as the README says to do), then run my build command, everything is fine:

poetry self add "poetry-dynamic-versioning[plugin]"
poetry build --format=sdist  # results in properly versioned sdist

Is this working-as-intended, a bug, or an upstream issue? Thanks!

Poetry version: 1.5.1 (latest)

mtkennerly commented 1 year ago

Poetry itself doesn't actually use the build-system config of the active project. The build-system is used in other commands like pip install ., but the Poetry CLI deliberately ignores it. Source: https://github.com/python-poetry/poetry/issues/6154#issuecomment-1218493969

BrianPugh commented 1 year ago

Gotcha, thanks for the clarification! This also explains why CIBuildWheel would correctly install poetry-dynamic-versioning. Thank you!

CPrescher commented 7 months ago

Hi, I am having this same issue. What would be the best way of action for building the packages inside of github actions?

BrianPugh commented 7 months ago

for a standard, pure python package, you can reference my github actions pipeline here:

https://github.com/BrianPugh/python-template/blob/main/.github/workflows/deploy.yaml

If you have dependencies that need to be compiled, you can check out my much more complicated pipeline here:

https://github.com/BrianPugh/python-template/blob/main/.github/workflows/build_wheels.yaml

CPrescher commented 7 months ago

Hi, thanks for the reference action. It is now working! https://github.com/Dioptas/Dioptas/blob/develop/.github/workflows/CD.yml

The main thing i needed to add was this:

      - name: Add Dynamic Versioning Plugin
        run: |
          poetry self add poetry-dynamic-versioning[plugin]

before building. Installing dependencies is not required for building.