From 5994c37a87c6262f3827da92f64dbe2daddca554 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Tue, 29 Oct 2024 15:39:25 -0700 Subject: [PATCH] Fix configuration of package data When setuptools 61+ is configured via pyproject.toml, it defaults to include-package-data = true, rather than the historical default of false. We don't want wheels to include random files from the package directory, in particular _convert.c. Disable include-package-data. In addition, we were inadvertently relying on setuptools 69+ experimental functionality to include .pyi and py.typed files in the sdist and .pyi files in wheels. Explicitly configure this. Move py.typed package-data declaration from setup.py to pyproject.toml. Fixes: b893ba288c25 ("Switch to PEP 621 project metadata") Fixes: a40175e028b5 ("_convert: add type hints") Fixes: 5f49c0173cd8 ("Export type hints from openslide package") Signed-off-by: Benjamin Gilbert --- MANIFEST.in | 1 + pyproject.toml | 4 ++++ setup.py | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 2aa1e1d6..6ac08ff1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include *.md +global-include py.typed *.pyi recursive-include doc *.py *.rst recursive-include examples *.html *.js *.png *.py recursive-include tests *.dcm *.png *.py *.svs *.tiff diff --git a/pyproject.toml b/pyproject.toml index 6bb05bb2..6394f6fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,11 +38,15 @@ Documentation = "https://openslide.org/api/python/" Repository = "https://github.com/openslide/openslide-python" [tool.setuptools] +include-package-data = false packages = ["openslide"] [tool.setuptools.dynamic] version = {attr = "openslide._version.__version__"} +[tool.setuptools.package-data] +openslide = ["py.typed", "*.pyi"] + [tool.black] skip-string-normalization = true target-version = ["py38", "py39", "py310", "py311", "py312", "py313"] diff --git a/setup.py b/setup.py index 4a5e532c..a4702e72 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,4 @@ # tag wheel for Limited API 'bdist_wheel': {'py_limited_api': 'cp311'} if _abi3 else {}, }, - package_data={ - 'openslide': ['py.typed'], - }, )