Skip to content

Tox hangs after build error #2825

@jaraco

Description

@jaraco

Issue

Attempting to run tests on the requests-mock project, I ran tox. Fairly quickly an error was emitted, but my shell prompt did not return. I waited some seconds then hit Ctrl+C to cancel whatever tox was doing. It emitted a notice about "Teardown Started" but still was unresponsive. I hit another Ctrl+C but with no luck.

Environment

Provide at least:

  • OS: macOS 13.1
  • pip list of the host Python where tox is installed:
Package       Version
------------- -------
cachetools    5.2.0
chardet       5.1.0
colorama      0.4.6
distlib       0.3.6
filelock      3.8.2
packaging     22.0
pip           22.3.1
platformdirs  2.6.0
pluggy        1.0.0
pyproject_api 1.2.1
setuptools    65.6.3
tox           4.0.16
virtualenv    20.17.1
wheel         0.38.4

Output of running tox

Ran without -rvv:

 requests-mock bugfix-17 $ tox
python: install_deps> python -I -m pip install pbr -r /Users/jaraco/code/jamielennox/requests-mock/requirements.txt -r /Users/jaraco/code/jamielennox/requests-mock/test-requirements.txt
.pkg: install_requires> python -I -m pip install 'setuptools>=40.8.0' wheel
.pkg: _optional_hooks> python /Users/jaraco/.local/pipx/venvs/tox/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_sdist> python /Users/jaraco/.local/pipx/venvs/tox/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: install_requires_for_build_sdist> python -I -m pip install pbr
.pkg: prepare_metadata_for_build_wheel> python /Users/jaraco/.local/pipx/venvs/tox/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: build_sdist> python /Users/jaraco/.local/pipx/venvs/tox/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
python: packaging backend failed (code=error: Multiple top-level packages discovered in a flat-layout: ['releasenotes', 'requests_mock'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:

1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names

To find more information, look for "package discovery" on setuptools docs.), with SystemExit: error: Multiple top-level packages discovered in a flat-layout: ['releasenotes', 'requests_mock'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:

1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names

To find more information, look for "package discovery" on setuptools docs.
/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
  warnings.warn(msg, warning_class)
Traceback (most recent call last):
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/dist.py", line 1204, in run_command
    self.set_defaults()
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/discovery.py", line 340, in __call__
    self._analyse_package_layout(ignore_ext_modules)
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/discovery.py", line 373, in _analyse_package_layout
    or self._analyse_flat_layout()
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/discovery.py", line 430, in _analyse_flat_layout
    return self._analyse_flat_packages() or self._analyse_flat_modules()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/discovery.py", line 436, in _analyse_flat_packages
    self._ensure_no_accidental_inclusion(top_level, "packages")
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/discovery.py", line 466, in _ensure_no_accidental_inclusion
    raise PackageDiscoveryError(cleandoc(msg))
setuptools.errors.PackageDiscoveryError: Multiple top-level packages discovered in a flat-layout: ['releasenotes', 'requests_mock'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:

1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names

To find more information, look for "package discovery" on setuptools docs.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jaraco/.local/pipx/venvs/tox/lib/python3.11/site-packages/pyproject_api/_backend.py", line 90, in run
    outcome = backend_proxy(parsed_message["cmd"], **parsed_message["kwargs"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/.local/pipx/venvs/tox/lib/python3.11/site-packages/pyproject_api/_backend.py", line 32, in __call__
    return getattr(on_object, name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/build_meta.py", line 417, in build_sdist
    return self._build_with_temp_dir(['sdist', '--formats', 'gztar'],
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/build_meta.py", line 398, in _build_with_temp_dir
    self.run_setup()
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/build_meta.py", line 485, in run_setup
    self).run_setup(setup_script=setup_script)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/build_meta.py", line 335, in run_setup
    exec(code, locals())
  File "<string>", line 5, in <module>
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 215, in run_commands
    raise SystemExit("error: " + str(msg))
SystemExit: error: Multiple top-level packages discovered in a flat-layout: ['releasenotes', 'requests_mock'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:

1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names

To find more information, look for "package discovery" on setuptools docs.
Backend: run command build_sdist with args {'sdist_directory': '/Users/jaraco/code/jamielennox/requests-mock/.tox/.pkg/dist', 'config_settings': None}
Backend: Wrote response {'code': 'error: Multiple top-level packages discovered in a flat-layout: [\'releasenotes\', \'requests_mock\'].\n\nTo avoid accidental inclusion of unwanted files or directories,\nsetuptools will not proceed with this build.\n\nIf you are trying to create a single distribution with multiple packages\non purpose, you should not rely on automatic discovery.\nInstead, consider the following options:\n\n1. set up custom discovery (`find` directive with `include` or `exclude`)\n2. use a `src-layout`\n3. explicitly set `py_modules` or `packages` with a list of names\n\nTo find more information, look for "package discovery" on setuptools docs.', 'exc_type': 'SystemExit', 'exc_msg': 'error: Multiple top-level packages discovered in a flat-layout: [\'releasenotes\', \'requests_mock\'].\n\nTo avoid accidental inclusion of unwanted files or directories,\nsetuptools will not proceed with this build.\n\nIf you are trying to create a single distribution with multiple packages\non purpose, you should not rely on automatic discovery.\nInstead, consider the following options:\n\n1. set up custom discovery (`find` directive with `include` or `exclude`)\n2. use a `src-layout`\n3. explicitly set `py_modules` or `packages` with a list of names\n\nTo find more information, look for "package discovery" on setuptools docs.'} to /var/folders/sx/n5gkrgfx6zd91ymxr2sr9wvw00n8zm/T/pep517_build_sdist-4ckv1cgg.json
.pkg: _exit> python /Users/jaraco/.local/pipx/venvs/tox/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__


^CROOT: [70319] KeyboardInterrupt - teardown started
ROOT: interrupt tox environment: python
^C

Looking at the process tree, there's a defunct process under tox:

 requests-mock bugfix-17 $ pstree -s tox
-+= 00001 root /sbin/launchd
 \-+= 69773 jaraco /Applications/Hyper.app/Contents/MacOS/Hyper
   \-+= 69782 jaraco /opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python /Users/jaraco/.local/bin/xonsh --login
     \-+= 70319 jaraco /opt/homebrew/Cellar/python@3.11/3.11.1/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python /Users/jaraco/.local/bin/tox
       \--- 70327 jaraco <defunct>

Invoking kill on 70319 gave the shell back.

I cleaned the space and re-ran tox and got a similar experience. Even without any Ctrl+C, I see the defunct process under tox.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:minordoes not affect many people or has no big impacthelp:wantedIssues that have been acknowledged, a solution determined and a PR might likely be accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions