[bumpversion]
-current_version = 65.2.0
+current_version = 65.3.0
commit = True
tag = True
+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 <userguide/quickstart:dependency-management>` -- by :user:`mfbutner`
+
+Misc
+^^^^
+* #3561: Fixed accidental name matching in editable hooks.
+
+
v65.2.0
-------
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 ``"."``.
# ...
dependencies = [
"docutils",
- "requires <= 0.4",
+ "requests <= 0.4",
]
# ...
[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
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:
@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))
# 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)
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):
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:
)
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"""
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
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.