Skip to content

Commit

Permalink
replaced geant4_pybind with g4python
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnaf-tahmid-chowdhury committed Aug 31, 2023
1 parent fdb4a85 commit 91ff773
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 41 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/run_build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ jobs:
./install-nuclear-boy.sh -d ${GITHUB_WORKSPACE} \
-e nuclear-boy \
-g ${GITHUB_WORKSPACE}/nuclear-boy/G4Data \
-c ${GITHUB_WORKSPACE}/nuclear-boy/CrossSection
- name: Available storage
run: |
df -h
-c ${GITHUB_WORKSPACE}/nuclear-boy/CrossSectionData
- name: Check NuclearBoy directories
run: |
echo "NuclearBoy directory"
ls -h ${GITHUB_WORKSPACE}/nuclear-boy
echo
echo "G4Data directory"
ls -h ${GITHUB_WORKSPACE}/nuclear-boy/G4Data
echo
echo "CrossSection directory"
ls -h ${GITHUB_WORKSPACE}/nuclear-boy/CrossSectionData
- name: Run tests
run: |
source ${GITHUB_WORKSPACE}/nuclear-boy/nuclear-boy
Expand Down
71 changes: 37 additions & 34 deletions install-nuclear-boy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,32 @@ detect_version_id() {
echo "Detected version id as $version"
}

# Parse command-line arguments
while getopts ":d:e:g:c:" opt; do
case $opt in
d)
install_dir="$OPTARG"
;;
e)
env_name="$OPTARG"
;;
g)
geant4_data_lib="$OPTARG"
;;
c)
cross_section_data_lib="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
parse_command_line_arguments() {
while getopts ":d:e:g:c:" opt; do
case $opt in
d)
install_dir="$OPTARG"
;;
e)
env_name="$OPTARG"
;;
g)
geant4_data_lib="$OPTARG"
;;
c)
cross_section_data_lib="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
}

set_install_directory() {
if [ -z "$install_dir" ]; then
Expand Down Expand Up @@ -287,9 +288,10 @@ install_moab() {
set_geant4_data_lib() {
if [ -z "$geant4_data_lib" ]; then
while true; do
read -p "Enter Geant4 data library path (or press enter for default '$env_dir/G4data'): " geant4_data_lib
read -p "Enter Geant4 data library path (or press enter for default '$env_dir/G4Data'): " geant4_data_lib
if [ -z "$geant4_data_lib" ]; then
geant4_data_lib=$env_dir/G4data
geant4_data_lib=$env_dir/G4Data
mkdir -p $geant4_data_lib
echo "Using default library path: $geant4_data_lib"
break
elif [ -d "$geant4_data_lib" ]; then
Expand Down Expand Up @@ -355,15 +357,14 @@ install_geant4() {
-DGEANT4_USE_QT=ON \
-DGEANT4_USE_OPENGL_X11=OFF \
-DGEANT4_USE_SYSTEM_EXPAT=OFF \
-DGEANT4_USE_PYTHON=ON \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
-DGEANT4_BUILD_MULTITHREADED=ON \
-DGEANT4_INSTALL_DATA=$install_geant4_data \
-DGEANT4_INSTALL_DATADIR=$geant4_data_lib \
-DGEANT4_INSTALL_DATA_TIMEOUT=0
make
make install
# Enable Python bindings
${env_dir}/bin/python3 -m pip install geant4-pybind
cd ${env_dir}
# Remove the temporary directory
rm -rf ${env_dir}/.tmp
Expand Down Expand Up @@ -410,6 +411,7 @@ set_cross_section_lib() {
read -p "Enter Cross Section data library path (or press enter for default '$env_dir/CrossSectionData'): " cross_section_data_lib
if [ -z "$cross_section_data_lib" ]; then
cross_section_data_lib=$env_dir/CrossSectionData
mkdir -p $cross_section_data_lib
echo "Using default library path: $cross_section_data_lib"
break
elif [ -d "$cross_section_data_lib" ]; then
Expand Down Expand Up @@ -592,7 +594,7 @@ else
export LD_LIBRARY_PATH="${hdf5_libdir}:${env_dir}/lib:\$LD_LIBRARY_PATH"
fi
export OPENMC_CROSS_SECTIONS="${cross_section_data_lib}/mcnp_endfb71"
export OPENMC_CROSS_SECTIONS="${cross_section_data_lib}/lib80x_hdf5/cross_sections.xml"
__${env_name}_activate(){
source ${env_dir}/bin/activate
Expand All @@ -608,9 +610,9 @@ __${env_name}_set_cross_sections_path() {
fi
local cmd=\$1
case \$cmd in
endfb70) export OPENMC_CROSS_SECTIONS="${cross_section_data_lib}/mcnp_endfb70" ;;
endfb71) export OPENMC_CROSS_SECTIONS="${cross_section_data_lib}/mcnp_endfb71" ;;
lib80x) export OPENMC_CROSS_SECTIONS="${cross_section_data_lib}/lib80x_hdf5" ;;
endfb70) export OPENMC_CROSS_SECTIONS="${cross_section_data_lib}/mcnp_endfb70/cross_sections.xml" ;;
endfb71) export OPENMC_CROSS_SECTIONS="${cross_section_data_lib}/mcnp_endfb71/cross_sections.xml" ;;
lib80x) export OPENMC_CROSS_SECTIONS="${cross_section_data_lib}/lib80x_hdf5/cross_sections.xml" ;;
*) echo "Error: Invalid input. Use '${env_name} --help' for more information.";
esac
}
Expand Down Expand Up @@ -662,14 +664,14 @@ __${env_name}_update_geant4() {
-DGEANT4_USE_QT=ON \\
-DGEANT4_USE_OPENGL_X11=OFF \\
-DGEANT4_USE_SYSTEM_EXPAT=OFF \\
-DGEANT4_USE_PYTHON=ON \\
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \\
-DGEANT4_BUILD_MULTITHREADED=ON \\
-DGEANT4_INSTALL_DATA=\$download_geant4_data \\
-DGEANT4_INSTALL_DATADIR=$geant4_data_lib \\
-DGEANT4_INSTALL_DATA_TIMEOUT=0
make
make install
${env_dir}/bin/python3 -m pip install -U geant4-pybind
echo "Geant4 has been updated to the latest version."
# Update the stored version tag
echo "\$geant4_latest_version" >\${env_dir}/var/log/Geant4.version.txt
Expand Down Expand Up @@ -1061,6 +1063,7 @@ main() {
echo "Welcome to the NuclearBoy installer!"
echo "This package manager will install the PyNE, OpenMC, DAGMC and Geant4 on your system."
echo
parse_command_line_arguments
set_install_directory
set_env_name
set_geant4_data_lib
Expand Down
4 changes: 2 additions & 2 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
pymoab = None

try:
from geant4_pybind import *
import geant4
except ImportError:
geant4 = False
geant4 = None

try:
import openmc
Expand Down

0 comments on commit 91ff773

Please sign in to comment.