Skip to content

Commit 5d10e12

Browse files
committed
Add menu role for macos, updates to macos installer
1 parent 9951a80 commit 5d10e12

File tree

9 files changed

+104
-22
lines changed

9 files changed

+104
-22
lines changed

.github/workflows/build_installer.yaml

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
windows-installer:
1414
runs-on: windows-latest
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
- uses: conda-incubator/setup-miniconda@v3
1818
with:
1919
activate-environment: rascal2
@@ -29,6 +29,7 @@ jobs:
2929
conda init powershell
3030
conda activate rascal2
3131
conda install -c nsis nsis=3.* accesscontrol
32+
pip install matlabengine==9.14.*
3233
python packaging/build_exe.py
3334
makensis packaging/windows/build_installer.nsi
3435
- name: Upload installer
@@ -40,7 +41,7 @@ jobs:
4041
runs-on: ubuntu-latest
4142
steps:
4243
- name: Checkout
43-
uses: actions/checkout@v4
44+
uses: actions/checkout@v5
4445
- name: Set up MATLAB
4546
uses: matlab-actions/setup-matlab@v2
4647
with:
@@ -64,10 +65,51 @@ jobs:
6465
with:
6566
name: linux installer
6667
path: packaging/linux/*.run
68+
macos-installer:
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
platform: [ macos-15-intel, macos-14 ]
73+
runs-on: ${{ matrix.platform }}
74+
steps:
75+
- uses: actions/checkout@v5
76+
- uses: conda-incubator/setup-miniconda@v3
77+
with:
78+
activate-environment: rascal2
79+
environment-file: environment.yaml
80+
auto-activate-base: false
81+
- name: Set up MATLAB
82+
uses: matlab-actions/setup-matlab@v2
83+
with:
84+
release: R2023b
85+
- name: Make installer
86+
shell: bash -el {0}
87+
run: |
88+
conda init bash
89+
conda activate rascal2
90+
if [ ${{ matrix.platform }} == "macos-14" ]; then
91+
ARCH="arm64"
92+
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Users/runner/hostedtoolcache/MATLAB/2023.2.999/arm64/MATLAB.app/bin/maca64
93+
python -m pip install --no-build-isolation /Users/runner/hostedtoolcache/MATLAB/2023.2.999/arm64/MATLAB.app/extern/engines/python
94+
else
95+
ARCH="x64"
96+
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Users/runner/hostedtoolcache/MATLAB/2023.2.999/x64/MATLAB.app/bin/maci64
97+
python -m pip install --no-build-isolation /Users/runner/hostedtoolcache/MATLAB/2023.2.999/x64/MATLAB.app/extern/engines/python
98+
fi
99+
python packaging/build_exe.py
100+
chmod 777 packaging/bundle/rascal.app/Contents/Resources/matlab/engine/_arch.txt
101+
cd packaging/macos/
102+
chmod 777 make.sh
103+
./make.sh $GITHUB_REF_NAME $ARCH
104+
- name: Upload installer
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: macOS installer-${{ strategy.job-index }}
108+
path: packaging/macos/rascal2-*.pkg
67109
deploy-nightly:
68110
if: github.ref == 'refs/heads/main'
69111
runs-on: ubuntu-latest
70-
needs: [windows-installer, linux-installer]
112+
needs: [macos-installer]
71113
permissions:
72114
contents: write
73115
steps:

.github/workflows/unit_tests.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,3 @@ jobs:
4242
- name: Install and run tests (MacOS/Windows)
4343
if: runner.os != 'linux'
4444
uses: ./.github/actions/windows-mac
45-

packaging/build_exe.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ def build_exe():
100100
shutil.rmtree(work_path)
101101

102102
# Copy resources into installer directory
103-
resources = ["static/images", "static/style.css"]
103+
resources = ["static/images", "static/style.css", "../examples"]
104104
shutil.copy(PROJECT_PATH / "LICENSE", dist_path / "LICENSE")
105105
for resource in resources:
106+
if resource == "../examples" and not IS_MAC:
107+
# on macOS, examples have to go into resources
108+
continue
109+
106110
if IS_MAC:
107111
dest_path = dist_path / "rascal.app" / "Contents" / "Resources" / resource
108112
else:
@@ -122,9 +126,13 @@ def build_exe():
122126

123127
ver_file.write(f'!define VERSION "{RASCAL2_VERSION}"')
124128

125-
arch_path = dist_path / "bin" / "_internal" / "matlab" / "engine" / "_arch.txt"
129+
if IS_MAC:
130+
arch_path = dist_path / "rascal.app" / "Contents" / "Resources" / "matlab" / "engine" / "_arch.txt"
131+
else:
132+
arch_path = dist_path / "bin" / "_internal" / "matlab" / "engine" / "_arch.txt"
133+
126134
if arch_path.exists():
127-
open(dist_path / "bin" / "_internal" / "matlab" / "engine" / "_arch.txt", "w").close()
135+
open(arch_path, "w").close()
128136
else:
129137
warnings.warn(
130138
f"MATLAB engine arch file ({arch_path}) was not found. Ignore if you don't plan to use MATLAB",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<installer-gui-script minSpecVersion="2">
3+
<title>Rascal-2 @VERSION_NAME@</title>
4+
<license file="LICENSE" mime-type="text/plain"/>
5+
<pkg-ref id="com.rascal2.pkg.rascal"/>
6+
<options customize="never" require-scripts="false" rootVolumeOnly="true" hostArchitectures="arm64,x86_64"/>
7+
<choices-outline>
8+
<line choice="com.rascal2.pkg.rascal"/>
9+
</choices-outline>
10+
<choice id="com.rascal2.pkg.rascal" title="RasCAL 2" enabled="false" start_selected="true">
11+
<pkg-ref id="com.rascal2.pkg.rascal" version="@VERSION@" onConclusion="none">rascal.pkg</pkg-ref>
12+
</choice>
13+
</installer-gui-script>

packaging/macos/make.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
RASCAL_PATH="../bundle/rascal.app"
4+
VER_NAME=$1
5+
ARCH_NAME=$2
6+
VER=$VER_NAME
7+
8+
if [[ ${VER_NAME:0:1} == 'v' ]]; then
9+
VER=${VER:1}
10+
fi
11+
12+
# Build Pkg
13+
sed -e "s/@VERSION_NAME@/${VER_NAME}/g" -e "s/@VERSION@/${VER}/g" distribution.xml.in > distribution.xml
14+
pkgbuild --root ${RASCAL_PATH} --identifier com.rascal2.rascal.pkg --version ${VER} --install-location "/Applications/rascal.app" rascal.pkg
15+
productbuild --distribution distribution.xml --resources . "rascal2-${VER}-${ARCH_NAME}.pkg"

rascal2/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
if getattr(sys, "frozen", False):
1414
# we are running in a bundle
1515
SOURCE_PATH = pathlib.Path(sys.executable).parent.parent
16-
if pathlib.Path(SOURCE_PATH / 'MacOS').is_dir():
17-
SOURCE_PATH = SOURCE_PATH / 'Resources'
1816
SITE_PATH = SOURCE_PATH / "bin/_internal"
17+
if pathlib.Path(SOURCE_PATH / "MacOS").is_dir():
18+
SOURCE_PATH = SOURCE_PATH / "Resources"
19+
SITE_PATH = SOURCE_PATH
1920
EXAMPLES_PATH = SOURCE_PATH / "examples"
2021
else:
2122
SOURCE_PATH = pathlib.Path(__file__).parent
@@ -275,7 +276,7 @@ def get_matlab_path(self):
275276
if len(lines) == 4:
276277
install_dir = pathlib.Path(lines[1]).parent.parent
277278
else:
278-
error = "Matlab not found, use 'Tools > Setup Matlab' to specify MATLAB location "
279+
error = "Matlab not found, specify MATLAB location in settings i.e. 'File > Settings' menu"
279280
except FileNotFoundError:
280281
error = "Matlab engine could not be found, ensure it is installed properly"
281282
if error:

rascal2/dialogs/settings_dialog.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ def __init__(self):
165165

166166
def open_folder_selector(self) -> None:
167167
"""Open folder selector."""
168-
folder_name = QtWidgets.QFileDialog.getExistingDirectory(self, "Select MATLAB Directory", ".")
168+
if platform.system() == "Darwin":
169+
folder_name = QtWidgets.QFileDialog.getOpenFileName(self, "Select MATLAB Application", filter="(*.app)")[0]
170+
else:
171+
folder_name = QtWidgets.QFileDialog.getExistingDirectory(self, "Select MATLAB Directory", ".")
169172
if folder_name:
170173
self.matlab_path.setText(folder_name)
171174
self.changed = True
@@ -186,7 +189,13 @@ def set_matlab_paths(self):
186189

187190
path_file.truncate(0)
188191

189-
arch = "win64" if platform.system() == "Windows" else "glnxa64"
192+
if platform.system() == "Windows":
193+
arch = "win64"
194+
elif platform.system() == "Darwin":
195+
arch = "maca64" if platform.mac_ver()[-1] == "arm64" else "maci64"
196+
else:
197+
arch = "glnxa64"
198+
190199
path_file.writelines(
191200
[
192201
f"{arch}\n",

rascal2/ui/view.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ def create_actions(self):
156156
self.settings_action = QtGui.QAction("Settings", self)
157157
self.settings_action.setStatusTip("Settings")
158158
self.settings_action.setIcon(QtGui.QIcon(path_for("settings.png")))
159+
self.settings_action.setMenuRole(QtGui.QAction.MenuRole.PreferencesRole)
159160
self.settings_action.triggered.connect(lambda: self.show_settings_dialog())
160-
self.settings_action.setEnabled(False)
161-
self.disabled_elements.append(self.settings_action)
162161

163162
open_help_action = QtGui.QAction("&Help", self)
164163
open_help_action.setStatusTip("Open Documentation")
@@ -167,13 +166,15 @@ def create_actions(self):
167166
self.open_help_action = open_help_action
168167

169168
open_about_action = QtGui.QAction("&About", self)
170-
open_about_action.setStatusTip("Report RAT version&info")
169+
open_about_action.setStatusTip(f"About {MAIN_WINDOW_TITLE}")
171170
open_about_action.triggered.connect(self.open_about_info)
171+
open_about_action.setMenuRole(QtGui.QAction.MenuRole.AboutQtRole)
172172
self.open_about_action = open_about_action
173173

174174
self.exit_action = QtGui.QAction("E&xit", self)
175175
self.exit_action.setStatusTip(f"Quit {MAIN_WINDOW_TITLE}")
176176
self.exit_action.setShortcut(QtGui.QKeySequence.StandardKey.Quit)
177+
self.exit_action.setMenuRole(QtGui.QAction.MenuRole.QuitRole)
177178
self.exit_action.triggered.connect(self.close)
178179

179180
# Window menu actions
@@ -201,10 +202,6 @@ def create_actions(self):
201202
self.clear_terminal_action.setStatusTip("Clear text in the terminal")
202203
self.clear_terminal_action.triggered.connect(self.terminal_widget.clear)
203204

204-
self.setup_matlab_action = QtGui.QAction("Setup MATLAB", self)
205-
self.setup_matlab_action.setStatusTip("Set the path of the MATLAB executable")
206-
self.setup_matlab_action.triggered.connect(lambda: self.show_settings_dialog(tab_name="Matlab"))
207-
208205
def add_submenus(self, main_menu: QtWidgets.QMenuBar):
209206
"""Add sub menus to the main menu bar"""
210207

@@ -243,8 +240,6 @@ def add_submenus(self, main_menu: QtWidgets.QMenuBar):
243240
tools_menu = main_menu.addMenu("&Tools")
244241
tools_menu.setObjectName("&Tools")
245242
tools_menu.addAction(self.clear_terminal_action)
246-
tools_menu.addSeparator()
247-
tools_menu.addAction(self.setup_matlab_action)
248243

249244
help_menu = main_menu.addMenu("&Help")
250245
help_menu.setObjectName("&Help")

tests/ui/test_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_menu_element_present(test_view, submenu_name):
174174
),
175175
("&Edit", ["&Undo", "&Redo", "Undo &History"]),
176176
("&Windows", ["Tile Windows", "Reset to Default", "Save Current Window Positions"]),
177-
("&Tools", ["Clear Terminal", "", "Setup MATLAB"]),
177+
("&Tools", ["Clear Terminal"]),
178178
("&Help", ["&About", "&Help"]),
179179
],
180180
)

0 commit comments

Comments
 (0)