Skip to content

Commit 535e37f

Browse files
authored
Prepare for release (#60)
1 parent 0045738 commit 535e37f

14 files changed

+278
-300
lines changed

.github/workflows/pytest-builds.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,5 @@ jobs:
124124
pytest --cov=libjpeg --cov-append libjpeg/tests
125125
126126
- name: Send coverage results
127-
if: ${{ success() && matrix.coverage == 'coverage' }}
127+
if: ${{ success() }}
128128
uses: codecov/codecov-action@v3

.github/workflows/release-wheels.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,18 @@ jobs:
243243
name: Upload wheels to PyPI
244244
needs: [ test-package ]
245245
runs-on: ubuntu-latest
246-
timeout-minutes: 10
246+
environment:
247+
name: pypi
248+
url: https://pypi.org/project/pylibjpeg-libjpeg/
249+
permissions:
250+
id-token: write
247251

248252
steps:
249253
- name: Download the wheels
250254
uses: actions/download-artifact@v4
251255
with:
252-
name: wheels
253256
path: dist/
257+
merge-multiple: true
254258

255259
- name: Publish package to PyPi
256-
uses: pypa/gh-action-pypi-publish@master
257-
with:
258-
user: __token__
259-
password: ${{ secrets.PYPI_PASSWORD }}
260+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ celerybeat.pid
103103
# Environments
104104
.env
105105
.venv
106-
env/
106+
env*/
107107
venv/
108108
ENV/
109109
env.bak/

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "libjpeg/src/libjpeg"]
1+
[submodule "lib/libjpeg"]
22
path = lib/libjpeg
33
url = https://github.com/thorfdbg/libjpeg.git

