Skip to content

Commit

Permalink
Use qt6 for mac instead qt5
Browse files Browse the repository at this point in the history
Change cache to compile G4 with qt6
Qt6 is not installed in the same directory than Qt5 on macOS

Try to add libqcocoa into the wheel. cibuildwheel could not do it so I compile and delocate the wheel by myself
  • Loading branch information
tbaudier committed Sep 4, 2024
1 parent 05038c4 commit 444283d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 47 deletions.
40 changes: 19 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ jobs:
uses: actions/cache@v4
with:
path: ~/software
key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build1
restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build1
key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
- name: Create opengate Wheel
if: matrix.os == 'ubuntu-latest'
run: |
Expand Down Expand Up @@ -139,8 +139,8 @@ jobs:
python --version
export PATH="/usr/local/miniconda/envs/opengate_core/bin/:$PATH"
pip install wget colored
pip install cibuildwheel==2.17.0
conda install -c conda-forge qt==5.15.6
pip install wheel delocate
conda install conda-forge::qt6-main conda-forge::qt6-3d
mkdir -p $HOME/software
if [ "${{ steps.cache_opengate_core_dependencies.outputs.cache-hit }}" != 'true' ]; then
cd $HOME/software
Expand All @@ -153,7 +153,8 @@ jobs:
-DGEANT4_INSTALL_DATA=OFF \
-DGEANT4_INSTALL_DATADIR=$HOME/software/geant4/data \
-DGEANT4_USE_QT=ON \
-DGEANT4_USE_OPENGL_X11=ON \
-DGEANT4_USE_OPENGL_X11=OFF \
-DGEANT4_USE_QT_QT6=ON \
-DGEANT4_USE_SYSTEM_EXPAT=OFF \
-DGEANT4_BUILD_MULTITHREADED=ON \
-DGEANT4_USE_GDML=ON \
Expand All @@ -174,26 +175,23 @@ jobs:
make -j4
fi
cd $GITHUB_WORKSPACE
ls /Users/runner/miniconda3/envs/opengate_core/plugins/platforms
source $HOME/software/geant4/bin/geant4make.sh
export CMAKE_PREFIX_PATH=$HOME/software/geant4/bin:$HOME/software/itk/bin/:${CMAKE_PREFIX_PATH}
cd core
mkdir opengate_core/plugins
mkdir opengate_core/plugins/miniconda
cp -r /Users/runner/miniconda3/envs/opengate_core/lib/qt6/plugins/platforms/* opengate_core/plugins/
cp -r /Users/runner/miniconda3/envs/opengate_core/lib/qt6/plugins/imageformats opengate_core/plugins/
python3 setup.py sdist bdist_wheel
ls dist
export DYLD_LIBRARY_PATH=$HOME/software/geant4/bin/BuildProducts/lib:/Users/runner/miniconda3/envs/opengate_core/lib/qt6/plugins/platforms:/opt/X11/lib/:$DYLD_LIBRARY_PATH:/Users/runner/miniconda3/envs/opengate_core/lib
delocate-listdeps --all dist/*.whl
delocate-wheel -w fixed_wheels -v dist/*.whl
rm -rf dist
if [ ${{ matrix.python-version }} == "3.8" ]; then
export CIBW_BUILD="cp38-macosx_x86_64"
elif [ ${{ matrix.python-version }} == "3.9" ]; then
export CIBW_BUILD="cp39-macosx_x86_64"
elif [ ${{ matrix.python-version }} == "3.10" ]; then
export CIBW_BUILD="cp310-macosx_x86_64"
elif [ ${{ matrix.python-version }} == "3.11" ]; then
export CIBW_BUILD="cp311-macosx_x86_64"
fi
export CIBW_ENVIRONMENT='MACOSX_DEPLOYMENT_TARGET=10.14'
export CIBW_BEFORE_BUILD="python -m pip install colored"
python -m cibuildwheel --output-dir dist
ls fixed_wheels
delocate-listdeps --all fixed_wheels/*.whl
mv fixed_wheels dist
cd dist
find . -name '*whl' -exec bash -c ' mv $0 ${0/macosx_12_0/macosx_10_9}' {} \;
cd ../..
mv core/dist .
- name: Create opengate_core Wheel Windows
Expand Down Expand Up @@ -327,8 +325,8 @@ jobs:
# uses: actions/cache@v4
# with:
# path: ~/software
# key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build1
# restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build1
# key: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
# restore-keys: ${{ runner.os }}-${{ steps.get-os-version.outputs.release }}_geant4_${{ env.GEANT4_VERSION }}_itk_${{ env.ITK_VERSION }}_build2
# - uses: conda-incubator/setup-miniconda@v3
# with:
# miniconda-version: "latest"
Expand Down
30 changes: 17 additions & 13 deletions .github/workflows/redoQt5LibsMac.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@
dictLibs = {
"@rpath/libz.1.dylib": "@loader_path/../../.dylibs/libz.1.2.11.dylib",
"@rpath/libpng16.16.dylib": "@loader_path/../../.dylibs/libpng16.16.dylib",
"@rpath/libQt5Gui.5.dylib": "@loader_path/../../.dylibs/libQt5Gui.5.15.6.dylib",
"@rpath/libQt5Core.5.dylib": "@loader_path/../../.dylibs/libQt5Core.5.15.6.dylib",
"@rpath/libQt5PrintSupport.5.dylib": "@loader_path/../../.dylibs/libQt5PrintSupport.5.15.6.dylib",
"@rpath/libQt5Widgets.5.dylib": "@loader_path/../../.dylibs/libQt5Widgets.5.15.6.dylib",
"@rpath/libQt5Svg.5.dylib": "@loader_path/../miniconda/libQt5Svg.5.15.6.dylib",
"@rpath/libQt5DBus.5.dylib": "@loader_path/../miniconda/libQt5DBus.5.15.6.dylib",
"@rpath/libQt5Quick.5.dylib": "@loader_path/../miniconda/libQt5Quick.5.15.6.dylib",
"@rpath/libQt5WebSockets.5.dylib": "@loader_path/../miniconda/libQt5WebSockets.5.15.6.dylib",
"@rpath/libQt5QmlModels.5.dylib": "@loader_path/../miniconda/libQt5QmlModels.5.15.6.dylib",
"@rpath/libQt5Qml.5.dylib": "@loader_path/../miniconda/libQt5Qml.5.15.6.dylib",
"@rpath/libQt5Network.5.dylib": "@loader_path/../miniconda/libQt5Network.5.15.6.dylib",
"@rpath/libQt5Pdf.5.dylib": "@loader_path/../miniconda/libQt5Pdf.5.15.6.dylib",
"@rpath/libQt6Gui.6.dylib": "@loader_path/../../.dylibs/libQt6Gui.6.6.0.dylib",
"@rpath/libQt6Core.6.dylib": "@loader_path/../../.dylibs/libQt6Core.6.6.0.dylib",
"@rpath/libQt6PrintSupport.6.dylib": "@loader_path/../../.dylibs/libQt6PrintSupport.6.6.0.dylib",
"@rpath/libQt6Widgets.6.dylib": "@loader_path/../../.dylibs/libQt6Widgets.6.6.0.dylib",
"@rpath/libQt6Svg.6.dylib": "@loader_path/../miniconda/libQt6Svg.6.6.0.dylib",
"@rpath/libQt6DBus.6.dylib": "@loader_path/../miniconda/libQt6DBus.6.6.0.dylib",
"@rpath/libQt6Quick.6.dylib": "@loader_path/../miniconda/libQt6Quick.6.6.0.dylib",
"@rpath/libQt6WebSockets.6.dylib": "@loader_path/../miniconda/libQt6WebSockets.6.6.0.dylib",
"@rpath/libQt6QmlModels.6.dylib": "@loader_path/../miniconda/libQt6QmlModels.6.6.0.dylib",
"@rpath/libQt6Qml.6.dylib": "@loader_path/../miniconda/libQt6Qml.6.6.0.dylib",
"@rpath/libQt6Network.6.dylib": "@loader_path/../miniconda/libQt6Network.6.6.0.dylib",
"@rpath/libQt6Pdf.6.dylib": "@loader_path/../miniconda/libQt6Pdf.6.6.0.dylib",
"@rpath/libc++.1.dylib": "@loader_path/../../.dylibs/libc++.1.dylib",
"@rpath/libjpeg.9.dylib": "@rpath/libjpeg.9.dylib",
"@rpath/libjpeg.8.dylib": "@rpath/libjpeg.8.dylib",
"@rpath/libwebp.7.dylib": "@rpath/libwebp.7.dylib",
"@rpath/libwebpdemux.2.dylib": "@rpath/libwebpdemux.2.dylib",
"@rpath/libwebpmux.3.dylib": "@rpath/libwebpmux.3.dylib",
"@rpath/libtiff.6.dylib": "@rpath/libtiff.6.dylib",
}

for root, dirs, files in os.walk("opengate_core/plugins"):
Expand Down
1 change: 1 addition & 0 deletions core/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include opengate_core/plugins *
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# default visualization
#/vis/open OGLSQt

/vis/open OGLIQt
/vis/open OGL
/vis/scene/create
/vis/drawVolume worlds
/vis/viewer/flush
Expand Down
2 changes: 1 addition & 1 deletion opengate/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ class Simulation(GateObject):
},
),
"visu_commands": (
read_mac_file_to_commands("default_visu_commands.mac"),
read_mac_file_to_commands("default_visu_commands_qt.mac"),
{
"doc": "Geant4 commands needed to handle the visualization. ",
},
Expand Down
13 changes: 2 additions & 11 deletions opengate/tests/src/test004_simple_visu_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
sim.g4_verbose = False
sim.g4_verbose_level = 1
sim.visu = True
sim.visu_type = "qt"
sim.visu_verbose = False
sim.number_of_threads = 1
sim.random_engine = "MersenneTwister"
Expand All @@ -43,7 +44,7 @@
source.energy.mono = 80 * keV
source.direction.type = "momentum"
source.direction.momentum = [0, 0, 1]
source.activity = 200000 * Bq
source.activity = 200 * Bq

# runs
sec = g4_units.second
Expand All @@ -55,13 +56,3 @@
# start simulation
# sim.add_g4_command_after_init("/run/verbose 1")
sim.run()

stats = sim.output.get_actor("Stats")
stats.counts.run_count = 1

# gate_test4_simulation_stats_actor
# Gate mac/main.mac
stats_ref = utility.read_stat_file(paths.gate_output / "stat.txt")
is_ok = utility.assert_stats(stats, stats_ref, tolerance=0.03)

utility.test_ok(is_ok)

0 comments on commit 444283d

Please sign in to comment.