From 8d8df3626000f6269cb4c784c7b1f09e8db85ccf Mon Sep 17 00:00:00 2001 From: Pete Bachant Date: Mon, 15 Jun 2026 08:00:13 -0700 Subject: [PATCH] Update to allow running TeX/matplotlib Docker env on arm64 --- .Dockerfile | 36 +++++++++++++++++++++++++++++---- analysis/environment-branch.yml | 6 ++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/.Dockerfile b/.Dockerfile index 46e4e78..9588118 100644 --- a/.Dockerfile +++ b/.Dockerfile @@ -13,9 +13,37 @@ COPY README.md /tmp/README.md COPY LICENSE /tmp/LICENSE COPY CITATION.cff /tmp/CITATION.cff -RUN mamba env create \ - -n openflash.openflash-on-branch-tex \ - -f /tmp/analysis/environment-branch.yml +# Build the Conda environment in three phases to work around the absence of +# libquadmath on aarch64: no native libquadmath package exists for arm64, yet +# gfortran still emits -lquadmath, which breaks capytaine's from-source build +# (capytaine ships no arm64 wheel). +# +# 1. Create the environment with the Conda packages only (strip the pip +# section), which installs the compiler toolchain. +RUN sed '/^[[:space:]]*- pip:/,$d' /tmp/analysis/environment-branch.yml \ + > /tmp/analysis/environment-nopip.yml \ + && mamba env create \ + -n openflash.openflash-on-branch-tex \ + -f /tmp/analysis/environment-nopip.yml + +# 2. If libquadmath is missing (i.e. on aarch64), drop an empty stub into the +# env so the linker is satisfied. capytaine references no quadmath symbols, +# and Conda links extensions with an rpath to $CONDA_PREFIX/lib, so the stub +# resolves at both link and run time. +RUN mamba run -n openflash.openflash-on-branch-tex bash -c '\ + if [ ! -e "$CONDA_PREFIX/lib/libquadmath.so" ]; then \ + echo "void __quadmath_stub(void){}" > /tmp/quadmath_stub.c \ + && "$CC" -shared -fPIC -Wl,-soname,libquadmath.so.0 \ + -o "$CONDA_PREFIX/lib/libquadmath.so.0" /tmp/quadmath_stub.c \ + && ln -sf libquadmath.so.0 "$CONDA_PREFIX/lib/libquadmath.so" \ + && rm /tmp/quadmath_stub.c; \ + fi' + +# 3. Install the pip packages; capytaine compiles its Fortran extension against +# the stub. +RUN mamba env update \ + -n openflash.openflash-on-branch-tex \ + -f /tmp/analysis/environment-branch.yml ENV PATH=/opt/conda/envs/openflash.openflash-on-branch-tex/bin:$PATH @@ -48,4 +76,4 @@ ENV XDG_CONFIG_HOME=/tmp/home/.config ENV MPLCONFIGDIR=/tmp/matplotlib ENV JUPYTER_DATA_DIR=/tmp/jupyter -CMD ["bash"] \ No newline at end of file +CMD ["bash"] diff --git a/analysis/environment-branch.yml b/analysis/environment-branch.yml index 6a0f2b9..31a50ac 100644 --- a/analysis/environment-branch.yml +++ b/analysis/environment-branch.yml @@ -15,6 +15,12 @@ dependencies: - streamlit - ipykernel - seaborn + # Compiler toolchain so pip can build capytaine's Fortran extension from + # source (no prebuilt arm64 wheel exists). Sets CC/FC during env activation. + # Note: on aarch64 these don't provide libquadmath, which gfortran still + # links against; .Dockerfile supplies an empty stub to satisfy the linker. + - c-compiler + - fortran-compiler - pip: - capytaine - -e ..