Skip to content

Commit 1d428d3

Browse files
authored
Make sure pydicom handler not already available when trying to add (#49)
* pydicom handler only added when importing the package when pydicom doesn't already have one
1 parent b09b1f8 commit 1d428d3

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

.github/workflows/pytest-builds.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches: [ master ]
66
pull_request:
7-
branches: [ master ]
87

98
jobs:
109
ubuntu:
@@ -29,12 +28,17 @@ jobs:
2928
python -m pip install .
3029
python -m pip uninstall -y pylibjpeg-openjpeg
3130
python -m pip install git+https://github.com/pydicom/pylibjpeg-data
32-
python -m pip install pytest coverage pytest-cov pydicom
31+
python -m pip install pytest coverage pytest-cov
3332
3433
- name: Run pytest with no plugins
3534
run: |
3635
pytest --cov=pylibjpeg --cov-append
3736
37+
- name: Rerun pytest with pydicom and no plugins
38+
run: |
39+
pip install pydicom
40+
pytest --cov=pylibjpeg --cov-append
41+
3842
- name: Rerun pytest with -lj plugin
3943
run: |
4044

pylibjpeg/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ def debug_logger():
2727

2828
try:
2929
import pydicom
30-
add_handler()
3130
_logger.debug('pydicom module loaded')
3231
from pylibjpeg.pydicom.utils import generate_frames
32+
33+
# We only add a handler if pydicom doesn't already have one
34+
try:
35+
import pydicom.pixel_data_handlers.pylibjpeg_handler
36+
except ImportError:
37+
add_handler()
38+
3339
except ImportError:
3440
pass

pylibjpeg/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44

55

6-
__version__ = '1.1.0'
6+
__version__ = '1.1.1'
77

88

99
VERSION_PATTERN = r"""

pylibjpeg/tests/test_pydicom.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def test_get_pixeldata_no_lj_syntax(self):
7272
handler.get_pixeldata(ds)
7373

7474

75+
@pytest.mark.skipif(not HAS_PYDICOM, reason="No pydicom")
7576
class TestPlugins(object):
7677
"""Test interaction with plugins."""
7778
@pytest.mark.skipif(not RUN_JPEG, reason="No JPEG plugin")

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[bdist_wheel]
2-
universal = 1
2+
universal = 0

0 commit comments

Comments
 (0)