forked from rotki/rotki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-osx.sh
executable file
·55 lines (48 loc) · 1.67 KB
/
setup-osx.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# code parts picked up from
# https://github.com/matthew-brett/multibuild/
MACPYTHON_URL=https://www.python.org/ftp/python
MACPYTHON_PY_PREFIX=/Library/Frameworks/Python.framework/Versions
DOWNLOADS_SDIR=~/
function lex_ver {
# Echoes dot-separated version string padded with zeros
# Thus:
# 3.2.1 -> 003002001
# 3 -> 003000000
echo "$1" | awk -F "." '{printf "%03d%03d%03d", $1, $2, $3}'
}
function unlex_ver {
# Reverses lex_ver to produce major.minor.micro
# Thus:
# 003002001 -> 3.2.1
# 003000000 -> 3.0.0
echo "$((10#${1:0:3}+0)).$((10#${1:3:3}+0)).$((10#${1:6:3}+0))"
}
function strip_ver_suffix {
echo $(unlex_ver $(lex_ver $1))
}
function install_mac_cpython {
local py_version
local py_osx_ver=$2
local py_stripped
local py_inst
py_version="$1"
py_stripped=$(strip_ver_suffix "$py_version")
py_inst=python-${py_version}-macosx${py_osx_ver}.pkg
local inst_path=$DOWNLOADS_SDIR/$py_inst
mkdir -p "$DOWNLOADS_SDIR"
curl $MACPYTHON_URL/"$py_stripped"/"${py_inst}" > "$inst_path"
sudo installer -pkg "$inst_path" -target /
local py_mm=${py_version:0:3}
export PYTHON_EXE=$MACPYTHON_PY_PREFIX/$py_mm/bin/python$py_mm
export PYTHON_DIR=$MACPYTHON_PY_PREFIX/$py_mm
# Install certificates for Python 3.6
local inst_cmd="/Applications/Python ${py_mm}/Install Certificates.command"
if [ -e "$inst_cmd" ]; then
sh "$inst_cmd"
fi
# If the signature is not removed from Python the PyInstaller will fail
codesign --remove-signature "$PYTHON_DIR/Python"
}
install_mac_cpython "3.7.9" "10.9"
echo "PATH=$PYTHON_DIR:$PYTHON_DIR/bin:$PATH" >> $GITHUB_ENV