Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile nrnpython on its own #2875

Merged
merged 11 commits into from
May 14, 2024
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
16 changes: 0 additions & 16 deletions cmake/NeuronFileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,6 @@ set(SCOPMATH_FILES_LIST

set(NRNMPI_FILES_LIST nrnmpi.cpp memory_usage.cpp bbsmpipack.cpp mpispike.cpp)

# nrnpython sources (only if ${NRN_ENABLE_PYTHON_DYNAMIC} is OFF}
set(NRNPYTHON_FILES_LIST
nrnpython.cpp
nrnpy_hoc.cpp
nrnpy_nrn.cpp
nrnpy_p2h.cpp
grids.cpp
rxd.cpp
rxd_extracellular.cpp
rxd_intracellular.cpp
rxd_vol.cpp
rxd_marching_cubes.cpp
rxd_llgramarea.cpp)

# built-in mod files
set(MODFILE_BASE_NAMES
apcount
Expand Down Expand Up @@ -471,8 +457,6 @@ nrn_create_file_list(NRN_SPARSE_SRC_FILES ${PROJECT_SOURCE_DIR}/src/sparse ${SPA
nrn_create_file_list(NRN_SCOPMATH_SRC_FILES ${PROJECT_SOURCE_DIR}/src/scopmath
${SCOPMATH_FILES_LIST})
nrn_create_file_list(NRN_NRNMPI_SRC_FILES ${PROJECT_SOURCE_DIR}/src/nrnmpi ${NRNMPI_FILES_LIST})
nrn_create_file_list(NRN_NRNPYTHON_SRC_FILES ${PROJECT_SOURCE_DIR}/src/nrnpython
${NRNPYTHON_FILES_LIST})
nrn_create_file_list(NRN_MODFILE_BASE_NAMES src/nrnoc ${MODFILE_BASE_NAMES})
nrn_create_file_list(NRN_BIN_SRC_FILES ${PROJECT_SOURCE_DIR}/src/ivoc/ nrnmain.cpp)
nrn_create_file_list(NRN_BIN_SRC_FILES ${PROJECT_SOURCE_DIR}/src/oc/ ockludge.cpp modlreg.cpp)
Expand Down
14 changes: 2 additions & 12 deletions src/nrniv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,6 @@ if(MINGW)
list(APPEND NRN_NRNIV_LIB_SRC_FILES ${PROJECT_SOURCE_DIR}/src/mswin/dlfcn.c)
endif()

# NRN_ENABLE_MODULE_INSTALL will create a separate nrnpython lib
if(NRN_ENABLE_PYTHON AND NOT NRN_ENABLE_PYTHON_DYNAMIC)
# Include nrnpython in nrniv - useful for single lib neuron and wheels
list(APPEND NRN_NRNIV_LIB_SRC_FILES ${NRN_NRNPYTHON_SRC_FILES})
endif()

if(NOT NRN_ENABLE_INTERVIEWS)
list(APPEND NRN_NRNIV_LIB_SRC_FILES ${NRN_IVOS_SRC_FILES})
endif()
Expand Down Expand Up @@ -412,7 +406,7 @@ cpp_cc_configure_sanitizers(TARGET nrniv_lib)
# Source-directory .cpp needs to find generated .hpp.
target_include_directories(nrniv_lib PUBLIC "${NRN_OC_GEN}")
if(NRN_ENABLE_PYTHON AND NOT NRN_ENABLE_PYTHON_DYNAMIC)
target_include_directories(nrniv_lib PUBLIC "${NRN_DEFAULT_PYTHON_INCLUDES}")
target_link_libraries(nrniv_lib nrnpython)
endif()
if(NRN_ENABLE_THREADS)
target_link_libraries(nrniv_lib Threads::Threads)
Expand Down Expand Up @@ -453,10 +447,6 @@ endif()
# =============================================================================
# Link with all libraries
# =============================================================================
if(NRN_ENABLE_PYTHON AND NOT NRN_ENABLE_PYTHON_DYNAMIC)
target_link_libraries(nrniv_lib ${NRN_DEFAULT_PYTHON_LIBRARIES})
endif()

if(NRN_ENABLE_MPI)
if(NRN_ENABLE_MPI_DYNAMIC)
list(LENGTH NRN_MPI_LIBNAME_LIST _num_mpi)
Expand Down Expand Up @@ -499,7 +489,7 @@ if(NRN_ENABLE_INTERVIEWS)
include_directories(${IV_INCLUDE_DIR})
target_link_libraries(nrniv_lib interviews)
else()
target_include_directories(nrniv_lib PUBLIC ${NRN_IVOS_SRC_DIR} ${PROJECT_BINARY_DIR}/src/ivos)
target_include_directories(nrniv_lib PUBLIC ${NRN_IVOS_SRC_DIR})
endif()

if(IV_ENABLE_X11_DYNAMIC)
Expand Down
56 changes: 38 additions & 18 deletions src/nrnpython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,41 @@ install(TARGETS rxdmath DESTINATION ${NRN_INSTALL_SHARE_LIB_DIR})
# =============================================================================
set(nrnpython_lib_list)

set(NRNPYTHON_FILES_LIST
alkino marked this conversation as resolved.
Show resolved Hide resolved
nrnpython.cpp
nrnpy_hoc.cpp
nrnpy_nrn.cpp
nrnpy_p2h.cpp
grids.cpp
rxd.cpp
rxd_extracellular.cpp
rxd_intracellular.cpp
rxd_vol.cpp
rxd_marching_cubes.cpp
rxd_llgramarea.cpp)
ferdonline marked this conversation as resolved.
Show resolved Hide resolved

set(INCLUDE_DIRS
..
../oc
../nrnoc
../ivoc
../nrniv
../nrnmpi
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_BINARY_DIR}/src/oc)
if(NRN_ENABLE_INTERVIEWS)
list(APPEND INCLUDE_DIRS ${IV_INCLUDE_DIR})
else()
list(APPEND INCLUDE_DIRS ../ivos)
endif()

# user has selected dynamic python support (could be multiple versions)
if(NRN_ENABLE_PYTHON_DYNAMIC)
set(INCLUDE_DIRS
.
..
../oc
../nrnoc
../ivoc
../nrniv
../gnu
../nrnmpi
${PROJECT_BINARY_DIR}/src/nrnpython
${PROJECT_BINARY_DIR}/src/ivos
${PROJECT_BINARY_DIR}/src/oc)
if(NRN_ENABLE_INTERVIEWS)
list(APPEND INCLUDE_DIRS ${IV_INCLUDE_DIR})
else()
list(APPEND INCLUDE_DIRS ../ivos)
endif()
foreach(val RANGE ${NRN_PYTHON_ITERATION_LIMIT})
list(GET NRN_PYTHON_VERSIONS ${val} pyver)
list(GET NRN_PYTHON_INCLUDES ${val} pyinc)
list(GET NRN_PYTHON_LIBRARIES ${val} pylib)
add_library(nrnpython${pyver} SHARED ${NRN_NRNPYTHON_SRC_FILES})
add_library(nrnpython${pyver} SHARED ${NRNPYTHON_FILES_LIST})
target_include_directories(nrnpython${pyver} BEFORE PUBLIC ${pyinc} ${INCLUDE_DIRS})
target_link_libraries(nrnpython${pyver} nrniv_lib ${Readline_LIBRARY})
if(NRN_LINK_AGAINST_PYTHON)
Expand All @@ -48,6 +59,15 @@ if(NRN_ENABLE_PYTHON_DYNAMIC)
list(APPEND nrnpython_lib_list nrnpython${pyver})
install(TARGETS nrnpython${pyver} DESTINATION ${NRN_INSTALL_SHARE_LIB_DIR})
endforeach()
else()
add_library(nrnpython OBJECT ${NRNPYTHON_FILES_LIST})
add_dependencies(nrnpython generated_source_files)
set_property(TARGET nrnpython PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(nrnpython PUBLIC ${INCLUDE_DIRS})
target_include_directories(nrnpython PUBLIC "${NRN_DEFAULT_PYTHON_INCLUDES}")
target_link_libraries(nrnpython ${NRN_DEFAULT_PYTHON_LIBRARIES})
target_include_directories(nrnpython PUBLIC ${PROJECT_SOURCE_DIR}/${NRN_3RDPARTY_DIR}/eigen)
target_include_directories(nrnpython PUBLIC ${PROJECT_BINARY_DIR}/src/nrniv/oc_generated)
endif()

configure_file(_config_params.py.in "${PROJECT_BINARY_DIR}/lib/python/neuron/_config_params.py"
Expand Down
2 changes: 1 addition & 1 deletion src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void add2topdict(PyObject*);
static const char* hocobj_docstring = "class neuron.hoc.HocObject - Hoc Object wrapper";

#if 1
#include <hoccontext.h>
#include "hoccontext.h"
#else
extern Object* hoc_thisobject;
#define HocTopContextSet \
Expand Down
4 changes: 2 additions & 2 deletions src/nrnpython/nrnpy_p2h.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <InterViews/resource.h>
#include <nrnoc2iv.h>
#include <classreg.h>
#include <nrnpython.h>
#include <hoccontext.h>
#include "nrnpython.h"
#include "hoccontext.h"
#include "nrnpy.h"
#include "nrnpy_utils.h"
#include "oc_ansi.h"
Expand Down
2 changes: 1 addition & 1 deletion src/nrnpython/nrnpy_utils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <nrnwrap_Python.h>
#include "nrnwrap_Python.h"
#include <cassert>

inline bool is_python_string(PyObject* python_string) {
Expand Down
6 changes: 3 additions & 3 deletions src/nrnpython/nrnpython.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <nrnpython.h>
#include <nrnpy_utils.h>
#include "nrnpython.h"
#include "nrnpy_utils.h"
#include "oc_ansi.h"
#include <stdio.h>
#include <InterViews/resource.h>
#if HAVE_IV
#include <InterViews/session.h>
#endif
#include <nrnoc2iv.h>
#include <hoccontext.h>
#include "hoccontext.h"
#include <ocfile.h> // bool isDirExist(const std::string& path);

#include <hocstr.h>
Expand Down Expand Up @@ -193,7 +193,7 @@
if (b == 1 && !started) {
p_nrnpy_pyrun = nrnpy_pyrun;
if (nrnpy_nositeflag) {
Py_NoSiteFlag = 1;

Check warning on line 196 in src/nrnpython/nrnpython.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04 - cmake (-DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNMODL_SANITIZERS=undefinedundefined)

'Py_NoSiteFlag' is deprecated [-Wdeprecated-declarations]
}
// Create a Python configuration, see
// https://docs.python.org/3.8/c-api/init_config.html#python-configuration, so that
Expand Down
2 changes: 1 addition & 1 deletion src/nrnpython/nrnpython.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#if defined(USE_PYTHON)
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include <nrnwrap_Python.h>
#include "nrnwrap_Python.h"

#endif /*USE_PYTHON*/

Expand Down
4 changes: 2 additions & 2 deletions src/nrnpython/rxd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <../nrnoc/section.h>
#include <../nrnoc/nrn_ansi.h>
#include <../nrnoc/multicore.h>
#include <nrnwrap_Python.h>
#include <nrnpython.h>
#include "nrnwrap_Python.h"
#include "nrnpython.h"

#include <thread>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion src/nrnpython/rxd_extracellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string.h>
#include "grids.h"
#include "rxd.h"
#include <nrnwrap_Python.h>
#include "nrnwrap_Python.h"
#include <cmath>
#include <ocmatrix.h>
#include <cfloat>
Expand Down
2 changes: 1 addition & 1 deletion src/nrnpython/rxd_intracellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string.h>
#include "grids.h"
#include "rxd.h"
#include <nrnwrap_Python.h>
#include "nrnwrap_Python.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/nrnpython/rxd_vol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <assert.h>
#include "grids.h"
#include "rxd.h"
#include <nrnwrap_Python.h>
#include "nrnwrap_Python.h"

/*Tortuous diffusion coefficients*/
#define DcX(x, y, z) (g->dc_x * PERM(x, y, z))
Expand Down
Loading