Skip to content

Commit cd288a4

Browse files
authored
Update interface and deploy builds (#11)
1 parent d96d420 commit cd288a4

File tree

9 files changed

+257
-52
lines changed

9 files changed

+257
-52
lines changed

.github/workflows/pytest-builds.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
name: Run pytest
1+
name: unit-tests
22

33
on:
44
push:
55
branches: [ master ]
66
pull_request:
7-
branches: [ master ]
87

98
jobs:
109
pytest:

.github/workflows/release-wheels.yml

+191-32
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,234 @@
1-
name: Build wheels and deploy to PyPI
1+
name: release-deploy
22

33
on:
44
release:
55
types: [ published ]
66

77
jobs:
8-
build_wheels:
9-
name: Build wheels for ${{ matrix.os }}
8+
build-sdist:
9+
name: Build source distribution
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
submodules: true
16+
17+
- uses: actions-rs/toolchain@v1
18+
with:
19+
toolchain: stable
20+
21+
- uses: actions/setup-python@v2
22+
name: Install Python
23+
with:
24+
python-version: '3.10'
25+
26+
- name: Build sdist
27+
run: |
28+
python -m pip install -U pip
29+
python -m pip install -U setuptools-rust
30+
python -m pip install .
31+
python setup.py sdist
32+
33+
- name: Store artifacts
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: wheels
37+
path: ./dist
38+
39+
build-wheels:
40+
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }}
1041
runs-on: ${{ matrix.os }}
11-
env:
12-
CIBW_SKIP: "cp36-* *-musl*"
1342
strategy:
1443
fail-fast: false
1544
matrix:
16-
os: [ubuntu-latest, windows-latest, macos-latest]
17-
python-version: ["3.10"]
45+
include:
46+
# Windows 32 bit
47+
- os: windows-latest
48+
python: 37
49+
platform_id: win32
50+
- os: windows-latest
51+
python: 38
52+
platform_id: win32
53+
- os: windows-latest
54+
python: 39
55+
platform_id: win32
56+
- os: windows-latest
57+
python: 310
58+
platform_id: win32
59+
60+
# Windows 64 bit
61+
- os: windows-latest
62+
python: 37
63+
platform_id: win_amd64
64+
- os: windows-latest
65+
python: 38
66+
platform_id: win_amd64
67+
- os: windows-latest
68+
python: 39
69+
platform_id: win_amd64
70+
- os: windows-latest
71+
python: 310
72+
platform_id: win_amd64
73+
74+
# Linux 64 bit manylinux2010
75+
- os: ubuntu-latest
76+
python: 37
77+
platform_id: manylinux_x86_64
78+
manylinux_image: manylinux2010
79+
- os: ubuntu-latest
80+
python: 38
81+
platform_id: manylinux_x86_64
82+
manylinux_image: manylinux2010
83+
- os: ubuntu-latest
84+
python: 39
85+
platform_id: manylinux_x86_64
86+
manylinux_image: manylinux2010
87+
- os: ubuntu-latest
88+
python: 310
89+
platform_id: manylinux_x86_64
90+
manylinux_image: manylinux2010
91+
92+
# Linux 64 bit manylinux2014
93+
- os: ubuntu-latest
94+
python: 37
95+
platform_id: manylinux_x86_64
96+
manylinux_image: manylinux2014
97+
- os: ubuntu-latest
98+
python: 38
99+
platform_id: manylinux_x86_64
100+
manylinux_image: manylinux2014
101+
- os: ubuntu-latest
102+
python: 39
103+
platform_id: manylinux_x86_64
104+
manylinux_image: manylinux2014
105+
- os: ubuntu-latest
106+
python: 310
107+
platform_id: manylinux_x86_64
108+
manylinux_image: manylinux2014
109+
110+
# MacOS x86_64
111+
- os: macos-latest
112+
python: 37
113+
platform_id: macosx_x86_64
114+
- os: macos-latest
115+
python: 38
116+
platform_id: macosx_x86_64
117+
- os: macos-latest
118+
python: 39
119+
platform_id: macosx_x86_64
120+
- os: macos-latest
121+
python: 310
122+
platform_id: macosx_x86_64
123+
124+
# MacOS arm64
125+
- os: macos-latest
126+
python: 38
127+
platform_id: macosx_arm64
128+
- os: macos-latest
129+
python: 39
130+
platform_id: macosx_arm64
131+
- os: macos-latest
132+
python: 310
133+
platform_id: macosx_arm64
18134

19135
steps:
20136
- uses: actions/checkout@v2
21137
with:
22138
submodules: true
23139

24-
# Install rust
25140
- uses: actions-rs/toolchain@v1
26141
with:
27142
toolchain: stable
28143

29-
# Install Python
30144
- uses: actions/setup-python@v2
31145
name: Install Python
32146
with:
33-
python-version: ${{ matrix.python-version }}
34-
35-
- name: Install requirements
36-
run: |
37-
pip install -U pip
38-
pip install cibuildwheel==2.3.1
39-
pip install setuptools-rust
147+
python-version: '3.9'
40148

41-
- name: Build sdist
149+
- name: Install cibuildwheel
42150
run: |
43-
python setup.py sdist
151+
python -m pip install -U pip
152+
python -m pip install -U setuptools-rust
153+
python -m pip install cibuildwheel==2.3.1
44154
45155
- name: Build wheels
156+
env:
157+
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
158+
CIBW_ARCHS: all
159+
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
160+
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
161+
CIBW_BUILD_VERBOSITY: 1
162+
CIBW_BEFORE_ALL: |
163+
curl -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y && rustup target add i686-pc-windows-msvc
164+
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
46165
run: |
47166
python --version
48167
python -m cibuildwheel --output-dir dist
49-
env:
50-
CIBW_BEFORE_ALL: |
51-
curl -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y && rustup target add i686-pc-windows-msvc
52-
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
53168
54-
- uses: actions/upload-artifact@v2
169+
- name: Store artifacts
170+
uses: actions/upload-artifact@v2
55171
with:
56172
name: wheels
57173
path: ./dist
58174

175+
test-package:
176+
name: Test built package
177+
needs: [ build-wheels, build-sdist ]
178+
runs-on: ubuntu-latest
179+
timeout-minutes: 30
180+
strategy:
181+
fail-fast: false
182+
matrix:
183+
python-version: ['3.7', '3.8', '3.9', '3.10']
184+
185+
steps:
186+
- uses: actions-rs/toolchain@v1
187+
with:
188+
toolchain: stable
189+
190+
- name: Set up Python ${{ matrix.python-version }}
191+
uses: actions/setup-python@v2
192+
with:
193+
python-version: ${{ matrix.python-version }}
194+
195+
- name: Download the wheels
196+
uses: actions/download-artifact@v2
197+
with:
198+
name: wheels
199+
path: dist/
200+
201+
- name: Install from package wheels and test
202+
run: |
203+
python -m venv testwhl
204+
source testwhl/bin/activate
205+
python -m pip install -U pip
206+
python -m pip install -U pytest pydicom pylibjpeg
207+
python -m pip uninstall -y pylibjpeg-rle
208+
python -m pip install git+https://github.com/pydicom/pylibjpeg-data
209+
python -m pip install -U --find-links dist/ pylibjpeg-rle
210+
python -c "import pytest; pytest.main(['--pyargs', 'rle.tests'])"
211+
deactivate
212+
213+
- name: Install from package tarball and test
214+
run: |
215+
python -m venv testsrc
216+
source testsrc/bin/activate
217+
python -m pip install -U pip
218+
python -m pip install -U pytest pydicom pylibjpeg
219+
python -m pip uninstall -y pylibjpeg-rle
220+
python -m pip install git+https://github.com/pydicom/pylibjpeg-data
221+
export PATH="$PATH:$HOME/.cargo/bin"
222+
python -m pip install -U dist/pylibjpeg-rle-*.tar.gz
223+
python -c "import pytest; pytest.main(['--pyargs', 'rle.tests'])"
224+
deactivate
225+
59226
# The pypi upload fails with non-linux containers, so grab the uploaded
60227
# artifacts and run using those
61228
# See: https://github.com/pypa/gh-action-pypi-publish/discussions/15
62229
deploy:
63230
name: Upload wheels to PyPI
64-
needs:
65-
- build_wheels
231+
needs: [ test-package ]
66232
runs-on: ubuntu-latest
67233

68234
steps:
@@ -72,13 +238,6 @@ jobs:
72238
name: wheels
73239
path: dist/
74240

75-
#- name: Publish package to Test PyPi
76-
# uses: pypa/gh-action-pypi-publish@master
77-
# with:
78-
# user: __token__
79-
# password: ${{ secrets.TEST_PYPI_PASSWORD }}
80-
# repository_url: https://test.pypi.org/legacy/
81-
82241
- name: Publish package to PyPi
83242
uses: pypa/gh-action-pypi-publish@master
84243
with:

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[![Build Status](https://github.com/pydicom/pylibjpeg-rle/workflows/unit-tests/badge.svg)](https://github.com/pydicom/pylibjpeg-rle/actions?query=workflow%3Aunit-tests)
2+
[![codecov](https://codecov.io/gh/pydicom/pylibjpeg-rle/branch/master/graph/badge.svg)](https://codecov.io/gh/pydicom/pylibjpeg-rle)
3+
[![PyPI version](https://badge.fury.io/py/pylibjpeg-rle.svg)](https://badge.fury.io/py/pylibjpeg-rle)
4+
[![Python versions](https://img.shields.io/pypi/pyversions/pylibjpeg-rle.svg)](https://img.shields.io/pypi/pyversions/pylibjpeg-rle.svg)
15

26
## pylibjpeg-rle
37

@@ -18,7 +22,7 @@ Make sure [Python](https://www.python.org/), [Git](https://git-scm.com/) and
1822
```bash
1923
git clone https://github.com/pydicom/pylibjpeg-rle
2024
cd pylibjpeg-rle
21-
python -m setup.py develop
25+
python -m pip install .
2226
```
2327

2428
### Supported Transfer Syntaxes
@@ -31,14 +35,11 @@ python -m setup.py develop
3135
#### Decoding
3236
##### With pylibjpeg
3337

34-
Because pydicom defaults to its own RLE decoder you must specify the use
35-
of pylibjpeg when decompressing:
3638
```python
3739
from pydicom import dcmread
3840
from pydicom.data import get_testdata_file
3941

4042
ds = dcmread(get_testdata_file("OBXXXX1A_rle.dcm"))
41-
ds.decompress("pylibjpeg")
4243
arr = ds.pixel_array
4344
```
4445

docs/release_notes/v1.3.0.rst

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. _v1.3.0:
2+
3+
1.3.0
4+
=====
5+
6+
Enhancements
7+
............
8+
9+
* Update decoding interface to allow passing kwargs instead of a dataset

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[build-system]
22
requires = [
3+
"setuptools>=18.0",
34
"setuptools-rust",
4-
"wheel"
5+
"wheel",
56
]

rle/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44

55

6-
__version__ = '1.2.0'
6+
__version__ = '1.3.0'
77

88

99
VERSION_PATTERN = r"""

rle/tests/test_handler.py

+16
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@
1919
@pytest.mark.skipif(not HAVE_PYDICOM, reason="No pydicom")
2020
class TestDecodePixelData:
2121
"""Tests for the plugin's decoder interface."""
22+
def test_no_dataset_kwargs_raises(self):
23+
"""Test plugin decoder with no dataset or kwargs raises"""
24+
ds = INDEX["OBXXXX1A_rle.dcm"]['ds']
25+
assert ds.file_meta.TransferSyntaxUID == RLELossless
26+
assert 8 == ds.BitsAllocated
27+
assert 1 == ds.SamplesPerPixel
28+
assert 0 == ds.PixelRepresentation
29+
assert 600 == ds.Rows
30+
assert 800 == ds.Columns
31+
assert 1 == getattr(ds, 'NumberOfFrames', 1)
32+
33+
frame = next(generate_pixel_data_frame(ds.PixelData))
34+
msg = r"Either `ds` or `\*\*kwargs` must be used"
35+
with pytest.raises(ValueError, match=msg):
36+
decode_pixel_data(frame)
37+
2238
def test_u8_1s_1f(self):
2339
"""Test plugin decoder for 8 bit, 1 sample, 1 frame data."""
2440
ds = INDEX["OBXXXX1A_rle.dcm"]['ds']

0 commit comments

Comments
 (0)