Skip to content

Commit 6d386ad

Browse files
authored
Update to OpenJPEG v2.5.3 (#106)
1 parent 7fb79a9 commit 6d386ad

File tree

5 files changed

+24
-481
lines changed

5 files changed

+24
-481
lines changed

build.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
LIB_DIR = Path(__file__).parent / "lib"
1212
BUILD_TOOLS = Path(__file__).parent / "build_tools"
1313
OPENJPEG_SRC = LIB_DIR / "openjpeg" / "src" / "lib" / "openjp2"
14+
THIRDPARTY_SRC = LIB_DIR / "openjpeg" / "thirdparty"
15+
BIN_SRC = LIB_DIR / "openjpeg" / "src" / "bin" / "common"
1416
INTERFACE_SRC = LIB_DIR / "interface"
1517
BUILD_DIR = LIB_DIR / "openjpeg" / "build"
1618
BACKUP_DIR = BUILD_TOOLS / "backup"
@@ -36,6 +38,7 @@ def build(setup_kwargs: Any) -> Any:
3638
language="c",
3739
include_dirs=[
3840
os.fspath(OPENJPEG_SRC),
41+
os.fspath(THIRDPARTY_SRC / "liblcms2" / "include"),
3942
os.fspath(INTERFACE_SRC),
4043
numpy.get_include(),
4144
],
@@ -83,6 +86,10 @@ def get_source_files() -> List[Path]:
8386
if fname.suffix == ".c":
8487
source_files.append(fname)
8588

89+
for name in (THIRDPARTY_SRC / "liblcms2" / "src").glob("*"):
90+
if name.suffix == ".c":
91+
source_files.append(name)
92+
8693
source_files = [p.relative_to(Path(__file__).parent) for p in source_files]
8794
source_files.insert(0, PACKAGE_DIR / "_openjpeg.pyx")
8895

@@ -100,6 +107,10 @@ def setup_oj() -> None:
100107

101108
BACKUP_DIR.mkdir(exist_ok=True, parents=True)
102109

110+
# Copy the color space conversion files
111+
for name in ("color.c", "color.h"):
112+
shutil.copy(BIN_SRC / name, INTERFACE_SRC / name)
113+
103114
shutil.copy(
104115
LIB_DIR / "openjpeg" / "CMakeLists.txt",
105116
BACKUP_DIR / "CMakeLists.txt.backup",
@@ -114,6 +125,7 @@ def setup_oj() -> None:
114125
BUILD_TOOLS / "cmake" / "CMakeLists.txt",
115126
LIB_DIR / "openjpeg" / "CMakeLists.txt",
116127
)
128+
117129
# Edit openjpeg.c to remove the OPJ_API declaration
118130
with p_openjpeg.open("r") as f:
119131
data = f.readlines()
@@ -128,18 +140,23 @@ def setup_oj() -> None:
128140
if os.path.exists(BUILD_DIR):
129141
shutil.rmtree(BUILD_DIR)
130142

131-
try:
132-
os.remove(INTERFACE_SRC / "opj_config.h")
133-
os.remove(INTERFACE_SRC / "opj_config_private.h")
134-
except:
135-
pass
143+
for name in ("opj_config.h", "opj_config_private.h"):
144+
try:
145+
os.remove(INTERFACE_SRC / name)
146+
except:
147+
pass
136148

137149
os.mkdir(BUILD_DIR)
138150
cur_dir = os.getcwd()
139151
os.chdir(BUILD_DIR)
140152
subprocess.call(['cmake', os.fspath((LIB_DIR / "openjpeg").resolve(strict=True))])
141153
os.chdir(cur_dir)
142154

155+
shutil.copy(
156+
BUILD_DIR / "src" / "bin" / "common" / "opj_apps_config.h",
157+
INTERFACE_SRC / "opj_apps_config.h",
158+
)
159+
143160
# Turn off JPIP
144161
if os.path.exists(INTERFACE_SRC / "opj_config.h"):
145162
with open(INTERFACE_SRC / "opj_config.h", "a") as f:

docs/changes/v2.5.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Changes
88

99
* Bits above the precision are now ignored when encoding (:issue:`104`)
1010
* Supported Python versions are 3.9 to 3.14.
11+
* Update to openjpeg v2.5.3

0 commit comments

Comments
 (0)