From 512ddc09897c9f8cb5b3a2bdc2e7fe4be4bccd2b Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Wed, 30 Oct 2024 10:44:46 -0700 Subject: [PATCH] Fix `setup.py install` with old setuptools We still need to support building distro packages with older setuptools that doesn't understand PEP 621. Re-add enough setup.py configuration (duplicating pyproject.toml) to make older setuptools happy. Signed-off-by: Benjamin Gilbert --- .github/workflows/python.yml | 19 +++++++++++++++++++ setup.py | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 3adaf2eb..01274db6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -231,6 +231,25 @@ jobs: path: artifacts/whl compression-level: 0 + setuptools: + name: Setuptools install + needs: pre-commit + runs-on: ubuntu-20.04 + steps: + - name: Check out repo + uses: actions/checkout@v4 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libopenslide0 python3-pil + pip install pytest + - name: Install OpenSlide Python + run: sudo python setup.py install + - name: Run tests + run: pytest -v + - name: Tile slide + run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/fixtures/small.svs + docs: name: Docs needs: pre-commit diff --git a/setup.py b/setup.py index a4702e72..82116233 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,13 @@ +import os import sys from setuptools import Extension, setup +# Load version string +_verfile = os.path.join(os.path.dirname(__file__), 'openslide', '_version.py') +with open(_verfile) as _fh: + exec(_fh.read()) # instantiates __version__ + # use the Limited API on Python 3.11+; build release-specific wheels on # older Python _abi3 = sys.version_info >= (3, 11) @@ -21,4 +27,18 @@ # tag wheel for Limited API 'bdist_wheel': {'py_limited_api': 'cp311'} if _abi3 else {}, }, + # + # setuptools < 61 compatibility for distro packages building from source + name='openslide-python', + version=__version__, # type: ignore[name-defined] # noqa: F821 + install_requires=[ + 'Pillow', + ], + packages=[ + 'openslide', + ], + package_data={ + 'openslide': ['py.typed', '*.pyi'], + }, + zip_safe=False, )