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

[BUG] In editable installs, whether new modules are auto-picked-up depends on whether the distribution contains a package or not #3624

Closed
anntzer opened this issue Oct 5, 2022 · 0 comments · Fixed by #3634
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.

Comments

@anntzer
Copy link

anntzer commented Oct 5, 2022

setuptools version

65.4.1

Python version

3.10.7

OS

Arch Linux

Additional environment information

No response

Description

In a loose (i.e. default) editable install of a distribution containing a single package, adding a toplevel module (out of the package) results in that module being automatically picked up (immediately available for import, without a reinstall). This corresponds also, I believe, to the old, pre-PEP660 behavior.
On the other hand, if the distribution does not contain a package but a single toplevel module, adding another toplevel module results in that (new) module not being automatically picked up.

Expected behavior

Consistent behavior in both cases, hopefully matching the legacy behavior (i.e. new toplevel modules are always auto-picked-up).

How to Reproduce

Write the following pyproject.toml:

[build-system]
requires = ["setuptools>=64"]
build-backend = "setuptools.build_meta"

[project]
name = "testpkg"
version = "0.0.1"

In that directory, create a single package, editably install, create a single (empty) new module, check that the new module can be imported:

mkdir src; mkdir src/pkg; touch src/pkg/__init__.py; pip install -e .; touch src/mod2.py; python -c 'import pkg, mod2'

This succeeds.

Blow away everything (except for pyproject.toml):

pip uninstall testpkg; rm -rf src

Create a single (empty) module, editably install, create another (empty) new module; this new module cannot be imported:

mkdir src; touch src/mod1.py; pip install -e .; touch src/mod2.py; python -c 'import mod1, mod2'

This fails with ModuleNotFoundError: No module named 'mod2'

Output

See above.

@anntzer anntzer added bug Needs Triage Issues that need to be evaluated for severity and status. labels Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant