Skip to content
Draft
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ build/
_build/
install/
reports/
_skbuild/
*.egg-info/
wheelhouse/

# compilation artefacts
pynest/pynestkernel.cxx
Expand Down Expand Up @@ -33,11 +36,9 @@ CMakeDoxygenDefaults.cmake
# generated files
doc/fulldoc.conf
doc/normaldoc.conf
bin/nest-config
bin/nest_vars.sh
libnestutil/config.h
nest/static_modules.h
pynest/setup.py

# installation artefacts
install_manifest.txt
Expand Down
13 changes: 0 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ endif ()
################## Summary of flags ##################
################################################################################

# used in nest-config

# all compiler flags
if ( NOT CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "None" )
set( ALL_CFLAGS "${CMAKE_C_FLAGS}" )
Expand Down Expand Up @@ -320,11 +318,6 @@ configure_file(
"${PROJECT_BINARY_DIR}/libnestutil/config.h" @ONLY
)

configure_file(
"${PROJECT_SOURCE_DIR}/pynest/setup.py.in"
"${PROJECT_BINARY_DIR}/pynest/setup.py" @ONLY
)

configure_file(
"${PROJECT_SOURCE_DIR}/bin/nest-config.in"
"${PROJECT_BINARY_DIR}/bin/nest-config" @ONLY
Expand All @@ -345,12 +338,6 @@ configure_file(
"${PROJECT_BINARY_DIR}/doc/fulldoc.conf" @ONLY
)

configure_file(
"${PROJECT_SOURCE_DIR}/pynest/nest/versionchecker.py.in"
"${PROJECT_BINARY_DIR}/pynest/nest/versionchecker.py" @ONLY
)


################################################################################
################## Install Extra Files ##################
################################################################################
Expand Down
1 change: 0 additions & 1 deletion bin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
install( PROGRAMS
nest-server
nest-server-mpi
${PROJECT_BINARY_DIR}/bin/nest-config
${PROJECT_BINARY_DIR}/bin/nest_vars.sh
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
6 changes: 4 additions & 2 deletions cmake/CheckExtraCompilerFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function( NEST_CHECK_EXITCODE_ABORT )
RESULT_VARIABLE RETURN_VALUE
ERROR_QUIET OUTPUT_QUIET
)
set( RETURN_VALUE 255 )
if ( NOT RETURN_VALUE EQUAL 0 )
set( ABORT_ERR ${RETURN_VALUE} )
endif ()
Expand All @@ -50,7 +51,7 @@ function( NEST_CHECK_EXITCODE_ABORT )
endif ()
endif ()
printInfo( "Check the abort exitcode. ${ABORT_ERR}" )
set( NEST_EXITCODE_ABORT ${ABORT_ERR} PARENT_SCOPE )
set( NEST_EXITCODE_ABORT 255 PARENT_SCOPE )
endfunction()

####### NEST_EXITCODE_SEGFAULT ########
Expand All @@ -70,6 +71,7 @@ function( NEST_CHECK_EXITCODE_SEGFAULT )
RESULT_VARIABLE RETURN_VALUE
ERROR_QUIET OUTPUT_QUIET
)
set( SEG_ERR 255 )
if ( NOT RETURN_VALUE EQUAL 0 )
set( SEG_ERR ${RETURN_VALUE} )
endif ()
Expand All @@ -78,7 +80,7 @@ function( NEST_CHECK_EXITCODE_SEGFAULT )
endif ()
endif ()
printInfo( "Check the segmentation fault exitcode. ${SEG_ERR}" )
set( NEST_EXITCODE_SEGFAULT ${SEG_ERR} PARENT_SCOPE )
set( NEST_EXITCODE_SEGFAULT 255 PARENT_SCOPE )
endfunction()

