Skip to content

Commit 0da8347

Browse files
authored
Merge pull request #306 from bgilbert/setuptools
Fix `setup.py install` with old setuptools
2 parents cd3216d + 43a3455 commit 0da8347

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
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

examples/deepzoom/deepzoom_tile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def _write_html(self) -> None:
335335
# We're not running from a module (e.g. "python deepzoom_tile.py")
336336
# so PackageLoader('__main__') doesn't work in jinja2 3.x.
337337
# Load templates directly from the filesystem.
338-
loader = jinja2.FileSystemLoader(Path(__file__).parent / 'templates')
338+
loader = jinja2.FileSystemLoader([Path(__file__).parent / 'templates'])
339339
env = jinja2.Environment(loader=loader, autoescape=True)
340340
template = env.get_template('slide-multipane.html')
341341
associated_urls = {n: self._url_for(n) for n in self._slide.associated_images}

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)