Skip to content

requirement with extra not installed #2604

@adamchainz

Description

@adamchainz

s## Issue

Minimized from daphne, which I just tried upgrading to tox 4.

Take this project setup in 4 files:

pyproject.toml:

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

setup.cfg:

[metadata]
name = example

[options]
py_modules = example
install_requires =
    twisted[tls]>=22.4

example.py:

import twisted

tox.ini:

[tox]
envlist = 311

[testenv]
commands =
    python -m example

On tox 3, this passes. On tox 4.0.0rc2+, it fails by not installing twisted:

tox
.pkg: install_requires> python -I -m pip install setuptools
.pkg: _optional_hooks> python /.../python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_sdist> python /.../python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: prepare_metadata_for_build_wheel> python /.../python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: build_sdist> python /.../python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
311: install_package> python -I -m pip install --force-reinstall --no-deps /Users/chainz/tmp/toxfail/.tox/.pkg/dist/example-0.0.0.tar.gz
311: commands[0]> python -m example
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/chainz/tmp/toxfail/example.py", line 1, in <module>
    import twisted
ModuleNotFoundError: No module named 'twisted'
311: exit 1 (0.01 seconds) /Users/chainz/tmp/toxfail> python -m example pid=735
.pkg: _exit> python /.../python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
  311: FAIL code 1 (3.01=setup[3.00]+cmd[0.01] seconds)
  evaluation failed :( (3.03 seconds)

This succeeds on tox 4.0.0rc1.

Removing the [tls] extra from twisted in setup.cfg also makes this pass on tox 4.0.0rc2+.

I suspect it has the same cause as #2603.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions