From 233064b2e21a4c09cb775bd955921174c61ba23d Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Fri, 14 Feb 2025 16:11:42 +0600 Subject: [PATCH 1/8] source build NCrystal --- CMakeLists.txt | 12 ++---------- tools/ci/gha-install-ncrystal.sh | 27 +++++++++++++++++++++++++++ tools/ci/gha-install.py | 4 ++-- tools/ci/gha-install.sh | 4 +--- 4 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 tools/ci/gha-install-ncrystal.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 94caec757ab..916c775a0fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,16 +121,8 @@ endmacro() #=============================================================================== if(OPENMC_USE_NCRYSTAL) - if(NOT DEFINED "NCrystal_DIR") - #Invocation of "ncrystal-config --show cmakedir" is needed to find NCrystal - #when it is installed from Python wheels: - execute_process( - COMMAND "ncrystal-config" "--show" "cmakedir" - OUTPUT_VARIABLE "NCrystal_DIR" OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endif() - find_package(NCrystal 3.8.0 REQUIRED) - message(STATUS "Found NCrystal: ${NCrystal_DIR} (version ${NCrystal_VERSION})") + find_package(NCrystal 4.0.0 REQUIRED) + message(STATUS "Found NCrystal: ${NCrystal_LIBRARIES} (version ${NCrystal_VERSION})") endif() #=============================================================================== diff --git a/tools/ci/gha-install-ncrystal.sh b/tools/ci/gha-install-ncrystal.sh new file mode 100644 index 00000000000..b8dfdf93bef --- /dev/null +++ b/tools/ci/gha-install-ncrystal.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -ex +cd $HOME + +# NCrystal Variables +NCRYSTAL_BRANCH='v4.0.0' +NCRYSTAL_REPO='https://github.com/mctools/ncrystal' +NCRYSTAL_INSTALL_DIR=$HOME/NCRYSTAL/ + +CURRENT_DIR=$(pwd) + +# NCrystal Install +cd $HOME +git clone -b $NCrystal_BRANCH $NCrystal_REPO ncrystal +cd ncrystal +mkdir build && cd build +cmake .. \ + -DBUILD_SHARED_LIBS=ON \ + -DNCRYSTAL_NOTOUCH_CMAKE_BUILD_TYPE=ON \ + -DNCRYSTAL_MODIFY_RPATH=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DNCRYSTAL_ENABLE_EXAMPLES=OFF \ + -DNCRYSTAL_ENABLE_SETUPSH=OFF \ + -DNCRYSTAL_ENABLE_DATA=EMBED \ + -DCMAKE_INSTALL_PREFIX="$NCRYSTAL_INSTALL_DIR" +make -j4 && make install +rm -rf $HOME/ncrystal diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index 1eb9a55b4dc..727869cee33 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -2,7 +2,6 @@ import shutil import subprocess - def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrystal=False): # Create build directory and change to it shutil.rmtree('build', ignore_errors=True) @@ -31,7 +30,6 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys if dagmc: cmake_cmd.append('-DOPENMC_USE_DAGMC=ON') - cmake_cmd.append('-DOPENMC_USE_UWUW=ON') dagmc_path = os.environ.get('HOME') + '/DAGMC' cmake_cmd.append('-DCMAKE_PREFIX_PATH=' + dagmc_path) @@ -42,6 +40,8 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys if ncrystal: cmake_cmd.append('-DOPENMC_USE_NCRYSTAL=ON') + ncrystal_path = os.environ.get('HOME') + '/NCRYSTAL' + cmake_cmd.append(f'-DCMAKE_PREFIX_PATH={ncrystal_path}') # Build in coverage mode for coverage testing cmake_cmd.append('-DOPENMC_ENABLE_COVERAGE=on') diff --git a/tools/ci/gha-install.sh b/tools/ci/gha-install.sh index 50f110ed4e6..cff7dc834f5 100755 --- a/tools/ci/gha-install.sh +++ b/tools/ci/gha-install.sh @@ -16,9 +16,7 @@ fi # Install NCrystal if needed if [[ $NCRYSTAL = 'y' ]]; then - pip install 'ncrystal>=4.0.0' - #Basic quick verification: - nctool --test + ./tools/ci/gha-install-ncrystal.sh fi # Install vectfit for WMP generation if needed From b8556c6621c3536e7770f9d835d812aa9fa1fdeb Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Fri, 14 Feb 2025 17:51:13 +0600 Subject: [PATCH 2/8] fix variables --- tools/ci/gha-install-ncrystal.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/ci/gha-install-ncrystal.sh b/tools/ci/gha-install-ncrystal.sh index b8dfdf93bef..b16c93efc39 100644 --- a/tools/ci/gha-install-ncrystal.sh +++ b/tools/ci/gha-install-ncrystal.sh @@ -11,7 +11,7 @@ CURRENT_DIR=$(pwd) # NCrystal Install cd $HOME -git clone -b $NCrystal_BRANCH $NCrystal_REPO ncrystal +git clone -b $NCRYSTAL_BRANCH $NCRYSTAL_REPO ncrystal cd ncrystal mkdir build && cd build cmake .. \ @@ -25,3 +25,4 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX="$NCRYSTAL_INSTALL_DIR" make -j4 && make install rm -rf $HOME/ncrystal +cd $CURRENT_DIR \ No newline at end of file From 72f653addd7ba97f4ce26958706a449c1b2c3a33 Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Fri, 14 Feb 2025 18:27:22 +0600 Subject: [PATCH 3/8] chmod +x --- tools/ci/gha-install-ncrystal.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/gha-install-ncrystal.sh b/tools/ci/gha-install-ncrystal.sh index b16c93efc39..bae3fbb0761 100644 --- a/tools/ci/gha-install-ncrystal.sh +++ b/tools/ci/gha-install-ncrystal.sh @@ -25,4 +25,4 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX="$NCRYSTAL_INSTALL_DIR" make -j4 && make install rm -rf $HOME/ncrystal -cd $CURRENT_DIR \ No newline at end of file +cd $CURRENT_DIR From 8eb71c244c879ea7e9ae2ba29bc643468db9008b Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Fri, 14 Feb 2025 18:32:51 +0600 Subject: [PATCH 4/8] chmod +x ./tools/ci/gha-install-ncrystal.sh --- tools/ci/gha-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/ci/gha-install.sh b/tools/ci/gha-install.sh index cff7dc834f5..f7c95ddff1c 100755 --- a/tools/ci/gha-install.sh +++ b/tools/ci/gha-install.sh @@ -16,6 +16,7 @@ fi # Install NCrystal if needed if [[ $NCRYSTAL = 'y' ]]; then + chmod +x ./tools/ci/gha-install-ncrystal.sh ./tools/ci/gha-install-ncrystal.sh fi From ac7b4f2e33b5a8709f21128bab933498f99bd566 Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Fri, 14 Feb 2025 18:51:40 +0600 Subject: [PATCH 5/8] skip nctool --- tools/ci/gha-script.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/ci/gha-script.sh b/tools/ci/gha-script.sh index 4733907eb25..c7c634ffa33 100755 --- a/tools/ci/gha-script.sh +++ b/tools/ci/gha-script.sh @@ -14,10 +14,5 @@ if [[ $EVENT == 'y' ]]; then args="${args} --event " fi -# Check NCrystal installation -if [[ $NCRYSTAL = 'y' ]]; then - nctool --test -fi - # Run regression and unit tests pytest --cov=openmc -v $args tests From 2be024a90462c19c09e92246ef8fdc8660fb461b Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Fri, 14 Feb 2025 20:19:55 +0600 Subject: [PATCH 6/8] fix tests --- cmake/OpenMCConfig.cmake.in | 11 +---------- tools/ci/gha-install-ncrystal.sh | 3 +-- tools/ci/gha-script.sh | 5 +++++ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/cmake/OpenMCConfig.cmake.in b/cmake/OpenMCConfig.cmake.in index b02bbffe5cf..668376ce5ae 100644 --- a/cmake/OpenMCConfig.cmake.in +++ b/cmake/OpenMCConfig.cmake.in @@ -10,16 +10,7 @@ if(@OPENMC_USE_DAGMC@) endif() if(@OPENMC_USE_NCRYSTAL@) - if(NOT DEFINED "NCrystal_DIR") - #Invocation of "ncrystal-config --show cmakedir" is needed to find NCrystal - #when it is installed from Python wheels: - execute_process( - COMMAND "ncrystal-config" "--show" "cmakedir" - OUTPUT_VARIABLE "NCrystal_DIR" OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endif() - find_package(NCrystal REQUIRED) - message(STATUS "Found NCrystal: ${NCrystal_DIR} (version ${NCrystal_VERSION})") + find_package(NCrystal REQUIRED HINTS @CMAKE_PREFIX_PATH@) endif() if(@OPENMC_USE_LIBMESH@) diff --git a/tools/ci/gha-install-ncrystal.sh b/tools/ci/gha-install-ncrystal.sh index bae3fbb0761..3bc29ab5417 100644 --- a/tools/ci/gha-install-ncrystal.sh +++ b/tools/ci/gha-install-ncrystal.sh @@ -1,6 +1,5 @@ #!/bin/bash set -ex -cd $HOME # NCrystal Variables NCRYSTAL_BRANCH='v4.0.0' @@ -25,4 +24,4 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX="$NCRYSTAL_INSTALL_DIR" make -j4 && make install rm -rf $HOME/ncrystal -cd $CURRENT_DIR +cd $CURRENT_DIR \ No newline at end of file diff --git a/tools/ci/gha-script.sh b/tools/ci/gha-script.sh index c7c634ffa33..7d98e152456 100755 --- a/tools/ci/gha-script.sh +++ b/tools/ci/gha-script.sh @@ -14,5 +14,10 @@ if [[ $EVENT == 'y' ]]; then args="${args} --event " fi +# Install NCrystal for testing +if [[ $NCRYSTAL = 'y' ]]; then + pip install ncrystal +fi + # Run regression and unit tests pytest --cov=openmc -v $args tests From 9e900f21d17b0d4f8764316c4856ac9f4f396c5a Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Fri, 14 Feb 2025 23:55:25 +0600 Subject: [PATCH 7/8] install only the python module of NCrystal --- tools/ci/gha-script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/gha-script.sh b/tools/ci/gha-script.sh index 7d98e152456..f76eb73b4a7 100755 --- a/tools/ci/gha-script.sh +++ b/tools/ci/gha-script.sh @@ -16,7 +16,7 @@ fi # Install NCrystal for testing if [[ $NCRYSTAL = 'y' ]]; then - pip install ncrystal + pip install ncrystal-python fi # Run regression and unit tests From 254c4c86449558458c05878b253b26898775c10a Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Mon, 17 Feb 2025 23:22:06 +0600 Subject: [PATCH 8/8] pip install ncrystal --- tools/ci/gha-install.py | 1 + tools/ci/gha-script.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index 727869cee33..7cfb78e11a3 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -30,6 +30,7 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys if dagmc: cmake_cmd.append('-DOPENMC_USE_DAGMC=ON') + cmake_cmd.append('-DOPENMC_USE_UWUW=ON') dagmc_path = os.environ.get('HOME') + '/DAGMC' cmake_cmd.append('-DCMAKE_PREFIX_PATH=' + dagmc_path) diff --git a/tools/ci/gha-script.sh b/tools/ci/gha-script.sh index f76eb73b4a7..7d98e152456 100755 --- a/tools/ci/gha-script.sh +++ b/tools/ci/gha-script.sh @@ -16,7 +16,7 @@ fi # Install NCrystal for testing if [[ $NCRYSTAL = 'y' ]]; then - pip install ncrystal-python + pip install ncrystal fi # Run regression and unit tests