question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

poetry>=1.2 package with group dependencies cannot be installed with default build-system

See original GitHub issue
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: macOS Monterey 12.0.1
  • Poetry version: 1.2.0a2
  • pyproject.toml: default from poetry init -n

Issue

Hello! Thanks a lot for this tool.

When creating a project with poetry>=1.2 it adds the default build-system:

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

If you add a --group dependency in this project, it becomes impossible to install because the latest stable release of poetry-core does not support group and produces

Traceback (most recent call last):
  File "/tmp/tmpbqlvtksr_in_process.py", line 280, in <module>
    main()
  File "/tmp/tmpbqlvtksr_in_process.py", line 263, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/tmp/tmpbqlvtksr_in_process.py", line 133, in prepare_metadata_for_build_wheel
    return hook(metadata_directory, config_settings)
  File "/tmp/pip-build-env-l3emamb6/overlay/lib/python3.10/site-packages/poetry/core/masonry/api.py", line 43, in prepare_metadata_for_build_wheel
    poetry = Factory().create_poetry(Path(".").resolve(), with_dev=False)
  File "/tmp/pip-build-env-l3emamb6/overlay/lib/python3.10/site-packages/poetry/core/factory.py", line 43, in create_poetry
    raise RuntimeError("The Poetry configuration is invalid:\n" + message)
RuntimeError: The Poetry configuration is invalid:
  - Additional properties are not allowed ('group' was unexpected)

Reproduce

This Dockerfile shows the issue

FROM python

RUN pip install "poetry==1.2.0a2"
# Create a package with a dev dependency
RUN mkdir -p /mypkg/mypkg \
    && cd /mypkg \
    && touch mypkg/__init__.py \
    && touch README.md \ 
    && poetry init -n \
    && poetry add --group dev pytest
 
 # Create a project that will import the package
 RUN mkdir -p /importer \
    && cd /importer \
    && poetry init -n
 
 # Trigger the error
 RUN cd /importer && poetry add /mypkg

Mitigation

Changing the build dependency to requires = ["poetry-core>=1.1.0a6"] will currently fix the issue

Resolution

  • If poetry 1.1 was forward compatible (as raised here #4628) it could “maybe work” if the only groups are dev dependencies not meant to be installed with the package.
  • Maybe poetry 1.2 could set a minimum build dependency, which would be poetry-core>=1.1 but i did not find a way to tell the build system to install with --pre to allow for pre-releases, so it would need to be explicitly something like poetry-core>=1.1.0a6.

Maybe this is not an issue, once poetry==1.2 and poetry-core==1.1 are officially release this might all go away.

Thank you very much!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

13reactions
ljnsncommented, Mar 25, 2022

I have the same issue on version 1.2.0b1.

5reactions
TBBlecommented, Jul 15, 2022

To be clear, the original issue this ticket was raised for still exists: A Poetry 1.2-managed project which uses groups (per the original example) still declares an unversioned build-system requirement on poetry-core, and so will fail if this is not manually adjusted to depend on poetry-core>=1.1.0a6 or similar. I just checked this hasn’t changed in Poetry master (from earlier this week, anyway).

Pendulum already has this versioned build-system requirement, so it’s not suffering from the issue in this ticket.

Poetry itself (in master) depends on poetry-core ^1.1.0b3, so it might make sense for Poetry projects created with poetry 1.2 to depend on that version of poetry-core for their build-system from the start; for existing projects, that requirement could be adjusted when some poetry-core-1.0-incompatible change , e.g. groups, or the newer console scripts support, is made via poetry CLI.

It might also make sense for the documentation to mark those pyproject.toml features that depend on poetry-core 1.1 in the documentation so that people editing their pyproject.toml manually with reference to the documentation, e.g., as happened in #4628, will know they need to ensure their build-system dependency is appropriately updated.

And as a further molly-guard, it might make sense to have Poetry notice when pyproject.toml contains features needing poetry-core 1.1 but does not declare this in its build-system block, similar to how it notices when your poetry.lock is out-of-date compared to pyproject.toml.

All this depends on having a clear record and documentation of the poetry-core 1.1 added and changed features, and the ability to recognise them in pyproject.toml. And parse the build-system requirement line to determine which version of poetry-core is being depended upon…

Separately, it might make sense for Poetry 1.2, when given add --group dev, to generate the poetry-core 1.0 format if the build-system requirement is not versioned for poetry-core 1.1 already (as opposed to bumping the poetry-core dependency as I suggested above). However, I assume that option would have been discussed in the initial implementation of generalised group support and not seen as valuable at the time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing Poetry 1.2.0 | Blog
By default, dependencies across all non-optional groups will be installed when executing poetry install . You can exclude one or more groups ......
Read more >
Upgrade poetry 1.2.0 tox.ini error Invalide PEP440 version
It might be a dependency that has Python version 3.8.13+ set as a dependency. So you could comment out all (dev) dependencies, then...
Read more >
The build system "ament_cmake" and the meta build tool ...
It consists of two major parts: a build system (e.g. CMake, Python setuptools) to configure, build, and install a single package; a tool...
Read more >
Using the koji build system — Koji 1.31.0 documentation
Koji runs on top of Mock to build RPM packages for specific architectures and ... it includes dependencies on the Koji CLI, so...
Read more >
How to make a Python package in 2021
2. Projects can re-package as a single task rather than a massive ... You can't install a poetry package editably into another environment....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found