Skip to content

Commit

Permalink
Set min version of GCC everywhere
Browse files Browse the repository at this point in the history
Also unify arches in CI
  • Loading branch information
JCGoran committed Jan 13, 2025
1 parent c7ae29e commit 2571c65
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
11 changes: 11 additions & 0 deletions packaging/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion packaging/python/build_wheels.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
19 changes: 6 additions & 13 deletions packaging/python/test_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions share/lib/python/scripts/_binwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2571c65

Please sign in to comment.