Skip to content

[BUG] pyproject.toml tools.setuptools.packages not recognized #3803

@hoba87

Description

@hoba87

setuptools version

67.0.0

Python version

3.9

OS

Win11

Additional environment information

I'm using a venv.

Description

With my flat directory layout I'm getting the error: " Multiple top-level packages discovered in a flat-layout: ['gui', 'misc', 'package']"
Settings in pyproject.toml as given below doesn't work. I have also tried with settings include/exclude for find.
The error only vanishes, if I use a additional setup.py with

import setuptools

if __name__ == "__main__":
    setuptools.setup(packages=['package'])

Expected behavior

It should work without the additional setup.py

How to Reproduce

directory layout:

- package
  - gui
  - misc
  - package
    - __init__.py
  - pyproject.toml

With the setting in pyproject.toml:

[tools.setuptools]
packages = ["package"]

Output

  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      error: Multiple top-level packages discovered in a flat-layout: ['gui', 'misc', 'package'].

      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.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssues that need to be evaluated for severity and status.bug
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions