Skip to content

Commit 8cd6bc2

Browse files
authored
Fix encoding and decoding on big endian systems (#99)
1 parent 765ce80 commit 8cd6bc2

18 files changed

+529
-16897
lines changed

.github/workflows/pytest-builds.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
15+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1616
arch: ['x64', 'x86']
1717

1818
steps:
@@ -48,7 +48,7 @@ jobs:
4848
strategy:
4949
fail-fast: false
5050
matrix:
51-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
51+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
5252

5353
steps:
5454
- uses: actions/checkout@v4
@@ -82,7 +82,7 @@ jobs:
8282
strategy:
8383
fail-fast: false
8484
matrix:
85-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
85+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
8686

8787
steps:
8888
- uses: actions/checkout@v4
@@ -106,7 +106,7 @@ jobs:
106106
pytest --cov openjpeg openjpeg/tests
107107
108108
- name: Install pydicom dev and rerun pytest (3.10+)
109-
if: ${{ contains('3.10 3.11 3.12', matrix.python-version) }}
109+
if: ${{ contains('3.10 3.11 3.12 3.13', matrix.python-version) }}
110110
run: |
111111
pip install pylibjpeg
112112
pip install git+https://github.com/pydicom/pydicom

.github/workflows/release-wheels.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ jobs:
4242
matrix:
4343
include:
4444
# Windows 32 bit
45-
- os: windows-latest
46-
python: 38
47-
platform_id: win32
4845
- os: windows-latest
4946
python: 39
5047
platform_id: win32
@@ -57,11 +54,11 @@ jobs:
5754
- os: windows-latest
5855
python: 312
5956
platform_id: win32
57+
- os: windows-latest
58+
python: 313
59+
platform_id: win32
6060

6161
# Windows 64 bit
62-
- os: windows-latest
63-
python: 38
64-
platform_id: win_amd64
6562
- os: windows-latest
6663
python: 39
6764
platform_id: win_amd64
@@ -74,12 +71,11 @@ jobs:
7471
- os: windows-latest
7572
python: 312
7673
platform_id: win_amd64
74+
- os: windows-latest
75+
python: 313
76+
platform_id: win_amd64
7777

7878
# Linux 64 bit manylinux2014
79-
- os: ubuntu-latest
80-
python: 38
81-
platform_id: manylinux_x86_64
82-
manylinux_image: manylinux2014
8379
- os: ubuntu-latest
8480
python: 39
8581
platform_id: manylinux_x86_64
@@ -96,11 +92,12 @@ jobs:
9692
python: 312
9793
platform_id: manylinux_x86_64
9894
manylinux_image: manylinux2014
95+
- os: ubuntu-latest
96+
python: 313
97+
platform_id: manylinux_x86_64
98+
manylinux_image: manylinux2014
9999

100100
# Linux aarch64
101-
- os: ubuntu-latest
102-
python: 38
103-
platform_id: manylinux_aarch64
104101
- os: ubuntu-latest
105102
python: 39
106103
platform_id: manylinux_aarch64
@@ -113,11 +110,11 @@ jobs:
113110
- os: ubuntu-latest
114111
python: 312
115112
platform_id: manylinux_aarch64
113+
- os: ubuntu-latest
114+
python: 313
115+
platform_id: manylinux_aarch64
116116

117117
# MacOS 12 x86_64
118-
- os: macos-12
119-
python: 38
120-
platform_id: macosx_x86_64
121118
- os: macos-12
122119
python: 39
123120
platform_id: macosx_x86_64
@@ -130,6 +127,9 @@ jobs:
130127
- os: macos-12
131128
python: 312
132129
platform_id: macosx_x86_64
130+
- os: macos-12
131+
python: 313
132+
platform_id: macosx_x86_64
133133

134134
steps:
135135
- uses: actions/checkout@v4
@@ -150,7 +150,7 @@ jobs:
150150
- name: Install cibuildwheel
151151
run: |
152152
python -m pip install -U pip
153-
python -m pip install cibuildwheel>=2.16
153+
python -m pip install cibuildwheel>=2.21
154154
155155
- name: Build wheels (non-MacOS arm64)
156156
env:
@@ -179,9 +179,6 @@ jobs:
179179
matrix:
180180
include:
181181
# MacOS 14 arm64
182-
- os: macos-14
183-
python: 38
184-
platform_id: macosx_arm64
185182
- os: macos-14
186183
python: 39
187184
platform_id: macosx_arm64
@@ -194,6 +191,9 @@ jobs:
194191
- os: macos-14
195192
python: 312
196193
platform_id: macosx_arm64
194+
- os: macos-14
195+
python: 313
196+
platform_id: macosx_arm64
197197

198198
steps:
199199
- uses: actions/checkout@v4
@@ -206,7 +206,7 @@ jobs:
206206
python-version: '3.9'
207207

208208
- name: Install cibuildwheel
209-
run: python -m pip install cibuildwheel==2.16.2 wheel==0.42
209+
run: python -m pip install cibuildwheel>=2.21 wheel>=0.42
210210

211211
- name: Build wheels
212212
env:
@@ -230,7 +230,7 @@ jobs:
230230
strategy:
231231
fail-fast: false
232232
matrix:
233-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
233+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
234234

235235
steps:
236236
- name: Set up Python ${{ matrix.python-version }}

build.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
from pathlib import Path
44
import shutil
5+
from struct import unpack
56
import subprocess
67
from typing import List, Any
78

@@ -24,6 +25,11 @@ def build(setup_kwargs: Any) -> Any:
2425

2526
setup_oj()
2627

28+
# Determine if system is big endian or not
29+
macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
30+
if unpack("h", b"\x00\x01")[0] == 1:
31+
macros.append(("PYOJ_BIG_ENDIAN", None))
32+
2733
ext = Extension(
2834
"_openjpeg",
2935
[os.fspath(p) for p in get_source_files()],
@@ -35,6 +41,7 @@ def build(setup_kwargs: Any) -> Any:
3541
],
3642
extra_compile_args=[],
3743
extra_link_args=[],
44+
define_macros=macros,
3845
)
3946

4047
ext_modules = cythonize(

0 commit comments

Comments
 (0)