####### HAVE_CMATH_MAKROS_IGNORED ########
Expand Down
110 changes: 63 additions & 47 deletions cmake/FindCython.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Find the Cython compiler.
#.rst:
#
# This code sets the following variables:
# Find ``cython`` executable.
#
# CYTHON_EXECUTABLE
# This module will set the following variables in your project:
#
# ``CYTHON_EXECUTABLE``
# path to the ``cython`` program
#
# ``CYTHON_VERSION``
# version of ``cython``
#
# ``CYTHON_FOUND``
# true if the program was found
#
# For more information on the Cython project, see https://cython.org/.
#
# *Cython is a language that makes writing C extensions for the Python language
# as easy as Python itself.*
#
# See also UseCython.cmake

#=============================================================================
# Copyright 2011 Kitware, Inc.
#
Expand All @@ -22,51 +34,55 @@
# limitations under the License.
#=============================================================================

# Modifications copyright (C) 2004 The NEST Initiative

# Using the Cython executable that lives next to the Python executable
# Use the Cython executable that lives next to the Python executable
# if it is a local installation.
if ( Python_FOUND )
get_filename_component( _python_path ${Python_EXECUTABLE} PATH )
find_program( CYTHON_EXECUTABLE
NAMES cython cython.bat cython3
HINTS ${_python_path}
)
else ()
find_program( CYTHON_EXECUTABLE
NAMES cython cython.bat cython3
)
endif ()
if(Python_EXECUTABLE)
get_filename_component(_python_path ${Python_EXECUTABLE} PATH)
elseif(Python3_EXECUTABLE)
get_filename_component(_python_path ${Python3_EXECUTABLE} PATH)
elseif(DEFINED PYTHON_EXECUTABLE)
get_filename_component(_python_path ${PYTHON_EXECUTABLE} PATH)
endif()

if(DEFINED _python_path)
find_program(CYTHON_EXECUTABLE
NAMES cython cython.bat cython3
HINTS ${_python_path}
DOC "path to the cython executable")
else()
find_program(CYTHON_EXECUTABLE
NAMES cython cython.bat cython3
DOC "path to the cython executable")
endif()

if(CYTHON_EXECUTABLE)
set(CYTHON_version_command ${CYTHON_EXECUTABLE} --version)

execute_process(COMMAND ${CYTHON_version_command}
OUTPUT_VARIABLE CYTHON_version_output
ERROR_VARIABLE CYTHON_version_error
RESULT_VARIABLE CYTHON_version_result
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)

if ( NOT CYTHON_EXECUTABLE STREQUAL "CYTHON_EXECUTABLE-NOTFOUND" )
execute_process(
COMMAND ${CYTHON_EXECUTABLE} --version
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE CYTHON_VAR_OUTPUT
ERROR_VARIABLE CYTHON_ERR_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if ( RESULT EQUAL 0 )
if ( "${CYTHON_VAR_OUTPUT}" STREQUAL "" )
# In cython v0.29.3 the version string is written to stderr and not to stdout, as one would expect.
set( CYTHON_VAR_OUTPUT "${CYTHON_ERR_OUTPUT}" )
if(NOT ${CYTHON_version_result} EQUAL 0)
set(_error_msg "Command \"${CYTHON_version_command}\" failed with")
set(_error_msg "${_error_msg} output:\n${CYTHON_version_error}")
message(SEND_ERROR "${_error_msg}")
else()
if("${CYTHON_version_output}" MATCHES "^[Cc]ython version ([^,]+)")
set(CYTHON_VERSION "${CMAKE_MATCH_1}")
else()
if("${CYTHON_version_error}" MATCHES "^[Cc]ython version ([^,]+)")
set(CYTHON_VERSION "${CMAKE_MATCH_1}")
endif()
endif()
string( REGEX REPLACE ".* ([0-9]+\\.[0-9]+(\\.[0-9]+)?).*" "\\1"
CYTHON_VERSION "${CYTHON_VAR_OUTPUT}" )
else ()
printError( "Cython error: ${CYTHON_ERR_OUTPUT}\nat ${CYTHON_EXECUTABLE}")
endif ()
endif()
endif()

endif ()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cython REQUIRED_VARS CYTHON_EXECUTABLE)

