Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use qt6 for mac instead qt5 #442

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ build_wheel_task:
- wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-MacOSX-arm64.sh -O ~/miniconda.sh
- bash ~/miniconda.sh -b -p $HOME/miniconda3
- export PATH="$HOME/miniconda3/bin/:$PATH"
- conda create -n py3.9 python=3.9
- conda create -n py3.10 python=3.10
- conda create -n py3.11 python=3.11
- conda create -n py3.12 python=3.12

software_cache:
folder: $HOME/software
Expand All @@ -31,24 +35,21 @@ build_wheel_task:
wget
- export LDFLAGS="-L/usr/local/opt/llvm/lib"
- export CPPFLAGS="-I/usr/local/opt/llvm/include -fopenmp"
- conda info
- conda list
- which python
- pip install wget colored
- pip install cibuildwheel==2.11.2
- conda install -c conda-forge qt==5.15.6
- brew install qt
- mkdir -p $HOME/software
- cd $HOME/software
- mkdir -p geant4
- cd geant4
- rm -rf src bin data
- mkdir -p src bin data
- if [ ! -d "src/source" ] ; then git clone --branch v11.1.1 https://github.com/Geant4/geant4.git --depth 1 src ; fi
- if [ ! -d "src/source" ] ; then git clone --branch v11.2.1 https://github.com/Geant4/geant4.git --depth 1 src ; fi
- cd bin
- cmake -DCMAKE_CXX_FLAGS=-std=c++17
-DGEANT4_INSTALL_DATA=OFF
-DGEANT4_INSTALL_DATADIR=$HOME/software/geant4/data
-DGEANT4_USE_QT=ON
-DGEANT4_USE_OPENGL_X11=ON
-DGEANT4_USE_QT_QT6=ON
-DGEANT4_BUILD_MULTITHREADED=ON
-DGEANT4_USE_SYSTEM_EXPAT=OFF
-DGEANT4_USE_GDML=ON
Expand All @@ -57,6 +58,7 @@ build_wheel_task:
- cd $HOME/software
- mkdir -p itk
- cd itk
- rm -rf src bin
- mkdir -p src bin
- if [ ! -d "src/CMake" ] ; then git clone --branch v5.2.1 https://github.com/InsightSoftwareConsortium/ITK.git --depth 1 src ; fi
- cd bin
Expand All @@ -69,22 +71,41 @@ build_wheel_task:
- make -j4

opengate_core_script:
- echo $PWD
- ls $HOME/miniconda3/plugins/platforms
- conda info
- conda list
- conda init bash
- source ~/.bash_profile
- ls /opt/homebrew/share/qt/plugins/platforms
- source $HOME/software/geant4/bin/geant4make.sh
- export CMAKE_PREFIX_PATH=$HOME/software/geant4/bin:$HOME/software/itk/bin/:${CMAKE_PREFIX_PATH}
- ls
- cd core
- mkdir opengate_core/plugins
- mkdir opengate_core/plugins/miniconda
- ls $HOME/miniconda3/lib/
- rm -rf dist
- export CIBW_BEFORE_BUILD="python -m pip install colored;
python -c \"import os,delocate; print(os.path.join(os.path.dirname(delocate.__file__), 'tools.py'));quit()\" | xargs -I{} sed -i.\"\" \"s/first, /input.pop('i386',None); first, /g\" {}"
- python -m cibuildwheel --output-dir dist
- cd dist
- cd ../..
- mv core/dist .
- cp -r /opt/homebrew/share/qt/plugins/platforms/* opengate_core/plugins/
- cp -r /opt/homebrew/share/qt/plugins/imageformats/* opengate_core/plugins/
- ls /opt/homebrew/lib
- cd ..
- mkdir all_dist
- |
for PYVERSION in 3.9 3.10 3.11 3.12; do
cd core
rm -rf dist
conda activate py$PYVERSION;
pip install wget colored
pip install wheel delocate
python setup.py sdist bdist_wheel
export DYLD_LIBRARY_PATH=$HOME/software/geant4/bin/BuildProducts/lib:/opt/homebrew/share/qt/plugins/platforms/:/opt/X11/lib/:$DYLD_LIBRARY_PATH:/opt/homebrew/lib
python -c "import os,delocate; print(os.path.join(os.path.dirname(delocate.__file__), 'tools.py'));quit()" | xargs -I{} sed -i."" "s/first, /input.pop('i386',None); first, /g" {}
delocate-listdeps --all dist/*.whl
delocate-wheel -w fixed_wheels -v dist/*.whl
rm -rf dist
ls fixed_wheels
delocate-listdeps --all fixed_wheels/*.whl
mv fixed_wheels dist
cd ..
cp core/dist/* all_dist/
done
- mv all_dist dist

binaries_artifacts:
path: dist/*
Expand Down
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 *
4 changes: 2 additions & 2 deletions docs/source/user_guide_2_0_simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ The **verbosity**, i.e. the messages printed on the screen, are controlled via v

##### QT

It will start a Qt interface with `ui.visu_type = "qt"`. By default, the Geant4 visualisation commands are the ones provided in the file `opengate\mac\default_visu_commands.mac`. It can be changed with `self.visu_commands = gate.read_mac_file_to_commands('my_visu_commands.mac')`.
It will start a Qt interface with `ui.visu_type = "qt"`. By default, the Geant4 visualisation commands are the ones provided in the file `opengate\mac\default_visu_commands_qt.mac`. It can be changed with `self.visu_commands = gate.read_mac_file_to_commands('my_visu_commands.mac')`.


The visualisation with qt is still work in progress. First, it does not work on some linux systems (we don't know why yet). When a CT image is inserted in the simulation, every voxel should be drawn which is highly inefficient and cannot really be used.
The visualisation with qt is still work in progress. First, it does not work on some linux systems (we don't know why yet). With MacOS Qt6 is working but sometimes you need to set the library path properly before running python with: ```export DYLD_LIBRARY_PATH=/<venv_osx_path>/lib/python3.9/site-packages/opengate_core/plugins:$DYLD_LIBRARY_PATH```. When a CT image is inserted in the simulation, every voxel should be drawn which is highly inefficient and cannot really be used.

##### VRML

Expand Down
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)
Loading