geant4-python-application 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. geant4_python_application-0.1.0/.clang-format +66 -0
  2. geant4_python_application-0.1.0/.cmake-format.yaml +6 -0
  3. geant4_python_application-0.1.0/.dockerignore +6 -0
  4. geant4_python_application-0.1.0/.github/CODEOWNERS +1 -0
  5. geant4_python_application-0.1.0/.github/dependabot.yaml +7 -0
  6. geant4_python_application-0.1.0/.github/workflows/build-test.yaml +283 -0
  7. geant4_python_application-0.1.0/.github/workflows/wheels.yaml +380 -0
  8. geant4_python_application-0.1.0/.gitignore +166 -0
  9. geant4_python_application-0.1.0/.pre-commit-config.yaml +74 -0
  10. geant4_python_application-0.1.0/CMakeLists.txt +186 -0
  11. geant4_python_application-0.1.0/Dockerfile +44 -0
  12. geant4_python_application-0.1.0/INSTALLATION.md +214 -0
  13. geant4_python_application-0.1.0/LICENSE +28 -0
  14. geant4_python_application-0.1.0/NOTICE +21 -0
  15. geant4_python_application-0.1.0/PKG-INFO +220 -0
  16. geant4_python_application-0.1.0/PYTHON_DEVELOPER_GUIDE.md +1631 -0
  17. geant4_python_application-0.1.0/README.md +171 -0
  18. geant4_python_application-0.1.0/docs/FEATURE_SUPPORT.md +33 -0
  19. geant4_python_application-0.1.0/examples/attenuation.ipynb +1256 -0
  20. geant4_python_application-0.1.0/examples/geant4-examples/00_qt_viewer_smoke.py +28 -0
  21. geant4_python_application-0.1.0/examples/geant4-examples/01_reference_physics_lists.py +47 -0
  22. geant4_python_application-0.1.0/examples/geant4-examples/02_gps_sources.py +50 -0
  23. geant4_python_application-0.1.0/examples/geant4-examples/03_scoring_meshes_hits.py +47 -0
  24. geant4_python_application-0.1.0/examples/geant4-examples/04_magnetic_electric_fields.py +43 -0
  25. geant4_python_application-0.1.0/examples/geant4-examples/05_optical_scintillation.py +41 -0
  26. geant4_python_application-0.1.0/examples/geant4-examples/06_callbacks.py +51 -0
  27. geant4_python_application-0.1.0/examples/geant4-examples/07_custom_physics.py +41 -0
  28. geant4_python_application-0.1.0/examples/geant4-examples/08_dna_medical.py +36 -0
  29. geant4_python_application-0.1.0/examples/geant4-examples/09_cad_vtk_root_generators.py +74 -0
  30. geant4_python_application-0.1.0/examples/geant4-examples/10_mpi_distributed.py +50 -0
  31. geant4_python_application-0.1.0/examples/geant4-examples/11_native_scoring_mesh.py +23 -0
  32. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/AUDIT.md +40 -0
  33. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/COMPATIBILITY.md +78 -0
  34. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/README.md +72 -0
  35. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/advanced/GoldFoilExperiment/gold_foil.py +145 -0
  36. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/advanced/NanoparticleTherapy/brain_tumor.py +166 -0
  37. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/advanced/NanoparticleTherapy/nano_therapy.py +168 -0
  38. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/basic/B1/b1.py +71 -0
  39. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/basic/B2/b2.py +74 -0
  40. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/basic/B3/b3.py +69 -0
  41. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/basic/B4/b4.py +73 -0
  42. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/basic/B5/b5.py +78 -0
  43. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/analysis/AnaEx01/ana_ex01.py +72 -0
  44. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/analysis/AnaEx02/ana_ex02.py +36 -0
  45. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/analysis/AnaEx03/ana_ex03.py +39 -0
  46. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/electromagnetic/TestEm1/test_em1.py +51 -0
  47. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/eventgenerator/HepMC/hepmc.py +45 -0
  48. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/eventgenerator/exgps/exgps.py +47 -0
  49. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/eventgenerator/particleGun/particle_gun.py +86 -0
  50. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/field/field01/field01.py +46 -0
  51. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/field/field02/field02.py +45 -0
  52. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/hadronic/Hadr00/hadr00.py +39 -0
  53. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/medical/GammaTherapy/gamma_therapy.py +47 -0
  54. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/medical/electronScattering/electron_scattering.py +42 -0
  55. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/optical/LXe/lxe.py +47 -0
  56. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/optical/OpNovice/op_novice.py +40 -0
  57. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/optical/wls/wls.py +45 -0
  58. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/parameterisations/Par01/par01.py +39 -0
  59. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/physicslists/factory/factory.py +41 -0
  60. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/radioactivedecay/rdecay01/rdecay01.py +38 -0
  61. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/extended/runAndEvent/RE01/re01.py +49 -0
  62. geant4_python_application-0.1.0/examples/geant4-examples/Geant4-11.4.2-examples-python/run_gdml.py +43 -0
  63. geant4_python_application-0.1.0/examples/qt_viewer.py +20 -0
  64. geant4_python_application-0.1.0/licenses/CLHEP-COPYING +674 -0
  65. geant4_python_application-0.1.0/licenses/CLHEP-COPYING.LESSER +165 -0
  66. geant4_python_application-0.1.0/licenses/Expat-COPYING +22 -0
  67. geant4_python_application-0.1.0/licenses/Geant4-LICENSE +73 -0
  68. geant4_python_application-0.1.0/licenses/PTL-LICENSE +21 -0
  69. geant4_python_application-0.1.0/licenses/Xerces-C-LICENSE +202 -0
  70. geant4_python_application-0.1.0/licenses/Xerces-C-NOTICE +10 -0
  71. geant4_python_application-0.1.0/licenses/zlib-LICENSE +22 -0
  72. geant4_python_application-0.1.0/pyproject.toml +127 -0
  73. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/ActionInitialization.h +18 -0
  74. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/Application.h +77 -0
  75. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/DataModel.h +176 -0
  76. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/DetectorConstruction.h +62 -0
  77. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/EventAction.h +18 -0
  78. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/PhysicsList.h +22 -0
  79. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/PrimaryGeneratorAction.h +48 -0
  80. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/RunAction.h +32 -0
  81. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/SensitiveDetector.h +16 -0
  82. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/StackingAction.h +26 -0
  83. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/SteppingAction.h +15 -0
  84. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/SteppingVerbose.h +20 -0
  85. geant4_python_application-0.1.0/src/geant4_application/include/geant4_application/TrackingAction.h +14 -0
  86. geant4_python_application-0.1.0/src/geant4_application/src/ActionInitialization.cpp +38 -0
  87. geant4_python_application-0.1.0/src/geant4_application/src/Application.cpp +397 -0
  88. geant4_python_application-0.1.0/src/geant4_application/src/DataModel.cpp +513 -0
  89. geant4_python_application-0.1.0/src/geant4_application/src/DetectorConstruction.cpp +258 -0
  90. geant4_python_application-0.1.0/src/geant4_application/src/EventAction.cpp +20 -0
  91. geant4_python_application-0.1.0/src/geant4_application/src/PhysicsList.cpp +49 -0
  92. geant4_python_application-0.1.0/src/geant4_application/src/PrimaryGeneratorAction.cpp +114 -0
  93. geant4_python_application-0.1.0/src/geant4_application/src/RunAction.cpp +53 -0
  94. geant4_python_application-0.1.0/src/geant4_application/src/SensitiveDetector.cpp +11 -0
  95. geant4_python_application-0.1.0/src/geant4_application/src/StackingAction.cpp +33 -0
  96. geant4_python_application-0.1.0/src/geant4_application/src/SteppingAction.cpp +16 -0
  97. geant4_python_application-0.1.0/src/geant4_application/src/SteppingVerbose.cpp +32 -0
  98. geant4_python_application-0.1.0/src/geant4_application/src/TrackingAction.cpp +25 -0
  99. geant4_python_application-0.1.0/src/geant4_python_application/__init__.py +49 -0
  100. geant4_python_application-0.1.0/src/geant4_python_application/_version.py +24 -0
  101. geant4_python_application-0.1.0/src/geant4_python_application/application.py +442 -0
  102. geant4_python_application-0.1.0/src/geant4_python_application/cad.py +124 -0
  103. geant4_python_application-0.1.0/src/geant4_python_application/detector.py +97 -0
  104. geant4_python_application-0.1.0/src/geant4_python_application/distributed.py +45 -0
  105. geant4_python_application-0.1.0/src/geant4_python_application/events.py +87 -0
  106. geant4_python_application-0.1.0/src/geant4_python_application/files/__init__.py +1 -0
  107. geant4_python_application-0.1.0/src/geant4_python_application/files/datasets.py +297 -0
  108. geant4_python_application-0.1.0/src/geant4_python_application/files/directories.py +40 -0
  109. geant4_python_application-0.1.0/src/geant4_python_application/gdml.py +39 -0
  110. geant4_python_application-0.1.0/src/geant4_python_application/generator.py +63 -0
  111. geant4_python_application-0.1.0/src/geant4_python_application/geometry.py +52 -0
  112. geant4_python_application-0.1.0/src/geant4_python_application/io.py +154 -0
  113. geant4_python_application-0.1.0/src/geant4_python_application/optical.py +199 -0
  114. geant4_python_application-0.1.0/src/geant4_python_application/scoring.py +118 -0
  115. geant4_python_application-0.1.0/src/python/module.cpp +89 -0
  116. geant4_python_application-0.1.0/src/vis/module.cpp +52 -0
  117. geant4_python_application-0.1.0/tests/__init__.py +0 -0
  118. geant4_python_application-0.1.0/tests/conftest.py +10 -0
  119. geant4_python_application-0.1.0/tests/test_analysis.py +174 -0
  120. geant4_python_application-0.1.0/tests/test_application.py +169 -0
  121. geant4_python_application-0.1.0/tests/test_capabilities.py +150 -0
  122. geant4_python_application-0.1.0/tests/test_module.py +18 -0
  123. geant4_python_application-0.1.0/tests/test_run.py +66 -0
  124. geant4_python_application-0.1.0/tools/audit_examples.py +155 -0
  125. geant4_python_application-0.1.0/tools/build_macos_self_contained.sh +35 -0
  126. geant4_python_application-0.1.0/tools/relink_qt_wheel.py +142 -0
  127. geant4_python_application-0.1.0/tools/smoke_viewer.py +55 -0