include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( Cython
FOUND_VAR
CYTHON_FOUND
REQUIRED_VARS
CYTHON_EXECUTABLE
VERSION_VAR
CYTHON_VERSION
)
mark_as_advanced(CYTHON_EXECUTABLE)

mark_as_advanced( CYTHON_EXECUTABLE )
include(UseCython)
104 changes: 62 additions & 42 deletions cmake/ProcessOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,21 @@ function( NEST_PROCESS_STATIC_LIBRARIES )
"@loader_path/../../../nest"
PARENT_SCOPE )
else ()
message( STATUS "Looking for libs in install prefix: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/nest")
message( STATUS "Looking for libs in relfolder: \$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}/nest")

set( CMAKE_INSTALL_RPATH
# for binaries
"\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}/nest"
# for libraries (except pynestkernel)
"\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}/nest"
# for pynestkernel: origin at <prefix>/lib/python3.x/site-packages/nest
# for wheel pynestkernel: origin at <prefix>/lib/python3.x/site-packages/nest
# On the target machine, the libs are installed in these 2 locations:
"\$ORIGIN/../../../nest"
"\$ORIGIN/../nest_simulator.libs"
# During wheel building, the libs are found here:
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/nest"
"\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}/nest"
PARENT_SCOPE )
endif ()

Expand Down Expand Up @@ -356,67 +364,79 @@ function( NEST_PROCESS_WITH_GSL )
endfunction()

function( NEST_PROCESS_WITH_PYTHON )
# Find Python
set( HAVE_PYTHON OFF PARENT_SCOPE )

if ( ${with-python} STREQUAL "ON" )

# Localize the Python interpreter and ABI
if ( ${with-python} STREQUAL "ON")
# Localize the Python interpreter and ABI, quietly.
find_package( Python 3.8 QUIET COMPONENTS Interpreter Development.Module )
if ( NOT Python_FOUND )
# Find the minimally required Python components, loudly,
find_package( Python 3.8 REQUIRED Interpreter Development )
# If that succeeds, still emit a warning that the other components weren't found.
string( CONCAT PYABI_WARN "Could not locate Python ABI"
", using shared libraries and header file instead."
" Please clear your CMake cache and build folder and verify that CMake"
" is up-to-date (3.18+)."
)
printWarning("${PYABI_WARN}")
else()
# If everything was found, repeat the quiet command, loudly, to show expected output.
find_package( Python 3.8 REQUIRED Interpreter Development.Module )
endif()

if ( Python_FOUND )
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
execute_process( COMMAND "${Python_EXECUTABLE}" "-c"
"import sys, os; print(int(bool(os.environ.get('CONDA_DEFAULT_ENV', False)) or (sys.prefix != sys.base_prefix)))"
OUTPUT_VARIABLE Python_InVirtualEnv OUTPUT_STRIP_TRAILING_WHITESPACE )

if ( NOT Python_InVirtualEnv AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
printError( "No virtual Python environment found and no installation prefix specified. "
"Please either build and install NEST in a virtual Python environment or specify CMake option -DCMAKE_INSTALL_PREFIX=<nest_install_dir>.")
endif()

# Setting CMAKE_INSTALL_PREFIX effects the inclusion of GNUInstallDirs defining CMAKE_INSTALL_<dir> and CMAKE_INSTALL_FULL_<dir>
get_filename_component( Python_EnvRoot "${Python_SITELIB}/../../.." ABSOLUTE)
set ( CMAKE_INSTALL_PREFIX "${Python_EnvRoot}" CACHE PATH "Default install prefix for the active Python interpreter" FORCE )
endif ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )

# export found variables to parent scope
set( HAVE_PYTHON ON PARENT_SCOPE )
set( Python_FOUND "${Python_FOUND}" PARENT_SCOPE )
set( Python_EXECUTABLE ${Python_EXECUTABLE} PARENT_SCOPE )
set( PYTHON ${Python_EXECUTABLE} PARENT_SCOPE )
set( Python_VERSION ${Python_VERSION} PARENT_SCOPE )
set( Python_VERSION_MAJOR ${Python_VERSION_MAJOR} PARENT_SCOPE )
set( Python_VERSION_MINOR ${Python_VERSION_MINOR} PARENT_SCOPE )
set( Python_INCLUDE_DIRS "${Python_INCLUDE_DIRS}" PARENT_SCOPE )
set( Python_LIBRARIES "${Python_LIBRARIES}" PARENT_SCOPE )

