Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions .Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -48,4 +76,4 @@ ENV XDG_CONFIG_HOME=/tmp/home/.config
ENV MPLCONFIGDIR=/tmp/matplotlib
ENV JUPYTER_DATA_DIR=/tmp/jupyter

CMD ["bash"]
CMD ["bash"]
6 changes: 6 additions & 0 deletions analysis/environment-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
Loading