-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add nanobound coupling kernel & build
- Loading branch information
Marmaduke Woodman
committed
Sep 3, 2024
1 parent
aac0394
commit c0ec48c
Showing
24 changed files
with
497 additions
and
563 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: build & test kernel library | ||
on: [push] | ||
|
||
jobs: | ||
pip-tvbk: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python-version: [ "3.10", ] | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
id: setPy | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: install tools and dependencies | ||
run: python3 -m pip install -U setuptools pip wheel pytest scipy | ||
|
||
- name: build | ||
run: cd tvb_kernels; pip install . | ||
|
||
- name: test | ||
run: cd tvb_kernels; python -m pytest | ||
|
||
|
||
spack-tvbk: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: setup spack | ||
uses: spack/setup-spack@v2 | ||
with: | ||
ref: develop | ||
buildcache: true | ||
color: true | ||
path: spack | ||
|
||
- name: install deps w/ spack | ||
shell: spack-bash {0} | ||
run: | | ||
cd tvb_kernels | ||
spack -e . concretize | ||
spack -e . install | ||
spack env activate . | ||
spack env status | ||
pip install pytest | ||
- name: build nanobound library | ||
shell: spack-bash {0} | ||
run: | | ||
cd tvb_kernels | ||
spack env activate . | ||
pip install . | ||
pytest | ||
# https://github.com/spack/setup-spack?tab=readme-ov-file#example-caching-your-own-binaries-for-public-repositories | ||
- name: Push packages and update index | ||
run: | | ||
cd tvb_kernels | ||
spack -e . mirror set --push --oci-username ${{ github.actor }} --oci-password "${{ secrets.GITHUB_TOKEN }}" local-buildcache | ||
spack -e . buildcache push --base-image ubuntu:22.04 --update-index local-buildcache | ||
if: ${{ !cancelled() }} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.cache | ||
build | ||
*.jpg | ||
build | ||
.spack-env | ||
spack.lock | ||
*.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
cmake_minimum_required(VERSION 3.18...3.27) | ||
project(tvb_kernels LANGUAGES C CXX) | ||
|
||
if (NOT SKBUILD) | ||
message(WARNING "\ | ||
This CMake file is meant to be executed using 'scikit-build-core'. | ||
Running it directly will almost certainly not produce the desired | ||
result. If you are a user trying to install this package, use the | ||
command below, which will install all necessary build dependencies, | ||
compile the package in an isolated environment, and then install it. | ||
===================================================================== | ||
$ pip install . | ||
===================================================================== | ||
If you are a software developer, and this is your own package, then | ||
it is usually much more efficient to install the build dependencies | ||
in your environment once and use the following command that avoids | ||
a costly creation of a new virtual environment at every compilation: | ||
===================================================================== | ||
$ pip install nanobind scikit-build-core[pyproject] | ||
$ pip install --no-build-isolation -ve . | ||
===================================================================== | ||
You may optionally add -Ceditable.rebuild=true to auto-rebuild when | ||
the package is imported. Otherwise, you need to rerun the above | ||
after editing C++ files.") | ||
endif() | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
add_compile_options(-std=c++17 -fopenmp-simd -mavx2 -march=native -mtune=native) | ||
|
||
find_package(Python 3.8 | ||
REQUIRED COMPONENTS Interpreter Development.Module | ||
) | ||
|
||
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") | ||
endif() | ||
|
||
# Detect the installed nanobind package and import it into CMake | ||
execute_process( | ||
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir | ||
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR) | ||
list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}") | ||
find_package(nanobind CONFIG REQUIRED) | ||
|
||
nanobind_add_module(tvb_kernels tvb_kernels.cpp tvbk_conn.c) | ||
|
||
nanobind_add_stub( | ||
tvb_kernels_stub | ||
MODULE tvb_kernels | ||
OUTPUT tvb_kernels.pyi | ||
PYTHON_PATH $<TARGET_FILE_DIR:tvb_kernels> | ||
DEPENDS tvb_kernels | ||
MARKER_FILE py.typed | ||
) | ||
|
||
install(TARGETS tvb_kernels LIBRARY DESTINATION tvb_kernels) |
Oops, something went wrong.