@@ -0,0 +1,66 @@
1
+ # Generated from CLion C/C++ Code Style settings
2
+ BasedOnStyle: LLVM
3
+ AccessModifierOffset: -4
4
+ AlignAfterOpenBracket: Align
5
+ AlignConsecutiveAssignments: None
6
+ AlignOperands: Align
7
+ AllowAllArgumentsOnNextLine: false
8
+ AllowAllConstructorInitializersOnNextLine: false
9
+ AllowAllParametersOfDeclarationOnNextLine: false
10
+ AllowShortBlocksOnASingleLine: Always
11
+ AllowShortCaseLabelsOnASingleLine: false
12
+ AllowShortFunctionsOnASingleLine: All
13
+ AllowShortIfStatementsOnASingleLine: Always
14
+ AllowShortLambdasOnASingleLine: All
15
+ AllowShortLoopsOnASingleLine: true
16
+ AlwaysBreakAfterReturnType: None
17
+ AlwaysBreakTemplateDeclarations: Yes
18
+ BreakBeforeBraces: Custom
19
+ BraceWrapping:
20
+ AfterCaseLabel: false
21
+ AfterClass: false
22
+ AfterControlStatement: Never
23
+ AfterEnum: false
24
+ AfterFunction: false
25
+ AfterNamespace: false
26
+ AfterUnion: false
27
+ BeforeCatch: false
28
+ BeforeElse: false
29
+ IndentBraces: false
30
+ SplitEmptyFunction: false
31
+ SplitEmptyRecord: true
32
+ BreakBeforeBinaryOperators: None
33
+ BreakBeforeTernaryOperators: true
34
+ BreakConstructorInitializers: BeforeColon
35
+ BreakInheritanceList: BeforeColon
36
+ ColumnLimit: 0
37
+ CompactNamespaces: false
38
+ ContinuationIndentWidth: 8
39
+ IndentCaseLabels: true
40
+ IndentPPDirectives: None
41
+ IndentWidth: 4
42
+ KeepEmptyLinesAtTheStartOfBlocks: true
43
+ MaxEmptyLinesToKeep: 2
44
+ NamespaceIndentation: None
45
+ ObjCSpaceAfterProperty: false
46
+ ObjCSpaceBeforeProtocolList: true
47
+ PointerAlignment: Left
48
+ ReflowComments: false
49
+ SpaceAfterCStyleCast: true
50
+ SpaceAfterLogicalNot: false
51
+ SpaceAfterTemplateKeyword: false
52
+ SpaceBeforeAssignmentOperators: true
53
+ SpaceBeforeCpp11BracedList: false
54
+ SpaceBeforeCtorInitializerColon: true
55
+ SpaceBeforeInheritanceColon: true
56
+ SpaceBeforeParens: ControlStatements
57
+ SpaceBeforeRangeBasedForLoopColon: false
58
+ SpaceInEmptyParentheses: false
59
+ SpacesBeforeTrailingComments: 0
60
+ SpacesInAngles: false
61
+ SpacesInCStyleCastParentheses: false
62
+ SpacesInContainerLiterals: false
63
+ SpacesInParentheses: false
64
+ SpacesInSquareBrackets: false
65
+ TabWidth: 4
66
+ UseTab: Never
@@ -0,0 +1,6 @@
1
+ # https://cmake-format.readthedocs.io/en/latest/configuration.html
2
+
3
+ format:
4
+ tab_size: 4
5
+ separate_ctrl_name_with_space: true
6
+ separate_fn_name_with_space: false
@@ -0,0 +1,6 @@
1
+ venv
2
+ build
3
+ *-build-*
4
+ *_cache
5
+ .github
6
+ tests
@@ -0,0 +1 @@
1
+ * @lobis
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ # Maintain dependencies for GitHub Actions
4
+ - package-ecosystem: github-actions
5
+ directory: /
6
+ schedule:
7
+ interval: monthly
@@ -0,0 +1,283 @@
1
+ name: Build and Test
2
+
3
+ on:
4
+ schedule:
5
+ - cron: 0 */24 * * *
6
+ workflow_dispatch:
7
+ pull_request:
8
+ push:
9
+ branches: [main]
10
+
11
+ concurrency:
12
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13
+ cancel-in-progress: true
14
+
15
+ env:
16
+ GEANT4_VERSION: 11.2.2
17
+ XERCES_VERSION: 3.2.5
18
+ CPP_STANDARD: 17
19
+ Geant4_DIR: ${{ github.workspace }}/geant4
20
+
21
+ jobs:
22
+ install-with-geant4-from-conda:
23
+ name: Install dependencies with conda
24
+ runs-on: ${{ matrix.os }}
25
+ timeout-minutes: 60
26
+ strategy:
27
+ fail-fast: false
28
+ matrix:
29
+ os: [ubuntu-latest, macos-latest] # Geant4 is not available on conda for windows TODO: update this when it is
30
+ defaults:
31
+ run:
32
+ shell: bash -l {0}
33
+ steps:
34
+ - name: Setup conda
35
+ uses: conda-incubator/setup-miniconda@v3
36
+ with:
37
+ auto-update-conda: true
38
+ python-version: 3.12
39
+
40
+ - name: Install Geant4 and cmake using conda
41
+ run: |
42
+ conda install -c conda-forge cmake ninja geant4=${{ env.GEANT4_VERSION }}
43
+
44
+ - name: Install additional dependencies (Ubuntu)
45
+ if: matrix.os == 'ubuntu-latest'
46
+ run: |
47
+ conda install -c conda-forge gxx_linux-64
48
+
49
+ - name: Install additional dependencies (MacOS)
50
+ if: matrix.os == 'macos-latest'
51
+ run: |
52
+ conda install -c conda-forge clang_osx-64
53
+
54
+ - name: Print versions
55
+ run: |
56
+ conda --version
57
+ cmake --version
58
+
59
+ echo "Geant4: ${{ env.GEANT4_VERSION }}"
60
+
61
+ geant4-config --version
62
+ geant4-config --check-datasets
63
+
64
+ - name: Install datasets if missing # Shouldn't they be available after the conda install?
65
+ run: |
66
+ geant4-config --install-datasets
67
+ geant4-config --check-datasets
68
+
69
+ - name: Checkout
70
+ uses: actions/checkout@v4
71
+
72
+ - name: pip install the package from source
73
+ run: |
74
+ python -m pip install .[test]
75
+ python -c "import geant4_python_application; print(geant4_python_application.version)"
76
+
77
+ - name: Check datasets are accessible # Datasets should have been installed by the conda package, and should be accessible
78
+ run: |
79
+ python -c "import geant4_python_application as g4; g4.files.datasets.check_datasets(throw=True)"
80
+
81
+ - name: Run tests
82
+ run: |
83
+ python -m pytest -vv --reruns 3 --reruns-delay 30 --only-rerun "(?i)http|timeout|connection|socket|resolve"
84
+
85
+ build-geant4:
86
+ name: Build Geant4 on ${{ matrix.os }}
87
+ runs-on: ${{ matrix.os }}
88
+ timeout-minutes: 120
89
+ strategy:
90
+ fail-fast: false
91
+ matrix:
92
+ os: [ubuntu-latest, macos-latest, windows-latest]
93
+
94
+ steps:
95
+ - name: Setup CMake
96
+ uses: lukka/get-cmake@v3.30.3
97
+
98
+ - name: Cache Xerces-C Installation
99
+ id: cache-xerces
100
+ uses: actions/cache@v4
101
+ with:
102
+ path: ${{ github.workspace }}/xerces
103
+ key: xerces-v${{ env.XERCES_VERSION }}-cpp${{ env.CPP_STANDARD }}
104
+
105
+ - name: Build and Install Xerces-C
106
+ if: steps.cache-xerces.outputs.cache-hit != 'true'
107
+ run: |
108
+ git clone https://github.com/apache/xerces-c.git xerces-source
109
+ git -C xerces-source checkout tags/v${{ env.XERCES_VERSION }}
110
+ cmake -B xerces-build -S xerces-source -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/xerces -DCMAKE_CXX_STANDARD=${{ env.CPP_STANDARD }} -DBUILD_SHARED_LIBS=OFF ${{ matrix.os == 'windows-latest' && '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_CXX_FLAGS_RELEASE="/MT"' || '-G Ninja -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC -Dnetwork-accessor=socket -Dtranscoder=iconv' }}
111
+ cmake --build xerces-build --parallel $(nproc) --config Release --target install
112
+
113
+ - name: Cache Geant4 Installation
114
+ id: cache-geant4
115
+ uses: actions/cache@v4
116
+ with:
117
+ path: ${{ env.Geant4_DIR }}
118
+ key: geant4-v${{ env.GEANT4_VERSION }}-cpp${{ env.CPP_STANDARD }}
119
+
120
+ - name: Build and Install Geant4 (without datasets)
121
+ if: steps.cache-geant4.outputs.cache-hit != 'true'
122
+ run: |
123
+ git clone https://github.com/Geant4/geant4.git ${{ github.workspace }}/geant4-source --depth 1 --branch v${{ env.GEANT4_VERSION }}
124
+ cmake -B geant4-build -S geant4-source -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.Geant4_DIR }} -DXERCESC_ROOT_DIR=${{ github.workspace }}/xerces -DCMAKE_CXX_STANDARD=${{ env.CPP_STANDARD }} -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_EXAMPLES=OFF -DGEANT4_INSTALL_DATA=OFF -DGEANT4_BUILD_TLS_MODEL=global-dynamic -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF ${{ matrix.os == 'windows-latest' && '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_CXX_FLAGS_RELEASE="/MT"' || '-G Ninja -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC -DGEANT4_USE_SYSTEM_EXPAT=OFF' }}
125
+ cmake --build geant4-build --parallel $(nproc) --config Release --target install
126
+
127
+ install-geant4-datasets:
128
+ name: Download Geant4 datasets for ${{ matrix.os }}
129
+ needs: [build-geant4]
130
+ runs-on: ${{ matrix.os }}
131
+ timeout-minutes: 30
132
+ strategy:
133
+ fail-fast: false
134
+ matrix:
135
+ os: [ubuntu-latest, macos-latest, windows-latest]
136
+
137
+ steps:
138
+ - name: Cache Geant4 Installation
139
+ id: cache-geant4
140
+ uses: actions/cache@v4
141
+ with:
142
+ path: ${{ env.Geant4_DIR }}
143
+ key: geant4-v${{ env.GEANT4_VERSION }}-cpp${{ env.CPP_STANDARD }}
144
+ fail-on-cache-miss: true
145
+
146
+ - name: Cache Geant4 Datasets
147
+ id: cache-geant4-data
148
+ uses: actions/cache@v4
149
+ with:
150
+ path: ${{ github.workspace }}/geant4-data
151
+ key: geant4-${{ env.GEANT4_VERSION }}-data
152
+ enableCrossOsArchive: true
153
+ lookup-only: true
154
+
155
+ - name: Move Geant4 datasets (Ubuntu/MacOS)
156
+ if:
157
+ steps.cache-geant4-data.outputs.cache-hit != 'true' && matrix.os !=
158
+ 'windows-latest'
159
+ shell: bash
160
+ run: |
161
+ bash ${{ env.Geant4_DIR }}/bin/geant4-config --install-datasets
162
+ bash ${{ env.Geant4_DIR }}/bin/geant4-config --check-datasets
163
+ mv ${{ env.Geant4_DIR }}/share/Geant4/data ${{ github.workspace }}/geant4-data
164
+
165
+ - name: Move Geant4 datasets (Windows)
166
+ if:
167
+ steps.cache-geant4-data.outputs.cache-hit != 'true' && matrix.os ==
168
+ 'windows-latest'
169
+ shell: powershell
170
+ run: |
171
+ Get-ChildItem -Path ${{ env.Geant4_DIR }}\bin
172
+ cmd /c ${{ env.Geant4_DIR }}\bin\geant4-config.cmd --install-datasets
173
+ cmd /c ${{ env.Geant4_DIR }}\bin\geant4-config.cmd --check-datasets
174
+ Move-Item ${{ env.Geant4_DIR }}\share\Geant4\data ${{ github.workspace }}\geant4-data
175
+
176
+ build-test:
177
+ name:
178
+ Build and Test for ${{ matrix.os }} (Python ${{ matrix.python-version }})
179
+ needs: [install-geant4-datasets]
180
+ timeout-minutes: 30
181
+ runs-on: ${{ matrix.os }}
182
+ strategy:
183
+ fail-fast: false
184
+ matrix:
185
+ os: [ubuntu-latest, macos-latest, windows-latest]
186
+ python-version:
187
+ - "3.8"
188
+ - "3.9"
189
+ - "3.10"
190
+ - "3.11"
191
+ - "3.12"
192
+
193
+ steps:
194
+ - name: Checkout
195
+ uses: actions/checkout@v4
196
+
197
+ - name: Setup Python
198
+ uses: actions/setup-python@v5
199
+ with:
200
+ python-version: ${{ matrix.python-version }}
201
+
202
+ - name: Setup CMake
203
+ uses: lukka/get-cmake@v3.30.3
204
+
205
+ - name: Setup Windows environment variables
206
+ if: matrix.os == 'windows-latest'
207
+ shell: bash
208
+ run: |
209
+ echo "CMAKE_ARGS=-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" >> $GITHUB_ENV
210
+
211
+ - name: Cache Xerces-C Installation
212
+ id: cache-xerces
213
+ uses: actions/cache@v4
214
+ with:
215
+ path: ${{ github.workspace }}/xerces
216
+ key: xerces-v${{ env.XERCES_VERSION }}-cpp${{ env.CPP_STANDARD }}
217
+ fail-on-cache-miss: true
218
+
219
+ - name: Cache Geant4 Installation
220
+ id: cache-geant4
221
+ uses: actions/cache@v4
222
+ with:
223
+ path: ${{ env.Geant4_DIR }}
224
+ key: geant4-v${{ env.GEANT4_VERSION }}-cpp${{ env.CPP_STANDARD }}
225
+ fail-on-cache-miss: true
226
+
227
+ - name: pip install the package
228
+ run: |
229
+ python -m pip install --upgrade pip
230
+ python -m pip install .[test]
231
+ git tag
232
+ python -c "import geant4_python_application; print(geant4_python_application.version)"
233
+
234
+ # test ability to download datasets in one job and use the cache in the others
235
+ - name: Cache Geant4 Datasets
236
+ if: matrix.python-version != '3.11'
237
+ id: cache-geant4-data
238
+ uses: actions/cache@v4
239
+ with:
240
+ path: ${{ github.workspace }}/geant4-data
241
+ key: geant4-${{ env.GEANT4_VERSION }}-data
242
+ fail-on-cache-miss: true
243
+ enableCrossOsArchive: true
244
+
245
+ - name: Move Geant4 datasets (Ubuntu/MacOS)
246
+ if: matrix.python-version != '3.11' && matrix.os != 'windows-latest'
247
+ run: |
248
+ GEANT4_DATA_DIR=$(python -c "import geant4_python_application; print(geant4_python_application.data_directory())")
249
+ mkdir -p ${{ github.workspace }}/geant4-data "$GEANT4_DATA_DIR"
250
+ mv ${{ github.workspace }}/geant4-data/* "$GEANT4_DATA_DIR"
251
+
252
+ # TODO: unify this with the above
253
+ - name: Move Geant4 datasets (Windows)
254
+ if: matrix.python-version != '3.11' && matrix.os == 'windows-latest'
255
+ shell: powershell
256
+ run: |
257
+ $env:GEANT4_DATA_DIR = python -c "import geant4_python_application; print(geant4_python_application.data_directory())"
258
+ New-Item -ItemType Directory -Path "${{ github.workspace }}\geant4-data" -Force
259
+ New-Item -ItemType Directory -Path $env:GEANT4_DATA_DIR -Force
260
+ Move-Item "${{ github.workspace }}\geant4-data\*" $env:GEANT4_DATA_DIR -Force
261
+
262
+ - name: Install datasets
263
+ uses: nick-fields/retry@v3
264
+ with:
265
+ timeout_minutes: 30
266
+ retry_wait_seconds: 60
267
+ max_attempts: 5
268
+ command: |
269
+ python -c "import geant4_python_application as g4; g4.install_datasets()"
270
+ # Check that the datasets are installed correctly
271
+ python -c "import geant4_python_application as g4; g4.files.datasets.check_datasets(throw=True)"
272
+
273
+ - name: Run tests
274
+ run: |
275
+ python -m pytest -vv --reruns 3 --reruns-delay 30 --only-rerun "(?i)http|timeout|connection|socket|resolve"
276
+
277
+ - name: Run example notebooks
278
+ if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
279
+ run: |
280
+ python -m pip install jupyter nbconvert matplotlib
281
+ for notebook in $(find examples -name '*.ipynb'); do
282
+ jupyter nbconvert --to notebook --execute --inplace $notebook
283
+ done