From fd1a59a1480963311716087284c4c429931eda6b Mon Sep 17 00:00:00 2001 From: Dan Short Date: Wed, 29 Jul 2020 16:43:14 +0000 Subject: [PATCH 01/24] First pass at python CI config --- .github/workflows/python.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..34b1f87 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,26 @@ +name: Python package + +on: + push: + branches: [ implement_ci ] + pull_request: + branches: [ implement_ci ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install plasma source + run: | + python setup.py sdist + python -m pip install --verbose dist/*.tar.gz From 167e05c02979ace847206a9e202f42bd60b68770 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Wed, 29 Jul 2020 16:44:47 +0000 Subject: [PATCH 02/24] Use empty init file This prevents an error on a fresh build --- parametric_plasma_source/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/parametric_plasma_source/__init__.py b/parametric_plasma_source/__init__.py index 351009c..e69de29 100644 --- a/parametric_plasma_source/__init__.py +++ b/parametric_plasma_source/__init__.py @@ -1,2 +0,0 @@ -from .plasma import Plasma -from .plasma_source import PlasmaSource From 92e9838a4e937783c8806af85dcacf3a6260001b Mon Sep 17 00:00:00 2001 From: Dan Short Date: Wed, 29 Jul 2020 17:09:00 +0000 Subject: [PATCH 03/24] Build using bdist_wheel rather than sdist --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 34b1f87..dad3c34 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -22,5 +22,5 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install plasma source run: | - python setup.py sdist - python -m pip install --verbose dist/*.tar.gz + python setup.py bdist_wheel + python -m pip install --verbose dist/*.whl From 60ab628a5bcc9e7dc1654c80b72fb18657ff77d1 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Wed, 29 Jul 2020 17:13:30 +0000 Subject: [PATCH 04/24] Make sure wheel is installed --- .github/workflows/python.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index dad3c34..6bc853f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -22,5 +22,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install plasma source run: | + pip install wheel python setup.py bdist_wheel python -m pip install --verbose dist/*.whl From 07b2e22bb0e4cd8f637fdf9ad25e4801766e7c3c Mon Sep 17 00:00:00 2001 From: Dan Short Date: Wed, 29 Jul 2020 17:15:12 +0000 Subject: [PATCH 05/24] Get submodules in CI --- .github/workflows/python.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6bc853f..1319588 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -22,6 +22,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install plasma source run: | + git submodule update --init --recursive pip install wheel python setup.py bdist_wheel python -m pip install --verbose dist/*.whl From 09deb7dd51f701c15845dfa0d9510355014b1813 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 08:34:17 +0100 Subject: [PATCH 06/24] Only build plasma_source for Python --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index af274c5..dab5d91 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ def build_extension(self, ext): cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg] build_args += ["--", "-j2"] - build_args += ["plasma_source"] + build_args += ["--target", "plasma_source"] env = os.environ.copy() env["CXXFLAGS"] = "{} -DVERSION_INFO=\\\"{}\\\"".format( From 4080d7f654a35e7e5be1474eafba40b1217ff5e8 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 09:17:24 +0100 Subject: [PATCH 07/24] Fix order of build args Target must come before the make arguements. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index dab5d91..65fb269 100644 --- a/setup.py +++ b/setup.py @@ -36,11 +36,11 @@ def build_extension(self, ext): "-DPYTHON_EXECUTABLE=" + sys.executable] cfg = "Debug" if self.debug else "Release" - build_args = ["--config", cfg] + build_args = ["--target", "plasma_source"] + build_args += ["--config", cfg] cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg] build_args += ["--", "-j2"] - build_args += ["--target", "plasma_source"] env = os.environ.copy() env["CXXFLAGS"] = "{} -DVERSION_INFO=\\\"{}\\\"".format( From a7de90fcd8da7f7e08b3c945a210688022cce424 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 09:20:16 +0100 Subject: [PATCH 08/24] Do not fail if openmc not found Makes OpenMC optional but does not build the source_sampling library if OPENMC_LIB is not found. --- CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 578d4ce..0eb1beb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,13 +26,15 @@ list(APPEND source_sampling_SOURCES add_library(source_sampling SHARED ${source_sampling_SOURCES}) -find_library(OPENMC_LIB openmc HINTS ${OPENMC_LIB_DIR}) - -set_target_properties(source_sampling PROPERTIES PREFIX "") -set_target_properties(source_sampling PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_include_directories(source_sampling PUBLIC ${OPENMC_INC_DIR}) -target_include_directories(source_sampling PUBLIC ${OPENMC_DIR}/vendor/pugixml) -target_link_libraries(source_sampling ${OPENMC_LIB} gfortran) +find_library(OPENMC_LIB openmc HINTS ${OPENMC_LIB_DIR} OPTIONAL) + +if (OPENMC_LIB) + set_target_properties(source_sampling PROPERTIES PREFIX "") + set_target_properties(source_sampling PROPERTIES POSITION_INDEPENDENT_CODE ON) + target_include_directories(source_sampling PUBLIC ${OPENMC_INC_DIR}) + target_include_directories(source_sampling PUBLIC ${OPENMC_DIR}/vendor/pugixml) + target_link_libraries(source_sampling ${OPENMC_LIB} gfortran) +endif() # Build plasma_source Python bindings list(APPEND plasma_source_pybind_SOURCES From 677607dad4024ff01803fda0b10aee4c142233fe Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 09:35:57 +0100 Subject: [PATCH 09/24] Remove unused RANDOM definition Random numbers are only generated in the source sample_source method, so we shouldn't need to link against OpenMC where we don't use OpenMC functions. --- parametric_plasma_source/plasma_source.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/parametric_plasma_source/plasma_source.cpp b/parametric_plasma_source/plasma_source.cpp index 3a2fc64..b0b61b0 100644 --- a/parametric_plasma_source/plasma_source.cpp +++ b/parametric_plasma_source/plasma_source.cpp @@ -3,9 +3,6 @@ #include #include "plasma_source.hpp" #include -#include "openmc/random_lcg.h" - -#define RANDOM openmc::prn() namespace plasma_source { From 53d7e070f268143e3e3c51f5bb0a6b378fa1c1f4 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 09:40:45 +0100 Subject: [PATCH 10/24] Upload wheel as artefact --- .github/workflows/python.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 1319588..731539a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -26,3 +26,8 @@ jobs: pip install wheel python setup.py bdist_wheel python -m pip install --verbose dist/*.whl + - name: upload wheel + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist From cafd6e58949a5710b88a95e2c7af1e355532d0c6 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 09:46:38 +0100 Subject: [PATCH 11/24] Create new publish step to upload wheels --- .github/workflows/python.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 731539a..db52783 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -26,6 +26,9 @@ jobs: pip install wheel python setup.py bdist_wheel python -m pip install --verbose dist/*.whl + + publish: + - name: upload wheel uses: actions/upload-artifact@v2 with: From 976be58b89c08a32fb15c4990ab14045b49c11d1 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 09:55:50 +0100 Subject: [PATCH 12/24] Tidy up actions --- .github/workflows/python.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index db52783..87d8bfb 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -7,13 +7,15 @@ on: branches: [ implement_ci ] jobs: - build: + setup: runs-on: ubuntu-latest strategy: matrix: python-version: [3.6, 3.7, 3.8] + build: + needs: setup steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -28,7 +30,9 @@ jobs: python -m pip install --verbose dist/*.whl publish: - + on: push + needs: build + steps: - name: upload wheel uses: actions/upload-artifact@v2 with: From 5bc783668aa887ed7a3861727bf8b9fca1ca8498 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 09:57:22 +0100 Subject: [PATCH 13/24] Fix syntax error --- .github/workflows/python.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 87d8bfb..1157e5f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -13,15 +13,16 @@ jobs: strategy: matrix: python-version: [3.6, 3.7, 3.8] - - build: - needs: setup steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + + build: + needs: setup + steps: - name: Install plasma source run: | git submodule update --init --recursive From 2a1d2e00fd3b25f72044da44d335f7a9775e9b83 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 10:04:53 +0100 Subject: [PATCH 14/24] Another syntax fix --- .github/workflows/python.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 1157e5f..d0be5f2 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,7 +31,6 @@ jobs: python -m pip install --verbose dist/*.whl publish: - on: push needs: build steps: - name: upload wheel From b4bbe0493b0fc06678388d0f50f5e3cf77e1bd30 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 10:14:50 +0100 Subject: [PATCH 15/24] Revert workflow to single job --- .github/workflows/python.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index d0be5f2..731539a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -7,32 +7,25 @@ on: branches: [ implement_ci ] jobs: + build: - setup: runs-on: ubuntu-latest strategy: matrix: python-version: [3.6, 3.7, 3.8] + steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - build: - needs: setup - steps: - name: Install plasma source run: | git submodule update --init --recursive pip install wheel python setup.py bdist_wheel python -m pip install --verbose dist/*.whl - - publish: - needs: build - steps: - name: upload wheel uses: actions/upload-artifact@v2 with: From c340abfccf817ffbe22974bb73e9358cdaf5ff8b Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 10:58:47 +0100 Subject: [PATCH 16/24] Implement a simple test --- .github/workflows/python.yml | 5 ++++- requirements-develop.txt | 2 ++ tests/test_plasma_source.py | 40 ++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 requirements-develop.txt create mode 100644 tests/test_plasma_source.py diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 731539a..dec0687 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -23,9 +23,12 @@ jobs: - name: Install plasma source run: | git submodule update --init --recursive - pip install wheel + pip install -r requirements-develop.txt python setup.py bdist_wheel python -m pip install --verbose dist/*.whl + - name: run tests + run: | + pytest tests - name: upload wheel uses: actions/upload-artifact@v2 with: diff --git a/requirements-develop.txt b/requirements-develop.txt new file mode 100644 index 0000000..0d73fcd --- /dev/null +++ b/requirements-develop.txt @@ -0,0 +1,2 @@ +pytest +wheel diff --git a/tests/test_plasma_source.py b/tests/test_plasma_source.py new file mode 100644 index 0000000..6c42ba0 --- /dev/null +++ b/tests/test_plasma_source.py @@ -0,0 +1,40 @@ +"""Tests for the methods in plasma_source.""" + +import pytest + +from parametric_plasma_source.plasma_source import PlasmaSource + +plasma_params = { + "elongation": 1.557, + "ion_density_origin": 1.09e20, + "ion_density_peaking_factor": 1, + "ion_density_pedistal": 1.09e20, + "ion_density_seperatrix": 3e19, + "ion_temperature_origin": 45.9, + "ion_temperature_peaking_factor": 8.06, + "ion_temperature_pedistal": 6.09, + "ion_temperature_seperatrix": 0.1, + "major_radius": 906.0, + "minor_radius": 292.258, + "pedistal_radius": 0.8 * 292.258, + "plasma_id": 1, + "shafranov_shift": 44.789, + "triangularity": 0.270, + "ion_temperature_beta": 6, +} + + +@pytest.fixture(scope="session") +def plasma_source(): + """Make a plasma source to use as a test fixture.""" + return PlasmaSource(**plasma_params) + + +class TestPlasmaSource: + """A class to run tests against the plasma source.""" + + def test_ion_density_magnetic_origin(self, plasma_source): + """Test the ion density at the magnetic origin.""" + ion_density = plasma_source.ion_density(0.0) + + assert pytest.approx(ion_density, 1.09e20) From aafe8765e2cd312d0c4516f5fe594321081513bf Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 11:05:55 +0100 Subject: [PATCH 17/24] Don't run compile test if OpenMC not installed --- tests/test_Compile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_Compile.py b/tests/test_Compile.py index b4eaf9f..405a275 100644 --- a/tests/test_Compile.py +++ b/tests/test_Compile.py @@ -8,6 +8,8 @@ from parametric_plasma_source.plasma import Plasma +pytest.importorskip("openmc") + class test_object_properties(unittest.TestCase): def test_compile(self): From aa4a9da1075548b4e980ed0c7a957637639d126a Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 11:17:13 +0100 Subject: [PATCH 18/24] Add some more tests --- tests/test_plasma_source.py | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/test_plasma_source.py b/tests/test_plasma_source.py index 6c42ba0..56a5437 100644 --- a/tests/test_plasma_source.py +++ b/tests/test_plasma_source.py @@ -38,3 +38,59 @@ def test_ion_density_magnetic_origin(self, plasma_source): ion_density = plasma_source.ion_density(0.0) assert pytest.approx(ion_density, 1.09e20) + + def test_ion_density_inside_pedestal(self, plasma_source): + """Test the ion density inside the pedestal.""" + ion_density = plasma_source.ion_density(0.2) + + assert pytest.approx(ion_density, 1.09e20) + + def test_ion_density_outside_pedestal(self, plasma_source): + """Test the ion density outside the pedestal.""" + ion_density = plasma_source.ion_density(2.4) + + assert pytest.approx(ion_density, 1.00628584e20) + + def test_ion_density_boundary(self, plasma_source): + """Test the ion density at the boundary.""" + boundary = plasma_params["minor_radius"] / 100.0 + ion_density = plasma_source.ion_density(boundary) + + assert pytest.approx( + ion_density, plasma_params["ion_density_seperatrix"] + ) + + def test_ion_temperature_magnetic_origin(self, plasma_source): + """Test the ion temperature at the magnetic origin.""" + ion_temperature = plasma_source.ion_temperature(0.0) + + assert pytest.approx( + ion_temperature, plasma_params["ion_temperature_origin"] + ) + + def test_ion_temperature_inside_pedestal(self, plasma_source): + """Test the ion temperature inside the pedestal.""" + ion_temperature = plasma_source.ion_temperature(0.2) + + assert pytest.approx(ion_temperature, 45.89987429) + + def test_ion_temperature_outside_pedestal(self, plasma_source): + """Test the ion temperature outside the pedestal.""" + ion_temperature = plasma_source.ion_temperature(2.4) + + assert pytest.approx(ion_temperature, 5.45525594) + + def test_ion_temperature_boundary(self, plasma_source): + """Test the ion temperature at the boundary.""" + boundary = plasma_params["minor_radius"] / 100.0 + ion_temperature = plasma_source.ion_temperature(boundary) + + assert pytest.approx( + ion_temperature, plasma_params["ion_temperature_seperatrix"] + ) + + def test_dt_cross_section(self, plasma_source): + """Test the dt cross section at a specific temperature.""" + dt_cross_section = plasma_source.dt_xs(4.25e7) + + assert pytest.approx(dt_cross_section, 0.0) From a869142a0ad8c3381676a4853fc4df7e85b81a8e Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 11:29:58 +0100 Subject: [PATCH 19/24] Add status badge Also a few format update to README. --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a8192d2..84d791e 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,20 @@ # parametric-plasma-source +![Python package](https://github.com/DanShort12/parametric-plasma-source/workflows/Python%20package/badge.svg) + Python package, C++ source and build files for parametric plasma source for use in fusion neutron transport calculations with OpenMC. The plasma source is based on a paper by [C. Fausser et al](https://www.sciencedirect.com/science/article/pii/S0920379612000853) -# Installation +## Installation ```pip install parametric_plasma_source``` -# Usage +## Usage The parametric plasma source can be imported an used in Python 3 in the following manner. -``` +```[python] from parametric_plasma_source import Plasma my_plasma = Plasma(major_radius=6, minor_radius=1.5, @@ -25,7 +27,7 @@ In the above example the major_radius, minor_radius, elongation and triangularit There are a number of additional arguments that can be passed to the Plasma class on construction. Units are in SI (e.g. meters not cm) -``` +```[python] ion_density_pedistal = 1.09e+20 ion_density_seperatrix = 3e+19 ion_density_origin = 1.09e+20 From 79a2aefff0efa8e40c6bce46942fe0cbae3cca13 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 13:12:07 +0100 Subject: [PATCH 20/24] Use a clearer job name --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index dec0687..9119e97 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -7,7 +7,7 @@ on: branches: [ implement_ci ] jobs: - build: + build_and_test: runs-on: ubuntu-latest strategy: From 69f88a6ef2e83d1340f58c99ffb374e10e070776 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 13:14:16 +0100 Subject: [PATCH 21/24] Only run actions when affecting master --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 9119e97..b09a078 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -2,9 +2,9 @@ name: Python package on: push: - branches: [ implement_ci ] + branches: [ master ] pull_request: - branches: [ implement_ci ] + branches: [ master ] jobs: build_and_test: From b13a1c7b4077432b5d673858083fd32b1d53ef8f Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 14:04:39 +0100 Subject: [PATCH 22/24] Submodules are now retrieved from CMake config --- .github/workflows/python.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b09a078..6cf6598 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -22,7 +22,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install plasma source run: | - git submodule update --init --recursive pip install -r requirements-develop.txt python setup.py bdist_wheel python -m pip install --verbose dist/*.whl From 1de521641ad5ca4f9b3738c1d8788568b185a505 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 14:06:54 +0100 Subject: [PATCH 23/24] Pick up submodules from CMake config --- CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eb1beb..412d405 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,26 @@ set(OPENMC_DIR /opt/openmc) set(OPENMC_INC_DIR ${OPENMC_DIR}/include) set(OPENMC_LIB_DIR ${OPENMC_DIR}/lib) +# Ensure submodules are available and up to date +find_package(Git QUIET) +if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + # Update submodules as needed + option(GIT_SUBMODULE "Check submodules during build" ON) + if(GIT_SUBMODULE) + message(STATUS "Submodule update") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT) + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + endif() + endif() +endif() + +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/pybind11/CMakeLists.txt") + message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") +endif() + # Build source_sampling list(APPEND source_sampling_SOURCES ${SRC_DIR}/source_sampling.cpp From 3353357af413e20fa2e04365f4dbaaf972030e56 Mon Sep 17 00:00:00 2001 From: Dan Short Date: Thu, 30 Jul 2020 14:12:50 +0100 Subject: [PATCH 24/24] Tidy up step names --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6cf6598..c46ced0 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -25,10 +25,10 @@ jobs: pip install -r requirements-develop.txt python setup.py bdist_wheel python -m pip install --verbose dist/*.whl - - name: run tests + - name: Run tests run: | pytest tests - - name: upload wheel + - name: Upload wheel artifact uses: actions/upload-artifact@v2 with: name: dist