From: JinWang An Date: Mon, 27 Mar 2023 08:02:55 +0000 (+0900) Subject: Imported Upstream version 65.1.1 X-Git-Tag: upstream/65.1.1^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09a28966e6223b2908f38dc25aa5c347be661958;p=platform%2Fupstream%2Fpython-setuptools.git Imported Upstream version 65.1.1 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 9dde3c5..6df865b 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 65.1.0 +current_version = 65.1.1 commit = True tag = True diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83624a5..1ff0403 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} - uses: actions/cache@v3 diff --git a/CHANGES.rst b/CHANGES.rst index 6cd0a78..448c6e8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,13 @@ +v65.1.1 +------- + + +Misc +^^^^ +* #3551: Avoided circular imports in meta path finder for editable installs when a + missing module has the same name as its parent. + + v65.1.0 ------- diff --git a/setup.cfg b/setup.cfg index b2a6950..ca95d7d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = setuptools -version = 65.1.0 +version = 65.1.1 author = Python Packaging Authority author_email = distutils-sig@python.org description = Easily download, build, install, upgrade, and uninstall Python packages diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index ea21484..b908298 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -684,9 +684,13 @@ def _is_nested(pkg: str, pkg_path: str, parent: str, parent_path: str) -> bool: False >>> _is_nested("a.b", "path/a/b", "c", "path/c") False + >>> _is_nested("a.a", "path/a/a", "a", "path/a") + True + >>> _is_nested("b.a", "path/b/a", "a", "path/a") + False """ norm_pkg_path = _normalize_path(pkg_path) - rest = pkg.replace(parent, "").strip(".").split(".") + rest = pkg.replace(parent, "", 1).strip(".").split(".") return ( pkg.startswith(parent) and norm_pkg_path == _normalize_path(Path(parent_path, *rest)) @@ -755,7 +759,7 @@ class _EditableFinder: # MetaPathFinder def find_spec(cls, fullname, path=None, target=None): for pkg, pkg_path in reversed(list(MAPPING.items())): if fullname.startswith(pkg): - rest = fullname.replace(pkg, "").strip(".").split(".") + rest = fullname.replace(pkg, "", 1).strip(".").split(".") return cls._find_spec(fullname, Path(pkg_path, *rest)) return None diff --git a/setuptools/tests/test_editable_install.py b/setuptools/tests/test_editable_install.py index 6b5cdd1..4a2ceb1 100644 --- a/setuptools/tests/test_editable_install.py +++ b/setuptools/tests/test_editable_install.py @@ -494,6 +494,27 @@ class TestFinderTemplate: three = import_module("parent.child.three") assert three.x == 3 + def test_no_recursion(self, tmp_path): + # See issue #3550 + files = { + "pkg": { + "__init__.py": "from . import pkg", + }, + } + jaraco.path.build(files, prefix=tmp_path) + + mapping = { + "pkg": str(tmp_path / "pkg"), + } + template = _finder_template(str(uuid4()), mapping, {}) + + with contexts.save_paths(), contexts.save_sys_modules(): + sys.modules.pop("pkg", None) + + self.install_finder(template) + with pytest.raises(ImportError, match="pkg"): + import_module("pkg") + def test_pkg_roots(tmp_path): """This test focus in getting a particular implementation detail right.