From: JinWang An Date: Mon, 27 Mar 2023 08:02:56 +0000 (+0900) Subject: Imported Upstream version 65.3.0 X-Git-Tag: upstream/65.3.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3fee349b2d338953549eeb4d7e476989506478cf;p=platform%2Fupstream%2Fpython-setuptools.git Imported Upstream version 65.3.0 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index cf3c02a..f90d102 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 65.2.0 +current_version = 65.3.0 commit = True tag = True diff --git a/CHANGES.rst b/CHANGES.rst index 09a7c1b..8e35e3f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,20 @@ +v65.3.0 +------- + + +Changes +^^^^^^^ +* #3547: Stop ``ConfigDiscovery.analyse_name`` from splatting the ``Distribution.name`` attribute -- by :user:`jeamland` + +Documentation changes +^^^^^^^^^^^^^^^^^^^^^ +* #3554: Changed requires to requests in the pyproject.toml example in the :ref:`Dependency management section of the Quickstart guide ` -- by :user:`mfbutner` + +Misc +^^^^ +* #3561: Fixed accidental name matching in editable hooks. + + v65.2.0 ------- @@ -50,7 +67,7 @@ Documentation changes Misc ^^^^ -* #3526: Fix backward compatibility of editable installs and custom ``build_ext`` +* #3526: Fixed backward compatibility of editable installs and custom ``build_ext`` commands inheriting directly from ``distutils``. * #3528: Fixed ``buid_meta.prepare_metadata_for_build_wheel`` when given ``metadata_directory`` is ``"."``. diff --git a/docs/userguide/quickstart.rst b/docs/userguide/quickstart.rst index e2afdb8..13846e2 100644 --- a/docs/userguide/quickstart.rst +++ b/docs/userguide/quickstart.rst @@ -309,7 +309,7 @@ The example below show how to configure this kind of dependencies: # ... dependencies = [ "docutils", - "requires <= 0.4", + "requests <= 0.4", ] # ... diff --git a/setup.cfg b/setup.cfg index 16fe951..3d260d5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = setuptools -version = 65.2.0 +version = 65.3.0 author = Python Packaging Authority author_email = distutils-sig@python.org description = Easily download, build, install, upgrade, and uninstall Python packages @@ -19,6 +19,7 @@ classifiers = keywords = CPAN PyPI distutils eggs package management project_urls = Documentation = https://setuptools.pypa.io/ + Changelog = https://setuptools.pypa.io/en/stable/history.html [options] packages = find_namespace: diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index b908298..d05c3a7 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -758,7 +758,7 @@ class _EditableFinder: # MetaPathFinder @classmethod def find_spec(cls, fullname, path=None, target=None): for pkg, pkg_path in reversed(list(MAPPING.items())): - if fullname.startswith(pkg): + if fullname == pkg or fullname.startswith(f"{{pkg}}."): rest = fullname.replace(pkg, "", 1).strip(".").split(".") return cls._find_spec(fullname, Path(pkg_path, *rest)) diff --git a/setuptools/config/pyprojecttoml.py b/setuptools/config/pyprojecttoml.py index 9ff0c87..d995f0b 100644 --- a/setuptools/config/pyprojecttoml.py +++ b/setuptools/config/pyprojecttoml.py @@ -234,8 +234,8 @@ class _ConfigExpander: # A distribution object is required for discovering the correct package_dir dist = self._ensure_dist() - - with _EnsurePackagesDiscovered(dist, self.setuptools_cfg) as ensure_discovered: + ctx = _EnsurePackagesDiscovered(dist, self.project_cfg, self.setuptools_cfg) + with ctx as ensure_discovered: package_dir = ensure_discovered.package_dir self._expand_data_files() self._expand_cmdclass(package_dir) @@ -428,8 +428,11 @@ def _ignore_errors(ignore_option_errors: bool): class _EnsurePackagesDiscovered(_expand.EnsurePackagesDiscovered): - def __init__(self, distribution: "Distribution", setuptools_cfg: dict): + def __init__( + self, distribution: "Distribution", project_cfg: dict, setuptools_cfg: dict + ): super().__init__(distribution) + self._project_cfg = project_cfg self._setuptools_cfg = setuptools_cfg def __enter__(self): @@ -443,8 +446,10 @@ class _EnsurePackagesDiscovered(_expand.EnsurePackagesDiscovered): dist.set_defaults._ignore_ext_modules() # pyproject.toml-specific behaviour - # Set `py_modules` and `packages` in dist to short-circuit auto-discovery, - # but avoid overwriting empty lists purposefully set by users. + # Set `name`, `py_modules` and `packages` in dist to short-circuit + # auto-discovery, but avoid overwriting empty lists purposefully set by users. + if dist.metadata.name is None: + dist.metadata.name = self._project_cfg.get("name") if dist.py_modules is None: dist.py_modules = cfg.get("py-modules") if dist.packages is None: diff --git a/setuptools/discovery.py b/setuptools/discovery.py index 6a3d2c9..98fc2a7 100644 --- a/setuptools/discovery.py +++ b/setuptools/discovery.py @@ -481,7 +481,6 @@ class ConfigDiscovery: ) if name: self.dist.metadata.name = name - self.dist.name = name def _find_name_single_package_or_module(self) -> Optional[str]: """Exactly one module or package""" diff --git a/setuptools/tests/test_config_discovery.py b/setuptools/tests/test_config_discovery.py index fac365f..85b64b3 100644 --- a/setuptools/tests/test_config_discovery.py +++ b/setuptools/tests/test_config_discovery.py @@ -508,6 +508,49 @@ def test_compatible_with_numpy_configuration(tmp_path): assert dist.packages is None +def test_name_discovery_doesnt_break_cli(tmpdir_cwd): + jaraco.path.build({"pkg.py": ""}) + dist = Distribution({}) + dist.script_args = ["--name"] + dist.set_defaults() + dist.parse_command_line() # <-- no exception should be raised here. + assert dist.get_name() == "pkg" + + +def test_preserve_explicit_name_with_dynamic_version(tmpdir_cwd, monkeypatch): + """According to #3545 it seems that ``name`` discovery is running, + even when the project already explicitly sets it. + This seems to be related to parsing of dynamic versions (via ``attr`` directive), + which requires the auto-discovery of ``package_dir``. + """ + files = { + "src": { + "pkg": {"__init__.py": "__version__ = 42\n"}, + }, + "pyproject.toml": DALS(""" + [project] + name = "myproj" # purposefully different from package name + dynamic = ["version"] + [tool.setuptools.dynamic] + version = {"attr" = "pkg.__version__"} + """) + } + jaraco.path.build(files) + dist = Distribution({}) + orig_analyse_name = dist.set_defaults.analyse_name + + def spy_analyse_name(): + # We can check if name discovery was triggered by ensuring the original + # name remains instead of the package name. + orig_analyse_name() + assert dist.get_name() == "myproj" + + monkeypatch.setattr(dist.set_defaults, "analyse_name", spy_analyse_name) + dist.parse_config_files() + assert dist.get_version() == "42" + assert set(dist.packages) == {"pkg"} + + def _populate_project_dir(root, files, options): # NOTE: Currently pypa/build will refuse to build the project if no # `pyproject.toml` or `setup.py` is found. So it is impossible to do diff --git a/setuptools/tests/test_editable_install.py b/setuptools/tests/test_editable_install.py index 4a2ceb1..c8ee747 100644 --- a/setuptools/tests/test_editable_install.py +++ b/setuptools/tests/test_editable_install.py @@ -515,6 +515,30 @@ class TestFinderTemplate: with pytest.raises(ImportError, match="pkg"): import_module("pkg") + def test_similar_name(self, tmp_path): + files = { + "foo": { + "__init__.py": "", + "bar": { + "__init__.py": "", + } + }, + } + jaraco.path.build(files, prefix=tmp_path) + + mapping = { + "foo": str(tmp_path / "foo"), + } + template = _finder_template(str(uuid4()), mapping, {}) + + with contexts.save_paths(), contexts.save_sys_modules(): + sys.modules.pop("foo", None) + sys.modules.pop("foo.bar", None) + + self.install_finder(template) + with pytest.raises(ImportError, match="foobar"): + import_module("foobar") + def test_pkg_roots(tmp_path): """This test focus in getting a particular implementation detail right.