From 9500741d61fa0bdcbf185a2c877093b693910542 Mon Sep 17 00:00:00 2001 From: JCGoran Date: Wed, 8 Jan 2025 16:24:50 +0100 Subject: [PATCH] Build Cython extensions out-of-source (#3302) Also remove unused setup.py.in --- setup.py | 10 ++++++++-- src/neuronmusic/setup.py.in | 40 ------------------------------------- 2 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 src/neuronmusic/setup.py.in diff --git a/setup.py b/setup.py index 25c3fabc2a..2fe0df68ad 100644 --- a/setup.py +++ b/setup.py @@ -435,7 +435,7 @@ def setup_package(): ] if Components.MUSIC: - extensions += [ + music_extensions = [ CyExtension( "neuronmusic", ["src/neuronmusic/neuronmusic.pyx"], @@ -444,6 +444,9 @@ def setup_package(): **extension_common_params, ) ] + for ext in music_extensions: + ext.cython_c_in_temp = True + extensions.append(ext) if Components.RX3D: include_dirs = ["share/lib/python/neuron/rxd/geometry3d", numpy.get_include()] @@ -467,7 +470,7 @@ def setup_package(): logging.info("RX3D compile flags %s" % str(rxd_params)) - extensions += [ + rxd_extensions = [ CyExtension( "neuron.rxd.geometry3d.graphicsPrimitives", ["share/lib/python/neuron/rxd/geometry3d/graphicsPrimitives.pyx"], @@ -490,6 +493,9 @@ def setup_package(): **rxd_params, ), ] + for ext in rxd_extensions: + ext.cython_c_in_temp = True + extensions.append(ext) logging.info("RX3D is %s", "ENABLED" if Components.RX3D else "DISABLED") 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] -)