Skip to content

Commit

Permalink
Fix encoding and decoding on big endian systems (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaramallion authored Oct 28, 2024
1 parent 765ce80 commit 8cd6bc2
Show file tree
Hide file tree
Showing 18 changed files with 529 additions and 16,897 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pytest-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
arch: ['x64', 'x86']

steps:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
Expand All @@ -106,7 +106,7 @@ jobs:
pytest --cov openjpeg openjpeg/tests
- name: Install pydicom dev and rerun pytest (3.10+)
if: ${{ contains('3.10 3.11 3.12', matrix.python-version) }}
if: ${{ contains('3.10 3.11 3.12 3.13', matrix.python-version) }}
run: |
pip install pylibjpeg
pip install git+https://github.com/pydicom/pydicom
Expand Down
44 changes: 22 additions & 22 deletions .github/workflows/release-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ jobs:
matrix:
include:
# Windows 32 bit
- os: windows-latest
python: 38
platform_id: win32
- os: windows-latest
python: 39
platform_id: win32
Expand All @@ -57,11 +54,11 @@ jobs:
- os: windows-latest
python: 312
platform_id: win32
- os: windows-latest
python: 313
platform_id: win32

# Windows 64 bit
- os: windows-latest
python: 38
platform_id: win_amd64
- os: windows-latest
python: 39
platform_id: win_amd64
Expand All @@ -74,12 +71,11 @@ jobs:
- os: windows-latest
python: 312
platform_id: win_amd64
- os: windows-latest
python: 313
platform_id: win_amd64

# Linux 64 bit manylinux2014
- os: ubuntu-latest
python: 38
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 39
platform_id: manylinux_x86_64
Expand All @@ -96,11 +92,12 @@ jobs:
python: 312
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: 313
platform_id: manylinux_x86_64
manylinux_image: manylinux2014

# Linux aarch64
- os: ubuntu-latest
python: 38
platform_id: manylinux_aarch64
- os: ubuntu-latest
python: 39
platform_id: manylinux_aarch64
Expand All @@ -113,11 +110,11 @@ jobs:
- os: ubuntu-latest
python: 312
platform_id: manylinux_aarch64
- os: ubuntu-latest
python: 313
platform_id: manylinux_aarch64

# MacOS 12 x86_64
- os: macos-12
python: 38
platform_id: macosx_x86_64
- os: macos-12
python: 39
platform_id: macosx_x86_64
Expand All @@ -130,6 +127,9 @@ jobs:
- os: macos-12
python: 312
platform_id: macosx_x86_64
- os: macos-12
python: 313
platform_id: macosx_x86_64

steps:
- uses: actions/checkout@v4
Expand All @@ -150,7 +150,7 @@ jobs:
- name: Install cibuildwheel
run: |
python -m pip install -U pip
python -m pip install cibuildwheel>=2.16
python -m pip install cibuildwheel>=2.21
- name: Build wheels (non-MacOS arm64)
env:
Expand Down Expand Up @@ -179,9 +179,6 @@ jobs:
matrix:
include:
# MacOS 14 arm64
- os: macos-14
python: 38
platform_id: macosx_arm64
- os: macos-14
python: 39
platform_id: macosx_arm64
Expand All @@ -194,6 +191,9 @@ jobs:
- os: macos-14
python: 312
platform_id: macosx_arm64
- os: macos-14
python: 313
platform_id: macosx_arm64

steps:
- uses: actions/checkout@v4
Expand All @@ -206,7 +206,7 @@ jobs:
python-version: '3.9'

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

- name: Build wheels
env:
Expand All @@ -230,7 +230,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down
7 changes: 7 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from pathlib import Path
import shutil
from struct import unpack
import subprocess
from typing import List, Any

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

setup_oj()

# Determine if system is big endian or not
macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
if unpack("h", b"\x00\x01")[0] == 1:
macros.append(("PYOJ_BIG_ENDIAN", None))

ext = Extension(
"_openjpeg",
[os.fspath(p) for p in get_source_files()],
Expand All @@ -35,6 +41,7 @@ def build(setup_kwargs: Any) -> Any:
],
extra_compile_args=[],
extra_link_args=[],
define_macros=macros,
)

ext_modules = cythonize(
Expand Down
Loading

0 comments on commit 8cd6bc2

Please sign in to comment.