Skip to content

Commit

Permalink
Use openslide-bin for default openslide support (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanocallaghan authored Oct 30, 2024
1 parent fae6fae commit a20ec2c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@ on:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install Openslide
run: sudo apt install openslide-tools

- name: Install
run: pip install .[test,openslide]
run: pip install .[test]

- name: Run tests
run: pytest
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ git clone https://github.com/qupath/qubalab.git # clone this repository
cd qubalab # go to the project directory
python -m venv ./.venv # create a local virual environment
source ./.venv/bin/activate # activate the venv
pip install -e ".[dev,test,openslide]" # install qubalab (-e means changes are loaded dynamically)
pip install -e ".[dev,test]" # install qubalab (-e means changes are loaded dynamically)
jupyter lab . # to start the Jupyter notebooks
pytest # to run unit tests
```

## OpenSlide support

OpenSlide support relies on having OpenSlide binaries installed at a system level. Therefore, not all aspects of OpenSlide will work consistently across platforms, as the versions available from package managers or from OpenSlide directly may vary between operating systems. We hope that this will be resolved shortly with the release of OpenSlide 4.0.0 binaries in the [openslide-bin](https://pypi.org/project/openslide-bin/) package, and the release of [openslide-python](https://pypi.org/project/openslide-python/) 1.4.0 which will use them.
6 changes: 4 additions & 2 deletions qubalab/images/qupath_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ def _read_block(self, level: int, region: Region2D) -> np.ndarray:

self._gateway.entry_point.writeImageRegion(self._qupath_server, request, temp_path)
image = bytes_to_image(temp_path, self.metadata.is_rgb, ImageShape(region.width, region.height, c=self.metadata.n_channels))

os.remove(temp_path)
## on Windows, this fails because the file handle is open elsewhere
## slightly bad manners to pollute tempfiles but should be insignificant
if not os.name == "nt":
os.remove(temp_path)
else:
format = 'png' if self.metadata.is_rgb else "imagej tiff"

Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ install_requires =
shapely ~= 2.0.4
rasterio ~= 1.3.10
matplotlib ~= 3.9.0
openslide-python ~= 1.4.0
openslide-bin ~=4.0.0


[options.extras_require]
Expand All @@ -33,7 +35,6 @@ dev =
test =
pytest ~= 8.2.2
openslide =
openslide-python ~= 1.2.0
doc =
sphinx ~= 7.4.5
sphinx-rtd-theme ~= 2.0.0

0 comments on commit a20ec2c

Please sign in to comment.