Skip to content

Commit cd9c685

Browse files
authored
Document cmake option: NRN_INSTALL_PYTHON_PREFIX (#3747)
* Make option NRN_INSTALL_PYTHON_PREFIX easier to user * Bump minimum cmake version from 3.19 to 3.20
1 parent 54ebb00 commit cd9c685

6 files changed

Lines changed: 38 additions & 9 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Setup cmake
6767
uses: jwlawson/actions-setup-cmake@v2
6868
with:
69-
cmake-version : '3.19'
69+
cmake-version : '3.20'
7070

7171
- name: Setup Caliper profiler
7272
run: |

.github/workflows/neuron-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
SDK_ROOT: $(xcrun --sdk macosx --show-sdk-path)
3737
SKIP_WHEELHOUSE_REPAIR: true
3838
BUILD_TYPE: Release
39-
DESIRED_CMAKE_VERSION: 3.19
40-
DYNAMIC_PYTHON_CMAKE_VERSION: 3.19
39+
DESIRED_CMAKE_VERSION: '3.20'
40+
DYNAMIC_PYTHON_CMAKE_VERSION: '3.20'
4141
PY_MIN_VERSION: ${{ matrix.config.python_min_version || '3.10' }}
4242
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.14' }}
4343
MUSIC_INSTALL_DIR: /opt/MUSIC

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ jobs:
159159
- name: Setup cmake
160160
uses: jwlawson/actions-setup-cmake@v2
161161
with:
162-
cmake-version : '3.19'
162+
cmake-version : '3.20'
163163

164164
- name: Set up Python
165165
id: setup-python

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
22
# Note that this needs to happen **before** the call to project(...). This is because CMake reads
33
# the CRAYPE_LINK_TYPE environment variable inside the call to project(...) and sets various flags
44
# and properties based on its value. Because we are so early in the CMake processing, we have to
@@ -39,7 +39,7 @@ if(POLICY CMP0177)
3939
cmake_policy(SET CMP0177 NEW)
4040
endif()
4141

42-
# customizable install path to Python components. Mostly useful for Spack builds
42+
# customizable install path to Python components. Mostly useful for Spack & venv builds
4343
set(NRN_INSTALL_PYTHON_PREFIX
4444
"lib/python/neuron/"
4545
CACHE STRING
@@ -65,6 +65,11 @@ else()
6565
set(NRN_INSTALL_DATA_PREFIX)
6666
endif()
6767

68+
# Make python install path relative to CMAKE_INSTALL_PREFIX
69+
if(IS_ABSOLUTE "${NRN_INSTALL_PYTHON_PREFIX}")
70+
cmake_path(RELATIVE_PATH NRN_INSTALL_PYTHON_PREFIX BASE_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
71+
endif()
72+
6873
# =============================================================================
6974
# CMake common project settings
7075
# =============================================================================

docs/cmake_doc/options.rst

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,30 @@ NRN_ENABLE_PYTHON:BOOL=ON
306306
Enable Python interpreter support
307307
(default python, fallback to python3, but see PYTHON_EXECUTABLE below)
308308

309+
NRN_INSTALL_PYTHON_PREFIX:STRING="lib/python/neuron/"
310+
-----------------------------------------------------
311+
Path where NEURON Python components will be installed, relative to CMAKE_INSTALL_PREFIX. Must end with a directory named "neuron"
312+
313+
Environment variable PYTHONPATH must contain the real path to NRN_INSTALL_PYTHON_PREFIX in order for python to find neuron.
314+
315+
This path must end with a directory named "neuron"
316+
317+
For venv's, configure cmake with:
318+
319+
.. code-block:: shell
320+
321+
-DCMAKE_INSTALL_PREFIX=$(python -c "import sysconfig; print(sysconfig.get_path('data', 'venv'))") \
322+
-DNRN_INSTALL_PYTHON_PREFIX=$(python -c "import sysconfig; print(sysconfig.get_path('platlib', 'venv') + '/neuron')")
323+
324+
To install to your home directory, configure cmake with:
325+
326+
.. code-block:: shell
327+
328+
-DCMAKE_INSTALL_PREFIX=$(python3 -m site --user-base) \
329+
-DNRN_INSTALL_PYTHON_PREFIX=$(python3 -m site --user-site)/neuron
330+
331+
This option is ignored when building a wheel, in which case the value is forced to "neuron/"
332+
309333
.. _cmake_nrn_enable_python_dynamic:
310334
NRN_ENABLE_PYTHON_DYNAMIC:BOOL=OFF
311335
----------------------------------
@@ -544,7 +568,7 @@ NRN_ENABLE_TESTS:BOOL=OFF
544568
python3 -m pytest test_currents.py
545569
546570
NRN_ENABLE_COVERAGE:BOOL=OFF
547-
---------------------------
571+
----------------------------
548572
Enable code coverage
549573

550574
Requires ``lcov`` (e.g. ``sudo apt install lcov``).
@@ -677,7 +701,7 @@ NRN_ENABLE_DIGEST:BOOL=OFF
677701
Requires libcrypto
678702

679703
NRN_ENABLE_ARCH_INDEP_EXP_POW:BOOL=OFF
680-
---------------------------------
704+
--------------------------------------
681705
Provides \ :func:`use_exp_pow_precision` function so that exp and pow produce
682706
same results on all platforms.
683707

src/nmodl/pybind/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ file(COPY ${NMODL_PROJECT_PURELIB_SOURCE_DIR}/ext DESTINATION ${NMODL_PROJECT_PU
120120
if(NOT NRN_LINK_AGAINST_PYTHON)
121121
install(TARGETS pywrapper DESTINATION ${NRN_INSTALL_DATA_PREFIX}lib)
122122
if(NMODL_ENABLE_PYTHON_BINDINGS)
123-
install(TARGETS _nmodl DESTINATION ${NRN_INSTALL_PYTHON_PREFIX}nmodl)
123+
install(TARGETS _nmodl DESTINATION ${NRN_INSTALL_PYTHON_PREFIX}/nmodl)
124124
endif()
125125
else()
126126
install(

0 commit comments

Comments
 (0)