You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a flat (non-src-based) layout, it is not possible to configure using pyproject.toml in a way that doesn't immediately break when a new package is added to the project layout.
i.e. I configure using
[tool.setuptools.packages.find]
where = ["."]
include = [
# ... long, and fragile, list
]
exclude = [
# This, or similar syntaxes, don't seem to actually work.
# https://stackoverflow.com/q/75091671/339144
] # exclude packages matching these glob patterns (empty by default)
but if I add a new directory to my project, I must remember to add it to pyproject.toml.
If you want to exclude the mypackage/data folder and anything under it, you should provide the following exclude pattern exclude = ["mypackage.data", "mypackage.data.*"]1.
The pattern mypackage*data*py is implying that you have py as part of the package name, which does not seem to be the case. Also note that packages in Python are collections of modules (i.e. they map into directories, while modules map into files), so you cannot use exclude for files specifically... The original pattern would match something like mypackage/data/py/file.py.
Now regarding the criticism about the methodology not being convenient for your use case, that is a fair comment. But setuptools understands that it is simply impossible to foresee and accommodate ALL the possible scenarios. Instead it offers the ultimate flexibility for all users that have a particular scenario in mind: you can implement your own discovery algorithm by using setup.py (note that you can keep most of your configuration in pyproject.toml and only define setup(packages=[...]) in setup.py.
So, ultimately, you have tree choices
You can choose convention over configuration and adequate your source layout to work with setuptools built-in automatic discovery.
You can use some lightweight configuration in pyproject.toml using include/exclude.
If that still don't work for you then, you can implement your own algorithm in setup.py.
setuptools version
setuptools==75.3.0
Python version
Python 3.11
OS
Ubuntu
Additional environment information
No response
Description
When using a flat (non-src-based) layout, it is not possible to configure using
pyproject.toml
in a way that doesn't immediately break when a new package is added to the project layout.i.e. I configure using
but if I add a new directory to my project, I must remember to add it to pyproject.toml.
As here: https://stackoverflow.com/questions/79169280/pyproject-toml-config-using-setuptools-with-correct-packages-automatically
Expected behavior
I expect to have a way that will "just work forever".
How to Reproduce
.
Output
.
The text was updated successfully, but these errors were encountered: