Skip to content

Commit

Permalink
Make sure pydicom handler not already available when trying to add (#49)
Browse files Browse the repository at this point in the history
* pydicom handler only added when importing the package when pydicom doesn't already have one
  • Loading branch information
scaramallion authored Jun 15, 2020
1 parent b09b1f8 commit 1d428d3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/pytest-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
ubuntu:
Expand All @@ -29,12 +28,17 @@ jobs:
python -m pip install .
python -m pip uninstall -y pylibjpeg-openjpeg
python -m pip install git+https://github.com/pydicom/pylibjpeg-data
python -m pip install pytest coverage pytest-cov pydicom
python -m pip install pytest coverage pytest-cov
- name: Run pytest with no plugins
run: |
pytest --cov=pylibjpeg --cov-append
- name: Rerun pytest with pydicom and no plugins
run: |
pip install pydicom
pytest --cov=pylibjpeg --cov-append
- name: Rerun pytest with -lj plugin
run: |
Expand Down
8 changes: 7 additions & 1 deletion pylibjpeg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ def debug_logger():

try:
import pydicom
add_handler()
_logger.debug('pydicom module loaded')
from pylibjpeg.pydicom.utils import generate_frames

# We only add a handler if pydicom doesn't already have one
try:
import pydicom.pixel_data_handlers.pylibjpeg_handler
except ImportError:
add_handler()

except ImportError:
pass
2 changes: 1 addition & 1 deletion pylibjpeg/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re


__version__ = '1.1.0'
__version__ = '1.1.1'


VERSION_PATTERN = r"""
Expand Down
1 change: 1 addition & 0 deletions pylibjpeg/tests/test_pydicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_get_pixeldata_no_lj_syntax(self):
handler.get_pixeldata(ds)


@pytest.mark.skipif(not HAS_PYDICOM, reason="No pydicom")
class TestPlugins(object):
"""Test interaction with plugins."""
@pytest.mark.skipif(not RUN_JPEG, reason="No JPEG plugin")
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[bdist_wheel]
universal = 1
universal = 0

0 comments on commit 1d428d3

Please sign in to comment.