if ( cythonize-pynest )
# Need updated Cython because of a change in the C api in Python 3.7
find_package( Cython 0.28.3 REQUIRED )
if ( CYTHON_FOUND )
# export found variables to parent scope
set( CYTHON_FOUND "${CYTHON_FOUND}" PARENT_SCOPE )
set( CYTHON_EXECUTABLE "${CYTHON_EXECUTABLE}" PARENT_SCOPE )
set( CYTHON_VERSION "${CYTHON_VERSION}" PARENT_SCOPE )
endif ()
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
execute_process( COMMAND "${Python_EXECUTABLE}" "-c"
"import sys, os; print(int(bool(os.environ.get('CONDA_DEFAULT_ENV', False)) or (sys.prefix != sys.base_prefix)))"
OUTPUT_VARIABLE Python_InVirtualEnv OUTPUT_STRIP_TRAILING_WHITESPACE )

if ( NOT Python_InVirtualEnv AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
printError(
"No virtual Python environment found and no installation prefix specified. "
"Please either build and install NEST in a virtual Python environment or "
"specify CMake option -DCMAKE_INSTALL_PREFIX=<nest_install_dir>, if you wish"
" to install NEST to a non-Python-default location.")
endif()

# Setting CMAKE_INSTALL_PREFIX effects the inclusion of GNUInstallDirs defining CMAKE_INSTALL_<dir> and CMAKE_INSTALL_FULL_<dir>
get_filename_component( Python_EnvRoot "${Python_SITELIB}/../../.." ABSOLUTE)
set ( CMAKE_INSTALL_PREFIX "${Python_EnvRoot}" CACHE PATH "Default install prefix for the active Python interpreter" FORCE )
endif ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )

# export found variables to parent scope
set( HAVE_PYTHON ON PARENT_SCOPE )
set( Python_FOUND "${Python_FOUND}" PARENT_SCOPE )
set( Python_EXECUTABLE ${Python_EXECUTABLE} PARENT_SCOPE )
set( PYTHON ${Python_EXECUTABLE} PARENT_SCOPE )
set( Python_VERSION ${Python_VERSION} PARENT_SCOPE )
set( Python_VERSION_MAJOR ${Python_VERSION_MAJOR} PARENT_SCOPE )
set( Python_VERSION_MINOR ${Python_VERSION_MINOR} PARENT_SCOPE )
set( Python_INCLUDE_DIRS "${Python_INCLUDE_DIRS}" PARENT_SCOPE )
set( Python_LIBRARIES "${Python_LIBRARIES}" PARENT_SCOPE )

if ( cythonize-pynest )
# Need updated Cython because of a change in the C api in Python 3.7
find_package( Cython 0.28.3 REQUIRED )
if ( CYTHON_FOUND )
# export found variables to parent scope
set( CYTHON_FOUND "${CYTHON_FOUND}" PARENT_SCOPE )
set( CYTHON_EXECUTABLE "${CYTHON_EXECUTABLE}" PARENT_SCOPE )
set( CYTHON_VERSION "${CYTHON_VERSION}" PARENT_SCOPE )
endif ()
endif ()

# Run a Python package installation through pip
if ( with-python-package )
# TODO: Add noop pip installation

# Enable the `nest.plot` dependencies
if (with-python-plot)
# TODO
endif()
endif()
elseif ( ${with-python} STREQUAL "OFF" )
else ()
printError( "Invalid value -Dwith-python=${with-python}, please use 'ON' or 'OFF'" )
endif ()

endfunction()

function( NEST_POST_PROCESS_WITH_PYTHON )
Expand Down
Loading