Created
May 18, 2021 18:33
-
-
Save joaompinto/be09e6d3054290583cd079423179ec6c to your computer and use it in GitHub Desktop.
Install standalobe python on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
cd /tmp | |
function setup_profile() { | |
cat >> ~/.bashrc << _EOF_ | |
export PATH=~/usm/python/install:~/usm/python/install/Scripts:\$PATH | |
_EOF_ | |
} | |
mkdir -p ~/bin ~/usm | |
curl -LO https://github.com/indygreg/python-build-standalone/releases/download/20210506/cpython-3.9.5-x86_64-pc-windows-msvc-shared-pgo-20210506T0943.tar.zst | |
curl -LO https://github.com/facebook/zstd/releases/download/v1.5.0/zstd-v1.5.0-win64.zip | |
rm -rf zstd-v1.5.0-win64 | |
unzip -q zstd-v1.5.0-win64.zip | |
rm -f cpython-3.9.5-x86_64-pc-windows-msvc-shared-pgo-20210506T0943.tar | |
/tmp/zstd-v1.5.0-win64/zstd.exe -d cpython-3.9.5-x86_64-pc-windows-msvc-shared-pgo-20210506T0943.tar.zst | |
tmp_dir=$(mktemp -d) | |
echo Extracing python from cpython-3.9.5-x86_64-pc-windows-msvc-shared-pgo-20210506T0943.tar... | |
tar -C $tmp_dir -xf cpython-3.9.5-x86_64-pc-windows-msvc-shared-pgo-20210506T0943.tar | |
rm -rf ~/usm/python | |
mv $tmp_dir/python ~/usm | |
echo usm python installed at $HOME/usm/python | |
# Fix path for pip install | |
USM_PYTHON="#!$(cygpath --windows $HOME/usm/python/install/python.exe|sed "s/\\\\/\\\\\\\\/g")" | |
sed -i "1s/.*/$USM_PYTHON/" "$HOME/usm/python/install/scripts/pip-script.py" | |
PATH=~/usm/python/install:~/usm/python/install/Scripts:$PATH | |
echo Installing some base python packages... | |
$HOME/usm/python/install/python.exe -m pip -q install httpie ptpython | |
# setup the profile | |
[[ ! -f ~/.bashrc ]] && setup_profile | |
grep -c usm/python/install ~/.bashrc >/dev/null || setup_profile | |
echo "Python interpreter path: $(cygpath --windows $HOME/usm/python/install/python.exe)" | |
echo "" | |
echo "You must restart the GitBash terminal to have the environment reloaded!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment