diff --git a/packaging/python/Dockerfile b/packaging/python/Dockerfile index 80cff2b56c..10204232d3 100644 --- a/packaging/python/Dockerfile +++ b/packaging/python/Dockerfile @@ -3,6 +3,17 @@ ARG MANYLINUX_IMAGE=manylinux_2_28_x86_64 FROM quay.io/pypa/$MANYLINUX_IMAGE LABEL authors="Pramod Kumbhar, Fernando Pereira, Alexandru Savulescu, Goran Jelic-Cizmek" +# problem: libstdc++ is _not_ forwards compatible, so if we try to compile mod +# files on a system that ships a version of it older than the one used for +# building the wheel itself, we'll get linker errors. +# solution: use a well-defined oldest-supported version of GCC +# we need to do this _before_ building any libraries from source +ARG OLDEST_SUPPORTED_GCC_VERSION=10 +RUN yum install -y gcc-toolset-${OLDEST_SUPPORTED_GCC_VERSION}-gcc gcc-toolset-${OLDEST_SUPPORTED_GCC_VERSION}-gcc-c++ +ENV PATH /opt/rh/gcc-toolset-${OLDEST_SUPPORTED_GCC_VERSION}/root/usr/bin:$PATH +ENV LD_LIBRARY_PATH=/opt/rh/gcc-toolset-${OLDEST_SUPPORTED_GCC_VERSION}/root/usr/lib64:/opt/rh/gcc-toolset-${OLDEST_SUPPORTED_GCC_VERSION}/root/usr/lib:/opt/rh/gcc-toolset-${OLDEST_SUPPORTED_GCC_VERSION}/root/usr/lib64/dyninst:/opt/rh/gcc-toolset-${OLDEST_SUPPORTED_GCC_VERSION}/root/usr/lib/dyninst +ENV DEVTOOLSET_ROOTPATH=/opt/rh/gcc-toolset-${OLDEST_SUPPORTED_GCC_VERSION}/root + RUN gcc --version && python3 --version # install basic packages diff --git a/packaging/python/build_wheels.bash b/packaging/python/build_wheels.bash index 564eb9f49a..cbf62ffccf 100755 --- a/packaging/python/build_wheels.bash +++ b/packaging/python/build_wheels.bash @@ -221,7 +221,9 @@ case "$1" in MPI_INCLUDE_HEADERS="${BREW_PREFIX}/opt/openmpi/include;${BREW_PREFIX}/opt/mpich/include" build_wheel_osx $(which python3) "$coreneuron" "$MPI_INCLUDE_HEADERS" else - MPI_INCLUDE_HEADERS="/usr/include/openmpi-$(uname -m);/usr/include/mpich-$(uname -m)" + # first two are for AlmaLinux 8 (default for manylinux_2_28); + # second two are for Debian/Ubuntu derivatives + MPI_INCLUDE_HEADERS="/usr/include/openmpi-$(uname -m);/usr/include/mpich-$(uname -m);/usr/lib/$(uname -m)-linux-gnu/openmpi/include;/usr/include/$(uname -m)-linux-gnu/mpich" build_wheel_linux $(which python3) "$coreneuron" "$MPI_INCLUDE_HEADERS" fi ls wheelhouse/ diff --git a/packaging/python/test_wheels.sh b/packaging/python/test_wheels.sh index 66d3f27009..a53dfce3f2 100755 --- a/packaging/python/test_wheels.sh +++ b/packaging/python/test_wheels.sh @@ -5,7 +5,7 @@ set -xe # See CMake's CMAKE_HOST_SYSTEM_PROCESSOR documentation # On the systems where we are building wheel we can rely # on uname -m. Note that this is just wheel testing script. -ARCH_DIR=`uname -m` +ARCH_DIR="$(uname -m)" if [ ! -f setup.py ]; then echo "Error: Please launch $0 from the root dir" @@ -175,23 +175,16 @@ run_parallel_test() { export DYLD_LIBRARY_PATH=${BREW_PREFIX}/opt/open-mpi/lib:$DYLD_LIBRARY_PATH run_mpi_test "${BREW_PREFIX}/opt/open-mpi/bin/mpirun" "OpenMPI" "" - # CI Linux or Azure Linux - elif [[ "$CI_OS_NAME" == "linux" || "$AGENT_OS" == "Linux" ]]; then + # CI Linux or Azure Linux or circleCI build (all on Debian/Ubuntu) + elif [[ "$CI_OS_NAME" == "linux" || "$AGENT_OS" == "Linux" || "$CIRCLECI" == "true" ]]; then # make debugging easier sudo update-alternatives --get-selections | grep mpi - sudo update-alternatives --list mpi-x86_64-linux-gnu + sudo update-alternatives --list mpi-${ARCH_DIR}-linux-gnu # choose mpich - sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich + sudo update-alternatives --set mpi-${ARCH_DIR}-linux-gnu /usr/include/${ARCH_DIR}-linux-gnu/mpich run_mpi_test "mpirun.mpich" "MPICH" "" # choose openmpi - sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/openmpi/include - run_mpi_test "mpirun.openmpi" "OpenMPI" "" - - # circle-ci build - elif [[ "$CIRCLECI" == "true" ]]; then - sudo update-alternatives --set mpi-aarch64-linux-gnu /usr/include/aarch64-linux-gnu/mpich - run_mpi_test "mpirun.mpich" "MPICH" "" - sudo update-alternatives --set mpi-aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/openmpi/include + sudo update-alternatives --set mpi-${ARCH_DIR}-linux-gnu /usr/lib/${ARCH_DIR}-linux-gnu/openmpi/include run_mpi_test "mpirun.openmpi" "OpenMPI" "" # linux desktop or docker container used for wheel diff --git a/share/lib/python/scripts/_binwrapper.py b/share/lib/python/scripts/_binwrapper.py index 1fb7e417ab..906522a376 100755 --- a/share/lib/python/scripts/_binwrapper.py +++ b/share/lib/python/scripts/_binwrapper.py @@ -7,6 +7,7 @@ import shutil import subprocess import sys +import warnings from importlib.metadata import metadata, PackageNotFoundError from importlib.util import find_spec from pathlib import Path @@ -44,8 +45,8 @@ def _set_default_compiler(): os.environ.setdefault("CXX", ccompiler.compiler_cxx[0]) -def _check_cpp_compiler_version(): - """Check if GCC compiler is >= 9.0 otherwise show warning""" +def _check_cpp_compiler_version(min_version: str): + """Check if GCC compiler is >= min supported one, otherwise show warning""" try: cpp_compiler = os.environ.get("CXX", "") version = subprocess.run( @@ -55,10 +56,9 @@ def _check_cpp_compiler_version(): version = subprocess.run( [cpp_compiler, "-dumpversion"], stdout=subprocess.PIPE ).stdout.decode("utf-8") - if Version(version) <= Version("9.0"): - print( - "Warning: GCC >= 9.0 is required with this version of NEURON but found", - version, + if Version(version) <= Version(min_version): + warnings.warn( + f"Warning: GCC >= {min_version} is required with this version of NEURON but found {version}", ) except: pass @@ -111,7 +111,7 @@ def _wrap_executable(output_name): if exe.endswith("nrnivmodl"): # To create a wrapper for special (so it also gets ENV vars) we intercept nrnivmodl - _check_cpp_compiler_version() + _check_cpp_compiler_version("10.0") subprocess.check_call([exe, *sys.argv[1:]]) _wrap_executable("special") sys.exit(0)