Skip to content

Commit 49f4bdd

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` now warns about the 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 49f4bdd

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
import os
12
import sys
23

34
from setuptools import Extension, setup
45

6+
# Load version string
7+
_verfile = os.path.join(os.path.dirname(__file__), 'openslide', '_version.py')
8+
with open(_verfile) as _fh:
9+
exec(_fh.read()) # instantiates __version__
10+
511
# use the Limited API on Python 3.11+; build release-specific wheels on
612
# older Python
713
_abi3 = sys.version_info >= (3, 11)
@@ -21,4 +27,18 @@
2127
# tag wheel for Limited API
2228
'bdist_wheel': {'py_limited_api': 'cp311'} if _abi3 else {},
2329
},
30+
#
31+
# setuptools < 61 compatibility for distro packages building from source
32+
name='openslide-python',
33+
version=__version__, # type: ignore[name-defined] # noqa: F821
34+
install_requires=[
35+
'Pillow',
36+
],
37+
packages=[
38+
'openslide',
39+
],
40+
package_data={
41+
'openslide': ['py.typed', '*.pyi'],
42+
},
43+
zip_safe=False,
2444
)

0 commit comments

Comments
 (0)