diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-08-11 22:12:07 +0100 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-08-11 22:12:07 +0100 |
| commit | 32e18c05945541e899e15d71c66439aa0ddca88b (patch) | |
| tree | 4cfe4399290c68d8bb17b1ef529f04f34c8ae952 | |
| parent | c2397339d57db2e792cbc629d088f7ef091d271b (diff) | |
| parent | 611f54ca354f874d342e16d498a882dd7ac5853f (diff) | |
| download | python-setuptools-git-32e18c05945541e899e15d71c66439aa0ddca88b.tar.gz | |
Fix issue with editable install and single module distributions
| -rw-r--r-- | changelog.d/3502.misc.rst | 1 | ||||
| -rw-r--r-- | setuptools/command/editable_wheel.py | 2 | ||||
| -rw-r--r-- | setuptools/tests/test_editable_install.py | 29 |
3 files changed, 31 insertions, 1 deletions
diff --git a/changelog.d/3502.misc.rst b/changelog.d/3502.misc.rst new file mode 100644 index 00000000..ecc98334 --- /dev/null +++ b/changelog.d/3502.misc.rst @@ -0,0 +1 @@ +Fix issue with editable install and single module packages. diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index eb79608b..1bb7ddfb 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -439,7 +439,7 @@ class _TopLevelFinder: roots = _find_package_roots(top_level, package_dir, src_root) namespaces_: Dict[str, List[str]] = dict(chain( - _find_namespaces(self.dist.packages, roots), + _find_namespaces(self.dist.packages or [], roots), ((ns, []) for ns in _find_virtual_namespaces(roots)), )) diff --git a/setuptools/tests/test_editable_install.py b/setuptools/tests/test_editable_install.py index 40a35f65..8ab17b3c 100644 --- a/setuptools/tests/test_editable_install.py +++ b/setuptools/tests/test_editable_install.py @@ -163,6 +163,35 @@ def test_editable_with_flat_layout(tmp_path, venv, editable_opts): assert subprocess.check_output(cmd).strip() == b"4 2" +def test_editable_with_single_module(tmp_path, venv, editable_opts): + files = { + "mypkg": { + "pyproject.toml": dedent("""\ + [build-system] + requires = ["setuptools", "wheel"] + build-backend = "setuptools.build_meta" + + [project] + name = "mod" + version = "3.14159" + + [tool.setuptools] + py-modules = ["mod"] + """), + "mod.py": "b = 2", + }, + } + jaraco.path.build(files, prefix=tmp_path) + project = tmp_path / "mypkg" + + cmd = [venv.exe(), "-m", "pip", "install", + "--no-build-isolation", # required to force current version of setuptools + "-e", str(project), *editable_opts] + print(str(subprocess.check_output(cmd), "utf-8")) + cmd = [venv.exe(), "-c", "import mod; print(mod.b)"] + assert subprocess.check_output(cmd).strip() == b"2" + + class TestLegacyNamespaces: """Ported from test_develop""" |
