Skip to content

Commit c362b85

Browse files
committed
menuinst now provides python symbolic link.
Add symbolic link directive to json. Post-install script for macOS now obsolete. Constructor variable replacement does not apply to Linux.
1 parent 6493c97 commit c362b85

File tree

3 files changed

+38
-62
lines changed

3 files changed

+38
-62
lines changed

installers-conda/build_installers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ def _definitions():
278278
"welcome_file": str(welcome_file),
279279
"conclusion_text": "",
280280
"readme_text": "",
281-
"post_install": str(RESOURCES / "post-install.sh"),
282281
}
283282
)
284283

Lines changed: 29 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,46 @@
11
#!/bin/bash
22
set -e
33

4-
echo "*** Running post install script for __NAME__ ..."
5-
6-
cat <<EOF
7-
* __PKG_NAME_LOWER__
8-
* __NAME__
9-
* __VERSION__
10-
* __CHANNELS__
11-
* __WRITE_CONDARC__
12-
* __SHORTCUTS__
13-
* __DEFAULT_PREFIX__
14-
* __LICENSE__
15-
* __FIRST_PAYLOAD_SIZE__
16-
* __SECOND_PAYLOAD_SIZE__
17-
* __MD5__
18-
* __INSTALL_COMMANDS__
19-
* __PLAT__
20-
* __NAME_LOWER__
21-
EOF
4+
echo "*** Running post install script for ${INSTALLER_NAME} ..."
225

236
echo "Args = $@"
247
echo "$(declare -p)"
258

26-
if [[ $OSTYPE == "darwin"* ]]; then
27-
# macOS
28-
ENV_PREFIX=$(cd "${PREFIX}/envs/__NAME_LOWER__"; pwd)
29-
shortcut_path="$(dirname ${DSTROOT})/Applications/__NAME__.app"
9+
name_lower=${INSTALLER_NAME,,}
10+
_shortcut_path="$HOME/.local/share/applications/${name_lower}_${name_lower}.desktop"
11+
shortcut_path="$(dirname ${_shortcut_path})/${name_lower}.desktop"
12+
if [[ -e ${_shortcut_path} ]]; then
13+
echo "Renaming ${_shortcut_path}..."
14+
mv -f "${_shortcut_path}" "${shortcut_path}"
15+
else
16+
echo "${_shortcut_path} does not exist"
17+
fi
18+
19+
case $SHELL in
20+
(*"zsh") shell_init=$HOME/.zshrc ;;
21+
(*"bash") shell_init=$HOME/.bashrc ;;
22+
esac
23+
spyder_exe=$(echo ${PREFIX}/envs/*/bin/spyder)
3024

31-
if [[ -e "$shortcut_path" ]]; then
32-
echo "Creating python symbolic link..."
33-
ln -sf "${ENV_PREFIX}/bin/python" "$shortcut_path/Contents/MacOS/python"
34-
else
35-
echo "ERROR: $shortcut_path does not exist"
36-
exit 1
37-
fi
3825

26+
if [[ ! -e "$spyder_exe" ]]; then
27+
echo "$spyder_exe not found. Alias not created."
28+
elif [[ -z "$shell_init" ]]; then
29+
echo "Aliasing for $SHELL not implemented."
3930
else
40-
# Linux
41-
name_lower=${INSTALLER_NAME,,}
42-
_shortcut_path="$HOME/.local/share/applications/${name_lower}_${name_lower}.desktop"
43-
shortcut_path="$(dirname ${_shortcut_path})/${name_lower}.desktop"
44-
if [[ -e ${_shortcut_path} ]]; then
45-
echo "Renaming ${_shortcut_path}..."
46-
mv -f "${_shortcut_path}" "${shortcut_path}"
47-
else
48-
echo "${_shortcut_path} does not exist"
49-
fi
50-
51-
spyder_exe=$(echo ${PREFIX}/envs/*/bin/spyder)
52-
if [[ -e "$spyder_exe" ]]; then
53-
case $SHELL in
54-
(*"zsh") init_file=$HOME/.zshrc ;;
55-
(*"bash") init_file=$HOME/.bashrc ;;
56-
esac
57-
echo "Aliasing Spyder's executable in $init_file ..."
58-
sed -i "/alias spyder=/{h;s|=.*|=${spyder_exe}|};\${x;/^$/{s||\nalias spyder=${spyder_exe}|;H};x}" $init_file
59-
else
60-
echo "$spyder_exe not found. Alias not created."
61-
fi
62-
63-
echo "Creating uninstall script..."
64-
cat <<EOF > ${PREFIX}/uninstall.sh
31+
echo "Aliasing Spyder's executable in $shell_init ..."
32+
sed -i "/alias spyder=/{h;s|=.*|=${spyder_exe}|};\${x;/^$/{s||\nalias spyder=${spyder_exe}|;H};x}" $shell_init
33+
fi
34+
35+
echo "Creating uninstall script..."
36+
cat <<EOF > ${PREFIX}/uninstall.sh
6537
#!/bin/bash
6638
rm -rf ${shortcut_path}
6739
rm -rf ${PREFIX}
6840
EOF
69-
chmod +x ${PREFIX}/uninstall.sh
41+
chmod +x ${PREFIX}/uninstall.sh
7042

71-
cat <<EOF
43+
cat <<EOF
7244
7345
###############################################################################
7446
Spyder can be launched by standard methods in Gnome and KDE desktop
@@ -90,6 +62,4 @@ $ ${PREFIX}/uninstall.sh
9062
9163
EOF
9264

93-
fi
94-
95-
echo "*** Post install script for __NAME__ complete"
65+
echo "*** Post install script for ${INSTALLER_NAME} complete"

installers-conda/resources/spyder-menu.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@
2121
]
2222
},
2323
"osx": {
24-
"precommand": "eval \"$($SHELL -l -c \"declare -x\")\"\nhere=$(dirname \"$0\")",
25-
"command": ["${here}/python", "${CONDA_PREFIX}/bin/spyder", "$@"],
24+
"precommand": "eval \"$($SHELL -l -c \"declare -x\")\"",
25+
"command": [
26+
"{{ MENU_ITEM_LOCATION }}/Contents/MacOS/python",
27+
"{{ PREFIX }}/bin/spyder",
28+
"$@"
29+
],
30+
"link_in_bundle": {
31+
"{{ PREFIX }}/bin/python": "{{ MENU_ITEM_LOCATION }}/Contents/MacOS/python"
32+
},
2633
"CFBundleName": "Spyder",
2734
"CFBundleDisplayName": "Spyder",
2835
"CFBundleIdentifier": "org.spyder-ide.Spyder",

0 commit comments

Comments
 (0)