Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra directories exposed by editable wheel for setuptools project itself #4006

Closed
abravalheri opened this issue Aug 8, 2023 · 0 comments · Fixed by #4007
Closed

Extra directories exposed by editable wheel for setuptools project itself #4006

abravalheri opened this issue Aug 8, 2023 · 0 comments · Fixed by #4007

Comments

@abravalheri
Copy link
Contributor

abravalheri commented Aug 8, 2023

I noticed in main (5169a9b) that some extra directories of the setuptools project ended up exposed by the editable wheel. Specifically launcher and newsfragments. This is a quick reproducer:

git clone --depth 1 https://github.com/pypa/setuptools /tmp/test-setuptools
cd /tmp/test-setuptools
git reset --hard 5169a9b
python3.11 -m venv .venv
.venv/bin/python -m pip install -U 'pip==23.2.1'
.venv/bin/python -m pip install -e .
cat .venv/lib/python3.11/site-packages/__editable___setuptools_*_finder.py | head
import sys
from importlib.machinery import ModuleSpec
from importlib.machinery import all_suffixes as module_suffixes
from importlib.util import spec_from_file_location
from itertools import chain
from pathlib import Path

MAPPING = {'_distutils_hack': '/tmp/test-setuptools/_distutils_hack', 'launcher': '/tmp/test-setuptools/launcher', 'newsfragments': '/tmp/test-setuptools/newsfragments', 'pkg_resources': '/tmp/test-setuptools/pkg_resources', 'setuptools': '/tmp/test-setuptools/setuptools'}
NAMESPACES = {'launcher': ['/tmp/test-setuptools/launcher'], 'newsfragments': ['/tmp/test-setuptools/newsfragments']}
PATH_PLACEHOLDER = '__editable__.setuptools-68.0.0.post20230808.finder' + ".__path_hook__"

This is likely caused by the way packages = find_namespace: is configured in setup.cfg.
We can check that by running:

# Still inside /tmp/test-setuptools from the previous example
.venv/bin/python
Python 3.11.4 (main, Jun  7 2023, 12:45:49) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools
>>> from distutils.core import run_setup
>>> dist = run_setup("setup.py", stop_after="commandline")
>>> dist.packages
['launcher', 'newsfragments', 'pkg_resources', 'setuptools', '_distutils_hack', 'pkg_resources.extern', 'pkg_resources._vendor', 'pkg_resources._vendor.importlib_resources', 'pkg_resources._vendor.jaraco', 'pkg_resources._vendor.more_itertools', 'pkg_resources._vendor.packaging', 'pkg_resources._vendor.platformdirs', 'pkg_resources._vendor.jaraco.text', 'setuptools.command', 'setuptools.config', 'setuptools.extern', 'setuptools._distutils', 'setuptools._vendor', 'setuptools.config._validate_pyproject', 'setuptools._distutils.command', 'setuptools._vendor.importlib_metadata', 'setuptools._vendor.importlib_resources', 'setuptools._vendor.jaraco', 'setuptools._vendor.more_itertools', 'setuptools._vendor.packaging', 'setuptools._vendor.tomli', 'setuptools._vendor.jaraco.text']
>>> "newsfragments" in dist.packages
True
>>> "launcher" in dist.packages
True

I imagine that the reason why newsfragments and launcher are not included in the regular wheel is because setup.cfg/setup.py does not have package_data = [...] or include_package_data = True, so the .rst and .exe files are excluded from the wheel, and therefore the newsfragments and launcher directories end up empty during the build, which will automatically remove them from the zip (zip files cannot contain empty directories right?)

The expectation would be that the packages configuration exclude these directories by default (even if they don't contain .py files) to prevent errors (e.g. in the future we could end up adding files to these directories that are captured by setuptools package_data or include_package_data).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant