Skip to content

Commit

Permalink
Update interface and deploy builds (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaramallion authored Jan 22, 2022
1 parent d96d420 commit cd288a4
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 52 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pytest-builds.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Run pytest
name: unit-tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
pytest:
Expand Down
223 changes: 191 additions & 32 deletions .github/workflows/release-wheels.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,234 @@
name: Build wheels and deploy to PyPI
name: release-deploy

on:
release:
types: [ published ]

jobs:
build_wheels:
name: Build wheels for ${{ matrix.os }}
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.10'

- name: Build sdist
run: |
python -m pip install -U pip
python -m pip install -U setuptools-rust
python -m pip install .
python setup.py sdist
- name: Store artifacts
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./dist

build-wheels:
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }}
runs-on: ${{ matrix.os }}
env:
CIBW_SKIP: "cp36-* *-musl*"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10"]
include:
# Windows 32 bit
- os: windows-latest
python: 37
platform_id: win32
- os: windows-latest
python: 38
platform_id: win32
- os: windows-latest
python: 39
platform_id: win32
- os: windows-latest
python: 310
platform_id: win32

# Windows 64 bit
- os: windows-latest
python: 37
platform_id: win_amd64
- os: windows-latest
python: 38
platform_id: win_amd64
- os: windows-latest
python: 39
platform_id: win_amd64
- os: windows-latest
python: 310
platform_id: win_amd64

# Linux 64 bit manylinux2010
- os: ubuntu-latest
python: 37
platform_id: manylinux_x86_64
manylinux_image: manylinux2010
- os: ubuntu-latest
python: 38
platform_id: manylinux_x86_64
manylinux_image: manylinux2010
- os: ubuntu-latest
python: 39
platform_id: manylinux_x86_64
manylinux_image: manylinux2010
- os: ubuntu-latest
python: 310
platform_id: manylinux_x86_64
manylinux_image: manylinux2010

# Linux 64 bit manylinux2014
- os: ubuntu-latest
python: 37
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 38
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 39
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 310
platform_id: manylinux_x86_64
manylinux_image: manylinux2014

# MacOS x86_64
- os: macos-latest
python: 37
platform_id: macosx_x86_64
- os: macos-latest
python: 38
platform_id: macosx_x86_64
- os: macos-latest
python: 39
platform_id: macosx_x86_64
- os: macos-latest
python: 310
platform_id: macosx_x86_64

# MacOS arm64
- os: macos-latest
python: 38
platform_id: macosx_arm64
- os: macos-latest
python: 39
platform_id: macosx_arm64
- os: macos-latest
python: 310
platform_id: macosx_arm64

steps:
- uses: actions/checkout@v2
with:
submodules: true

# Install rust
- uses: actions-rs/toolchain@v1
with:
toolchain: stable

# Install Python
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: ${{ matrix.python-version }}

- name: Install requirements
run: |
pip install -U pip
pip install cibuildwheel==2.3.1
pip install setuptools-rust
python-version: '3.9'

- name: Build sdist
- name: Install cibuildwheel
run: |
python setup.py sdist
python -m pip install -U pip
python -m pip install -U setuptools-rust
python -m pip install cibuildwheel==2.3.1
- name: Build wheels
env:
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_ARCHS: all
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_ALL: |
curl -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y && rustup target add i686-pc-windows-msvc
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
run: |
python --version
python -m cibuildwheel --output-dir dist
env:
CIBW_BEFORE_ALL: |
curl -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y && rustup target add i686-pc-windows-msvc
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
- uses: actions/upload-artifact@v2
- name: Store artifacts
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./dist

test-package:
name: Test built package
needs: [ build-wheels, build-sdist ]
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Download the wheels
uses: actions/download-artifact@v2
with:
name: wheels
path: dist/

- name: Install from package wheels and test
run: |
python -m venv testwhl
source testwhl/bin/activate
python -m pip install -U pip
python -m pip install -U pytest pydicom pylibjpeg
python -m pip uninstall -y pylibjpeg-rle
python -m pip install git+https://github.com/pydicom/pylibjpeg-data
python -m pip install -U --find-links dist/ pylibjpeg-rle
python -c "import pytest; pytest.main(['--pyargs', 'rle.tests'])"
deactivate
- name: Install from package tarball and test
run: |
python -m venv testsrc
source testsrc/bin/activate
python -m pip install -U pip
python -m pip install -U pytest pydicom pylibjpeg
python -m pip uninstall -y pylibjpeg-rle
python -m pip install git+https://github.com/pydicom/pylibjpeg-data
export PATH="$PATH:$HOME/.cargo/bin"
python -m pip install -U dist/pylibjpeg-rle-*.tar.gz
python -c "import pytest; pytest.main(['--pyargs', 'rle.tests'])"
deactivate
# The pypi upload fails with non-linux containers, so grab the uploaded
# artifacts and run using those
# See: https://github.com/pypa/gh-action-pypi-publish/discussions/15
deploy:
name: Upload wheels to PyPI
needs:
- build_wheels
needs: [ test-package ]
runs-on: ubuntu-latest

steps:
Expand All @@ -72,13 +238,6 @@ jobs:
name: wheels
path: dist/

#- name: Publish package to Test PyPi
# uses: pypa/gh-action-pypi-publish@master
# with:
# user: __token__
# password: ${{ secrets.TEST_PYPI_PASSWORD }}
# repository_url: https://test.pypi.org/legacy/

- name: Publish package to PyPi
uses: pypa/gh-action-pypi-publish@master
with:
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![Build Status](https://github.com/pydicom/pylibjpeg-rle/workflows/unit-tests/badge.svg)](https://github.com/pydicom/pylibjpeg-rle/actions?query=workflow%3Aunit-tests)
[![codecov](https://codecov.io/gh/pydicom/pylibjpeg-rle/branch/master/graph/badge.svg)](https://codecov.io/gh/pydicom/pylibjpeg-rle)
[![PyPI version](https://badge.fury.io/py/pylibjpeg-rle.svg)](https://badge.fury.io/py/pylibjpeg-rle)
[![Python versions](https://img.shields.io/pypi/pyversions/pylibjpeg-rle.svg)](https://img.shields.io/pypi/pyversions/pylibjpeg-rle.svg)

## pylibjpeg-rle

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

### Supported Transfer Syntaxes
Expand All @@ -31,14 +35,11 @@ python -m setup.py develop
#### Decoding
##### With pylibjpeg

Because pydicom defaults to its own RLE decoder you must specify the use
of pylibjpeg when decompressing:
```python
from pydicom import dcmread
from pydicom.data import get_testdata_file

ds = dcmread(get_testdata_file("OBXXXX1A_rle.dcm"))
ds.decompress("pylibjpeg")
arr = ds.pixel_array
```

Expand Down
9 changes: 9 additions & 0 deletions docs/release_notes/v1.3.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. _v1.3.0:

1.3.0
=====

Enhancements
............

* Update decoding interface to allow passing kwargs instead of a dataset
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build-system]
requires = [
"setuptools>=18.0",
"setuptools-rust",
"wheel"
"wheel",
]
2 changes: 1 addition & 1 deletion rle/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re


__version__ = '1.2.0'
__version__ = '1.3.0'


VERSION_PATTERN = r"""
Expand Down
16 changes: 16 additions & 0 deletions rle/tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
@pytest.mark.skipif(not HAVE_PYDICOM, reason="No pydicom")
class TestDecodePixelData:
"""Tests for the plugin's decoder interface."""
def test_no_dataset_kwargs_raises(self):
"""Test plugin decoder with no dataset or kwargs raises"""
ds = INDEX["OBXXXX1A_rle.dcm"]['ds']
assert ds.file_meta.TransferSyntaxUID == RLELossless
assert 8 == ds.BitsAllocated
assert 1 == ds.SamplesPerPixel
assert 0 == ds.PixelRepresentation
assert 600 == ds.Rows
assert 800 == ds.Columns
assert 1 == getattr(ds, 'NumberOfFrames', 1)

frame = next(generate_pixel_data_frame(ds.PixelData))
msg = r"Either `ds` or `\*\*kwargs` must be used"
with pytest.raises(ValueError, match=msg):
decode_pixel_data(frame)

def test_u8_1s_1f(self):
"""Test plugin decoder for 8 bit, 1 sample, 1 frame data."""
ds = INDEX["OBXXXX1A_rle.dcm"]['ds']
Expand Down
Loading

0 comments on commit cd288a4

Please sign in to comment.