Open isuruf opened 2 years ago
It does not seem good if docs have to recommend the definition of namespace packages for projects that are not using namespace packages.
This is the essence of the issue: the deprecation makes it necessary to use a more complex solution (find_namespace_packages
) to a problem (bundling a data
folder in one's package) that was previously relatively simple to resolve.
My case above is illustrative.
It does not seem good if docs have to recommend the definition of namespace packages for projects that are not using namespace packages.
@merwok, please note that if a distribution install a directory nested somewhere under sys.path
and this directory that does not contain an __init__.py
, then that is indeed a namespace package, and the project is, effectively, using namespace packages. You can use your REPL to check that the directory is importable and the REPL will show you something like <module '...' (namespace)>
if you print the object you imported.
The assumption that certain directories that don't contain Python files are exempt of this behaviour is not backed by the implementation, and as far as I know, by the Python docs (the PEP introducing implicit namespaces pretty much says the opposite).
The warning message discussed in this issue has to deal with 2 situations:
include_package_data
to do so, but is forgetting to list such directories in packages
(therefore, it is providing an incorrect configuration that fails match file structure and intent).packages
or by using find_namespace_packages(..)
with the include/exclude
options, or by consciously relying on the fact that find_packages(...)
skip directories without __init__.py
). At the same time, the developer is correctly specifying include_package_data
such that files in other directories are included.Currently there is a bug in setuptools that will incorrectly handle both situations.
For situation 1, setuptools will include packages that are not listed in packages
, and therefore fail to fulfil the configuration that has been passed.
For situation 2, setuptools will not skip certain directories that are intentionally omitted from packages
, and therefore also fail to fulfil the configuration that has been passed.
To fix this bug we need the warning message to bring awareness for users that fall into category 1: that their configuration does not match the intent, and for users that fall into category 2: that they will need to use a workaround while the fix has not been implemented yet.
the project is, effectively, using namespace packages
I understand that, but my viewpoint is about author intent. In the examples here the developers have regular packages, source files and data files. They need a clean way to have their packages packaged up and installed, and the data files also packaged up.
They need a clean way to have their packages packaged up and installed, and the data files also packaged up.
The clean way is to list any package they are using to host data files in the packages
directive. This mental model is aligned with the Python implementation, docs, and work great with importlib.resources
.
There is no need for differentiating between types of directories, that is only conceptual overhead that does not really match the way Python works.
setuptools version
62.3.2
Python version
3.10
OS
Debian with conda
Additional environment information
No response
Description
pyopencl has OpenCL files and some headers in a subdirectory
pyopencl/cl
and they are included aspackage_data
so that the python module can find them.With new setuptools, there is a warning saying
cc @inducer
Expected behavior
No warning
How to Reproduce
python setup.py install
Output