Skip to content

Commit 43a3455

Browse files
committed
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. With setuptools >= 62.3.0, `setup.py install` will now warn about duplicate specification of dependencies, but the warning is harmless: SetuptoolsWarning: `install_requires` overwritten in `pyproject.toml` (dependencies) Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent e3d30a4 commit 43a3455

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/workflows/python.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,25 @@ jobs:
231231
path: artifacts/whl
232232
compression-level: 0
233233

234+
setuptools:
235+
name: Setuptools install
236+
needs: pre-commit
237+
runs-on: ubuntu-20.04
238+
steps:
239+
- name: Check out repo
240+
uses: actions/checkout@v4
241+
- name: Install dependencies
242+
run: |
243+
sudo apt-get update
244+
sudo apt-get install -y libopenslide0 python3-pil
245+
pip install pytest
246+
- name: Install OpenSlide Python
247+
run: sudo python setup.py install
248+
- name: Run tests
249+
run: pytest -v
250+
- name: Tile slide
251+
run: python examples/deepzoom/deepzoom_tile.py --viewer -o tiled tests/fixtures/small.svs
252+
234253
docs:
235254
name: Docs
236255
needs: pre-commit

setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
from pathlib import Path
12
import sys
23

34
from setuptools import Extension, setup
45

6+
# Load version string
7+
with open(Path(__file__).parent / 'openslide/_version.py') as _fh:
8+
exec(_fh.read()) # instantiates __version__
9+
510
# use the Limited API on Python 3.11+; build release-specific wheels on
611
# older Python
712
_abi3 = sys.version_info >= (3, 11)
@@ -21,4 +26,18 @@
2126
# tag wheel for Limited API
2227
'bdist_wheel': {'py_limited_api': 'cp311'} if _abi3 else {},
2328
},
29+
#
30+
# setuptools < 61 compatibility for distro packages building from source
31+
name='openslide-python',
32+
version=__version__, # type: ignore[name-defined] # noqa: F821
33+
install_requires=[
34+
'Pillow',
35+
],
36+
packages=[
37+
'openslide',
38+
],
39+
package_data={
40+
'openslide': ['py.typed', '*.pyi'],
41+
},
42+
zip_safe=False,
2443
)

0 commit comments

Comments
 (0)