README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
[![Build Status](https://github.com/pydicom/pylibjpeg-libjpeg/workflows/unit-tests/badge.svg)](https://github.com/pydicom/pylibjpeg-libjpeg/actions?query=workflow%3Aunit-tests)
2-
[![codecov](https://codecov.io/gh/pydicom/pylibjpeg-libjpeg/branch/master/graph/badge.svg)](https://codecov.io/gh/pydicom/pylibjpeg-libjpeg)
3-
[![PyPI version](https://badge.fury.io/py/pylibjpeg-libjpeg.svg)](https://badge.fury.io/py/pylibjpeg-libjpeg)
4-
[![Python versions](https://img.shields.io/pypi/pyversions/pylibjpeg-libjpeg.svg)](https://img.shields.io/pypi/pyversions/pylibjpeg-libjpeg.svg)
1+
<p align="center">
2+
<a href="https://github.com/pydicom/pylibjpeg-libjpeg/actions?query=workflow%3Aunit-tests"><img alt="Build status" src="https://github.com/pydicom/pylibjpeg-libjpeg/workflows/unit-tests/badge.svg"></a>
3+
<a href="https://codecov.io/gh/pydicom/pylibjpeg-libjpeg"><img alt="Test coverage" src="https://codecov.io/gh/pydicom/pylibjpeg-libjpeg/branch/main/graph/badge.svg"></a>
4+
<a href="https://pypi.org/project/pylibjpeg-libjpeg/"><img alt="PyPI versions" src="https://img.shields.io/pypi/v/pylibjpeg-libjpeg"></a>
5+
<a href="https://www.python.org/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/pylibjpeg-libjpeg"></a>
6+
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
7+
</p>
58

69
## pylibjpeg-libjpeg
710

docs/changes/v2.0.0.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
Changes
77
.......
88

9-
* Supports Python 3.8-3.12
10-
* Switched build to ``pyproject.toml``
9+
* Drop support for Python 3.7
10+
* Add supports for Python 3.11 and 3.12
11+
* Switched packaging and build to ``pyproject.toml``
1112
* Added type hints
12-
* Added support for returning a bytearray containing the decoded image data
13+
* Added support for version 2 of the pixel data decoding interface

libjpeg/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""Set package shortcuts."""
22

3-
from ._version import __version__
4-
from .utils import decode, decode_pixel_data, get_parameters
3+
from ._version import __version__ # noqa: F401
4+
from .utils import decode, decode_pixel_data, get_parameters # noqa: F401

libjpeg/_libjpeg.cpp

+239-239
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libjpeg/tests/test_decode.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
"""Tests for pylibjpeg.decode()."""
22

3-
from io import BytesIO
43
import os
54
from pathlib import Path
65
import pytest
7-
import warnings
86

97
import numpy as np
108

119
try:
12-
import pydicom
1310
from pydicom.encaps import generate_pixel_data_frame
1411
from pydicom.pixel_data_handlers.util import reshape_pixel_array
1512

@@ -215,7 +212,7 @@ def test_lossless_sv1(self, fname, info):
215212
assert arr.dtype == "uint16"
216213

217214
@pytest.mark.parametrize("fname, info", REF_DCM["1.2.840.10008.1.2.4.80"])
218-
def test_extended(self, fname, info):
215+
def test_jls_lossless(self, fname, info):
219216
"""Test get_parameters() for the LS lossless datasets."""
220217
# info: (rows, columns, spp, bps)
221218
index = get_indexed_datasets("1.2.840.10008.1.2.4.80")
@@ -235,7 +232,7 @@ def test_extended(self, fname, info):
235232
assert arr.dtype == "uint16"
236233

237234
@pytest.mark.parametrize("fname, info", REF_DCM["1.2.840.10008.1.2.4.81"])
238-
def test_extended(self, fname, info):
235+
def test_jls(self, fname, info):
239236
"""Test get_parameters() for the LS lossy datasets."""
240237
# info: (rows, columns, spp, bps)
241238
index = get_indexed_datasets("1.2.840.10008.1.2.4.81")

libjpeg/tests/test_handler.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
"""Tests for the pylibjpeg pixel data handler."""
22

33
import pytest
4-
import warnings
5-
6-
import numpy as np
74

85
try:
9-
import pydicom
10-
import pydicom.config
116
from pydicom.pixel_data_handlers.util import convert_color_space
127
from pydicom.encaps import defragment_data
138

@@ -1010,7 +1005,7 @@ def test_1s_1f_i_16_16(self):
10101005
r"plugin is not installed"
10111006
)
10121007
with pytest.raises(RuntimeError, match=msg):
1013-
arr = ds.pixel_array
1008+
ds.pixel_array
10141009

10151010

10161011
@pytest.mark.skipif(not HAS_PYDICOM, reason="No dependencies")
@@ -1038,4 +1033,4 @@ def test_1s_1f_i_16_16(self):
10381033
r"plugin is not installed"
10391034
)
10401035
with pytest.raises(RuntimeError, match=msg):
1041-
arr = ds.pixel_array
1036+
ds.pixel_array

libjpeg/tests/test_parameters.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
"""Tests for the pylibjpeg pixel data handler."""
22

3-
from io import BytesIO
43
import os
54
import pytest
6-
import warnings
7-
8-
import numpy as np
95

106
try:
11-
import pydicom
12-
import pydicom.config
13-
from pydicom.pixel_data_handlers.util import convert_color_space
14-
from pydicom.encaps import defragment_data, generate_pixel_data_frame
7+
from pydicom.encaps import generate_pixel_data_frame
158

169
HAS_PYDICOM = True
1710
except ImportError:
@@ -53,9 +46,9 @@
5346
("SC_rgb_jpeg_gdcm.dcm", (100, 100, 3, 8)),
5447
],
5548
"1.2.840.10008.1.2.4.80": [
56-
("emri_small_jpeg_ls_lossless.dcm", (64, 64, 1, 12)),
49+
("emri_small_jpeg_ls_lossless.dcm", (64, 64, 1, 16)), # should be 16
5750
("MR_small_jpeg_ls_lossless.dcm", (64, 64, 1, 16)),
58-
("RG1_JLSL.dcm", (1955, 1841, 1, 16)),
51+
("RG1_JLSL.dcm", (1955, 1841, 1, 15)),
5952
("RG2_JLSL.dcm", (2140, 1760, 1, 10)),
6053
],
6154
"1.2.840.10008.1.2.4.81": [
@@ -168,21 +161,25 @@ def test_lossless_sv1(self, fname, info):
168161
assert info[3] == params["precision"]
169162

170163
@pytest.mark.parametrize("fname, info", REF_DCM["1.2.840.10008.1.2.4.80"])
171-
def test_extended(self, fname, info):
164+
def test_jls_lossless(self, fname, info):
172165
"""Test get_parameters() for the LS lossless datasets."""
173166
# info: (rows, columns, spp, bps)
174167
index = get_indexed_datasets("1.2.840.10008.1.2.4.80")
175168
ds = index[fname]["ds"]
176169

170+
print(fname)
171+
177172
frame = next(self.generate_frames(ds))
178173
params = get_parameters(frame)
174+
print(params)
175+
print(info)
179176

180177
assert (info[0], info[1]) == (params["rows"], params["columns"])
181178
assert info[2] == params["nr_components"]
182179
assert info[3] == params["precision"]
183180

184181
@pytest.mark.parametrize("fname, info", REF_DCM["1.2.840.10008.1.2.4.81"])
185-
def test_extended(self, fname, info):
182+
def test_jls_lossy(self, fname, info):
186183
"""Test get_parameters() for the LS lossy datasets."""
187184
# info: (rows, columns, spp, bps)
188185
index = get_indexed_datasets("1.2.840.10008.1.2.4.81")

libjpeg/tests/test_reconstruct.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Tests for the pylibjpeg pixel data handler."""
22

3-
from io import BytesIO
43
import os
54
import tempfile
65
from tempfile import NamedTemporaryFile

libjpeg/utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import enum
2-
from io import BytesIO
32
from math import ceil
43
import os
54
from pathlib import Path

pyproject.toml

+3-17
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ classifiers=[
3434
"Topic :: Software Development :: Libraries",
3535
]
3636
description = """\
37-
"A Python wrapper for libjpeg, with a focus on use as a plugin for "\
38-
"for pylibjpeg"\
37+
A Python wrapper for libjpeg, with a focus on use as a plugin for \
38+
for pylibjpeg\
3939
"""
4040
homepage = "https://github.com/pydicom/pylibjpeg-libjpeg"
4141
keywords = ["dicom pydicom python jpg jpeg jpg-ls jpeg-ls libjpeg pylibjpeg"]
@@ -56,26 +56,12 @@ packages = [
5656
{ include = "libjpeg" },
5757
]
5858
readme = "README.md"
59-
version = "2.0.0.dev0"
59+
version = "2.0.0"
6060

6161
[tool.poetry.dependencies]
6262
python = "^3.8"
6363
numpy = "^1.24"
6464

65-
# Optional dependencies
66-
black = { version = "^23.1", optional = true }
67-
coverage = { version = "^7.3", optional = true }
68-
mypy = { version = "^1.7", optional = true }
69-
pytest = { version = "^7.4", optional = true }
70-
pytest-cov = { version = "^4.1", optional = true }
71-
pydicom = { version = "^2.4", optional = true }
72-
pylibjpeg = { git = "https://github.com/pydicom/pylibjpeg.git", optional = true}
73-
pylibjpeg-data = { git = "https://github.com/pydicom/pylibjpeg-data.git", optional = true}
74-
75-
[tool.poetry.extras]
76-
dev = ["black", "coverage", "mypy", "pytest", "pytest-cov"]
77-
tests = ["coverage", "pytest", "pytest-cov", "pylibjpeg-data", "pylibjpeg", "pydicom"]
78-
7965
[tool.poetry.plugins."pylibjpeg.jpeg_decoders"]
8066
libjpeg = "libjpeg:decode"
8167

0 commit comments

Comments
 (0)