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

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

Closed
BrianPugh opened this issue Jun 9, 2023 · 6 comments
Closed
Labels
question Further information is requested

Comments

@BrianPugh
Copy link

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
Copy link
Owner

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: python-poetry/poetry#6154 (comment)

@mtkennerly mtkennerly added the question Further information is requested label Jun 10, 2023
@BrianPugh
Copy link
Author

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

@CPrescher
Copy link

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

@BrianPugh
Copy link
Author

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
Copy link

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.

@jymchng
Copy link

jymchng commented Aug 1, 2024

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)

Seems like when I try to use your Python template and run poetry build --format sdist, then I try to pip install ./dist/simple_python_template-0.0.0.tar.gz`, I get the following error:

Processing ./dist/simple_python_template-0.1.0.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [26 lines of output]
      Traceback (most recent call last):
        File "/root/python_projects/simple-python-template/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/root/python_projects/simple-python-template/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/root/python_projects/simple-python-template/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/poetry/core/masonry/api.py", line 42, in prepare_metadata_for_build_wheel
          poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/poetry_dynamic_versioning/patch.py", line 26, in alt_poetry_create
          name = _get_and_apply_version(
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/poetry_dynamic_versioning/__init__.py", line 705, in _get_and_apply_version
          version, instance = _get_version(config, name)
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/poetry_dynamic_versioning/__init__.py", line 515, in _get_version
          version = _get_version_from_dunamai(vcs, pattern, config)
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/poetry_dynamic_versioning/__init__.py", line 474, in _get_version_from_dunamai
          return Version.from_vcs(
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/dunamai/__init__.py", line 2045, in from_vcs
          return cls._do_vcs_callback(
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/dunamai/__init__.py", line 2097, in _do_vcs_callback
          return callback(**kwargs)
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/dunamai/__init__.py", line 1089, in from_git
          _detect_vcs(vcs, path)
        File "/tmp/pip-build-env-3e4s9cm6/overlay/lib/python3.10/site-packages/dunamai/__init__.py", line 371, in _detect_vcs
          raise RuntimeError("This does not appear to be a {} project".format(expected_vcs.value.title()))
      RuntimeError: This does not appear to be a Git project
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Any idea @BrianPugh?

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

No branches or pull requests

4 participants