diff --git a/packaging/python/build_wheels.bash b/packaging/python/build_wheels.bash index a791d2eca5..dd8b6592f1 100755 --- a/packaging/python/build_wheels.bash +++ b/packaging/python/build_wheels.bash @@ -60,7 +60,7 @@ pip_numpy_install() { # older version for apple m1 as building from source fails if [[ `uname -m` == 'arm64' ]]; then - numpy_ver="numpy==1.21.3" + numpy_ver="numpy==1.23.5" fi echo " - pip install $numpy_ver" @@ -168,6 +168,9 @@ build_wheel_osx() { echo " - Python installation is universal2 and we are on arm64, setting _PYTHON_HOST_PLATFORM to: ${_PYTHON_HOST_PLATFORM}" export ARCHFLAGS="-arch arm64" echo " - Setting ARCHFLAGS to: ${ARCHFLAGS}" + # This is a shortcut to have a successful delocate-wheel. See: + # https://github.com/matthew-brett/delocate/issues/153 + python -c "import os,delocate; print(os.path.join(os.path.dirname(delocate.__file__), 'tools.py'));quit()" | xargs -I{} sed -i."" "s/first, /input.pop('i386',None); first, /g" {} else export _PYTHON_HOST_PLATFORM="${py_platform/universal2/x86_64}" echo " - Python installation is universal2 and we are on x84_64, setting _PYTHON_HOST_PLATFORM to: ${_PYTHON_HOST_PLATFORM}" diff --git a/setup.py b/setup.py index d90e512516..7b7180f9de 100644 --- a/setup.py +++ b/setup.py @@ -174,7 +174,22 @@ def run(self, *args, **kw): the CMake building, sets the extension build environment and collects files. """ for ext in self.extensions: - + if ext.name == "neuronmusic" and not just_extensions: + # Since MUSIC is not a CMakeAugmentedExtension, we need to add the include_dirs manually + # Of interest are the include_dirs for the MPI library and the CMAKE_PREFIX_PATH + if self.cmake_prefix: + ext.include_dirs += [ + os.path.join(inc_dir, "include") + for inc_dir in self.cmake_prefix.split(";") + ] + # Look for NRN_MPI_DYNAMIC in cmake_defs, split it and add to include_dirs + if self.cmake_defs: + for cmake_def in self.cmake_defs.split(","): + if cmake_def.startswith("NRN_MPI_DYNAMIC"): + ext.include_dirs += cmake_def.split("=")[1].split(";") + break + + continue if isinstance(ext, CMakeAugmentedExtension): if ext.cmake_done: continue @@ -382,7 +397,9 @@ def setup_package(): "neuron.rxd", "neuron.crxd", "neuron.gui2", - ] + (["neuron.rxd.geometry3d"] if Components.RX3D else []) + ] + py_packages += ["neuron.rxd.geometry3d"] if Components.RX3D else [] + #py_packages += ["neuronmusic"] if Components.MUSIC else [] REL_RPATH = "@loader_path" if sys.platform[:6] == "darwin" else "$ORIGIN" @@ -407,6 +424,8 @@ def setup_package(): # Get extra_compile_args and extra_link_args from environment variable extra_link_args = os.environ.get("LDFLAGS", "").split() extra_compile_args = os.environ.get("CFLAGS", "").split() + logging.info("CFLAGS %s" % str(extra_compile_args)) + logging.info("LDFLAGS %s" % str(extra_link_args)) extensions = [ CMakeAugmentedExtension( @@ -456,12 +475,21 @@ def setup_package(): ] if Components.MUSIC: + music_libraries = ["nrniv"] + if not just_extensions: + music_libraries.append("nrnmusic") extensions += [ CyExtension( "neuronmusic", ["src/neuronmusic/neuronmusic.pyx"], + libraries=music_libraries, + library_dirs=[os.path.join(cmake_build_dir, "lib")], include_dirs=["src/nrnpython", "src/nrnmusic"], - **extension_common_params, + language="c++", + extra_link_args=extra_link_args + + ["-Wl,-rpath,{}{}".format(REL_RPATH, "/neuron/.data/lib/")] + if not just_extensions + else [], ) ] diff --git a/src/neuronmusic/setup.py.in b/src/neuronmusic/setup.py.in deleted file mode 100644 index 94699fcad2..0000000000 --- a/src/neuronmusic/setup.py.in +++ /dev/null @@ -1,40 +0,0 @@ -#setup.py for neuronmusic extension -from setuptools import setup, Extension - -nrn_srcdir = "@NRN_SRCDIR@" -instdir = "@prefix@" -if nrn_srcdir[0] != '/' : - nrn_srcdir = '../../' + nrn_srcdir - -mpicc_bin = "@CC@" -mpicxx_bin = "@CXX@" -import os -os.environ["CC"]=mpicc_bin -os.environ["CXX"]=mpicxx_bin - -include_dirs = ['@MUSIC_INCDIR@', nrn_srcdir+'/src/neuronmusic', nrn_srcdir + '/src/nrnpython', '.'] + '@MPI_INCLUDE_PATH@'.split(';') -libdirs = ['@MUSIC_LIBDIR@', @NRN_LIBDIR@] - - - -# as neuronmusic module will be built during make, add build/lib -# directory for linking. Note that build/lib shouldn't be -# added to rpath to avoid issues with dlopen. -libdirs.append("@CMAKE_BINARY_DIR@/lib") - -nrnmusic_lib = [@NRNMUSIC_DYNAM_LIB@] - -neuronmusic_module = Extension( - 'neuronmusic', - ['neuronmusic.cpp'], - library_dirs = libdirs, - libraries = ['nrniv'] + nrnmusic_lib, - runtime_library_dirs = [@NRN_LIBDIR@], - include_dirs = include_dirs -) - -setup(name="neuronmusic", version=@PACKAGE_VERSION@, - description = "NEURON+MUSIC python interface", - package_dir = {'':instdir+'/share/nrn/lib/python'}, - ext_modules=[neuronmusic_module] -) diff --git a/src/nrniv/CMakeLists.txt b/src/nrniv/CMakeLists.txt index f03c95a470..709d4740ea 100644 --- a/src/nrniv/CMakeLists.txt +++ b/src/nrniv/CMakeLists.txt @@ -458,9 +458,6 @@ if(NRN_ENABLE_MPI) if(NRN_ENABLE_MUSIC) # libnrnmusic does not depend explicitly on MPI so don't need mpi version specific versions. set(libnrnmusic "nrnmusic") - set(NRNMUSIC_DYNAM_LIB - "'${libnrnmusic}'" - PARENT_SCOPE) add_library(${libnrnmusic}_lib SHARED ${NRN_MUSIC_SRC_FILES}) target_include_directories(${libnrnmusic}_lib BEFORE PUBLIC ${include}) add_dependencies(${libnrnmusic}_lib nrniv_lib ${libname}_lib) diff --git a/test/music_tests/runtests.py b/test/music_tests/runtests.py index 35d5df3802..231882f36c 100644 --- a/test/music_tests/runtests.py +++ b/test/music_tests/runtests.py @@ -25,6 +25,7 @@ def run(cmd): result = subprocess.run(cmd, shell=True, env=my_env, capture_output=True, text=True) if result.returncode != 0: print(result.stderr) + print(result.stdout) result.check_returncode() return result