diff --git a/.github/workflows/test-src-build-linux.yml b/.github/workflows/test-src-build-linux.yml index 0fd591ce..290fa28a 100644 --- a/.github/workflows/test-src-build-linux.yml +++ b/.github/workflows/test-src-build-linux.yml @@ -36,10 +36,12 @@ jobs: fail-fast: false matrix: arch: ["amd64", "arm64"] - docker_file: ["Alpine_3_18", "Almalinux_9"] + docker_file: ["Alpine_3_17", "Alpine_3_18", "Almalinux_9", "Debian_12"] include: - arch: "arm/v7" docker_file: "Alpine_3_18" + - arch: "arm/v7" + docker_file: "Debian_12" - arch: "amd64" docker_file: "Fedora_38" diff --git a/docker/from_src/Alpine_3_17.Dockerfile b/docker/from_src/Alpine_3_17.Dockerfile new file mode 100644 index 00000000..34da44e0 --- /dev/null +++ b/docker/from_src/Alpine_3_17.Dockerfile @@ -0,0 +1,32 @@ +FROM alpine:3.17 as base + +RUN \ + apk add --no-cache \ + python3-dev \ + py3-pip \ + alpine-sdk \ + cmake \ + nasm \ + aom-dev \ + x265-dev \ + py3-numpy \ + py3-pillow + +RUN \ + python3 -m pip install --upgrade pip + +FROM base as build_test + +COPY . /pillow_heif + +RUN \ + python3 pillow_heif/libheif/linux_build_libs.py && \ + if [ `getconf LONG_BIT` = 64 ]; then \ + python3 -m pip install -v "pillow_heif/.[tests]"; \ + else \ + python3 -m pip install -v "pillow_heif/.[tests-min]"; \ + fi && \ + echo "**** Build Done ****" && \ + python3 -c "import pillow_heif; print(pillow_heif.libheif_info())" && \ + pytest pillow_heif && \ + echo "**** Test Done ****" diff --git a/docker/from_src/Alpine_3_18.Dockerfile b/docker/from_src/Alpine_3_18.Dockerfile index cf90f714..140c469a 100644 --- a/docker/from_src/Alpine_3_18.Dockerfile +++ b/docker/from_src/Alpine_3_18.Dockerfile @@ -5,7 +5,11 @@ RUN \ python3-dev \ py3-pip \ alpine-sdk \ - libheif-dev \ + cmake \ + nasm \ + aom-dev \ + x265-dev \ + libde265-dev \ py3-numpy \ py3-pillow @@ -17,6 +21,7 @@ FROM base as build_test COPY . /pillow_heif RUN \ + python3 pillow_heif/libheif/linux_build_libs.py && \ if [ `getconf LONG_BIT` = 64 ]; then \ python3 -m pip install -v "pillow_heif/.[tests]"; \ else \ diff --git a/docker/from_src/Debian_12.Dockerfile b/docker/from_src/Debian_12.Dockerfile new file mode 100644 index 00000000..dda544db --- /dev/null +++ b/docker/from_src/Debian_12.Dockerfile @@ -0,0 +1,33 @@ +FROM debian:bookworm-slim as base + +RUN \ + apt-get -qq update && \ + apt-get -y -q install \ + python3-pip \ + python3-pillow \ + libffi-dev \ + libtool \ + git \ + cmake \ + nasm \ + wget \ + libde265-dev \ + libx265-dev \ + libaom-dev + +FROM base as build_test + +COPY . /pillow_heif + +RUN \ + python3 pillow_heif/libheif/linux_build_libs.py && \ + if [ `getconf LONG_BIT` = 64 ]; then \ + python3 -m pip install -v --break-system-packages "pillow_heif/.[tests]"; \ + else \ + python3 -m pip install -v --break-system-packages "pillow_heif/.[tests-min]"; \ + export PH_TESTS_NO_HEVC_ENC=1; \ + fi && \ + echo "**** Build Done ****" && \ + python3 -c "import pillow_heif; print(pillow_heif.libheif_info())" && \ + pytest pillow_heif && \ + echo "**** Test Done ****" diff --git a/libheif/linux_build_libs.py b/libheif/linux_build_libs.py index 0c946577..7fe7cbd6 100644 --- a/libheif/linux_build_libs.py +++ b/libheif/linux_build_libs.py @@ -104,6 +104,17 @@ def is_musllinux() -> bool: return False +def is_library_installed(name: str) -> bool: + if name.find("main") != -1 and name.find("reference") != -1: + raise Exception("`name` param can not contain `main` and `reference` substrings.") + _r = run(f"gcc -l{name}".split(), stdout=PIPE, stderr=STDOUT, check=False) + if _r.stdout: + _ = _r.stdout.decode("utf-8") + if _.find("main") != -1 and _.find("reference") != -1: + return True + return False + + def run_print_if_error(args) -> None: _ = run(args, stdout=PIPE, stderr=STDOUT, check=False) if _.returncode != 0: @@ -202,15 +213,25 @@ def build_libs() -> None: _original_dir = getcwd() try: if not tool_check_version("cmake", "3.13.4"): - raise ValueError("Can not find `cmake` with version >=3.13.4") - if not PH_LIGHT_VERSION: - if not check_install_nasm("2.15.05"): - raise ValueError("Can not find/install `nasm` with version >=2.15.05") - build_lib_linux(LIBX265_URL, "x265") - if not check_install_nasm("2.15.05"): - raise ValueError("Can not find/install `nasm` with version >=2.15.05") - build_lib_linux(LIBAOM_URL, "aom") - build_lib_linux(LIBDE265_URL, "libde265") + raise ValueError("Can not find `cmake` with version >=3.16.3") + if not is_library_installed("x265"): + if not PH_LIGHT_VERSION: + if not check_install_nasm("2.15.05"): + raise ValueError("Can not find/install `nasm` with version >=2.15.05") + build_lib_linux(LIBX265_URL, "x265") + else: + print("x265 already installed.") + if not is_library_installed("aom"): + if not PH_LIGHT_VERSION: + if not check_install_nasm("2.15.05"): + raise ValueError("Can not find/install `nasm` with version >=2.15.05") + build_lib_linux(LIBAOM_URL, "aom") + else: + print("aom already installed.") + if not is_library_installed("libde265") and not is_library_installed("de265"): + build_lib_linux(LIBDE265_URL, "libde265") + else: + print("libde265 already installed.") build_lib_linux(LIBHEIF_URL, "libheif") finally: chdir(_original_dir)