Open ewjoachim opened 3 months ago
this is a variation on "recording package.optional
in poetry.lock
is a bad idea". https://github.com/python-poetry/poetry/issues/3188 is another example.
in this case it is get_extra_package_names()
that does not recognise that importlib-metadata
is required by the sphinx
extra: because it sees that extra and assumes that the first sphinx
it finds will be just fine for the rest of its analysis. But the first sphinx
it finds is the newer one that does not need importlib-metadata
, and after that it never considers the other.
the Right Way to fix this IMO is not to put optional
in the lockfile at all: this is a misunderstanding of what the lockfile really is. Rather the installer-solver ought to start out knowing what extras it is solving for, and just return the right answer.
I expect that sorting that out will be quite the tangle for someone.
Might be fixed in the main branch.
1.8.3:
$ poetry install --dry-run --all-extras | grep importlib-metadata
- Installing importlib-metadata (8.2.0): Skipped for the following reason: Not required
main:
$ poetry install --dry-run --all-extras | grep importlib-metadata
- Installing importlib-metadata (8.2.0)
Pretty sure it isn't, maybe the luck of which sphinx
happens to show up first during get_extra_package_names()
is unstable
Apparently I knew about this at https://github.com/python-poetry/poetry/pull/6372#issue-1360542275
I am going to consider this a solved issue.
This is not a solved issue
Description
I am the maintainer of a package, procrastinate. Procrastinate is compatible with py3.8+ This package provides an optional Sphinx extension, so the package has sphinx as an extra dependency.
Procrastinate, independently, also has a doc that is built with sphinx. Building procrastinate's own doc needs Sphinx v8 (but the Sphinx extension provided by Procrastinate does not) Sphinx v8 only supports py3.10+ Consequently, Procrastinate has an optional dependency group that includes sphinx with v8+ (only for py3.10+) (the doc is built with a modern python, so all is well)
On Sphinx v7, Sphinx has a dependency to
importlib-metadata
but only for py < 3.10 On v8, they dropped this dependency, given py < 3.10 isn't required anymore.https://github.com/sphinx-doc/sphinx/blob/v7.4.7/pyproject.toml#L74C6-L74C24
When installing my env with py3.8,
poetry
says that importlib-metadata isSkipped for the following reason: Not required
, and so it's not installed, but it IS required (and it fails at runtime because it's not there)(below is a simple reproducer
pyproject.toml
that showcases the issue)Interestingly: here we have the issue without the
docs
group. If I remove thedocs
group from pyproject.toml, then it works normally.importlib-metadata
is a part of poetry.lock, andsphinx
appears twice inpoetry.lock
(once with v7 and once with v8), as expected.Workarounds
None identified
Poetry Installation Method
pipx
Operating System
Mac OS 14.2.1 (23C71) (Sonoma)
Poetry Version
Poetry (version 1.8.3)
Poetry Configuration
Python Sysconfig
Example pyproject.toml
Poetry Runtime Logs