Last active
December 10, 2020 05:38
-
-
Save namgivu/b6a0bcc4ecc6b71d1a8b11b1d32b218a to your computer and use it in GitHub Desktop.
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/bash | |
_='run the below scripts line by line not run the whole as a batch file'; | |
_='gist github ref. bit.ly/nnpipenv'; | |
_='create $bashrc soft-linked to ~/.bash_profile, as in macos, if $bashrc file not exists while ~/.bash_profile does exist'; | |
if [[ ! -f ~/.bashrc ]] && [[ -f ~/.bash_profile ]]; then ln -s ~/.bash_profile ~/.bashrc ; fi ; | |
bashrc="$HOME/.bashrc" ; `# must use $HOME instead of ~ here to get '>> $bashrc' working below` | |
_='#region install pyenv for ubuntu 16'; | |
sudo apt update ; | |
sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ | |
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ | |
xz-utils tk-dev libffi-dev ; | |
sudo apt autoremove -y ; | |
git clone https://github.com/pyenv/pyenv.git ~/.pyenv ; | |
echo -e '\n# pyenv setup' >> $HOME/.bashrc ; | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> $HOME/.bashrc ; | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> $HOME/.bashrc ; | |
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> $HOME/.bashrc ; | |
_='restart shell & aftermath check' ; | |
source $HOME/.bashrc ; | |
pyenv --version ; | |
_='resolve common build error ref. from pyenv error message -> https://github.com/pyenv/pyenv/wiki/Common-build-problems' | |
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev ; | |
sudo apt-get install -y libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev ; | |
sudo apt-get install -y xz-utils tk-dev libffi-dev liblzma-dev python-openssl git ; | |
_='latest python version' ; | |
py_release_version='3.6' ; | |
py_release_version='3.8' ; | |
py_latest=`curl -s https://www.python.org/doc/versions/ | grep "release/$py_release_version" | head -n1 | cut -d'>' -f3 | cut -d'<' -f1 | cut -d' ' -f2` ; | |
echo $py_latest ; | |
_='install python :py36x_latest'; | |
pyenv install $py_latest ; | |
`# set it global` | |
pyenv global $py_latest ; | |
source $HOME/.bashrc ; `# must reload to get effect ` | |
python --version ; `# should be :py36x_latest` | |
_='#endregion install pyenv for ubuntu 16'; | |
`#region pipenv installation` | |
`# install pipenv` | |
old='curl https://raw.githubusercontent.com/kennethreitz/pipenv/master/get-pipenv.py | python'; | |
python -m pip install --upgrade pip ; python -m pip install pipenv ; | |
echo -e '\n# pipenv setup' >> $HOME/.bashrc ; | |
echo 'export PATH="~/.local:$PATH"' >> $HOME/.bashrc ; | |
echo 'export PIPENV_VENV_IN_PROJECT=1' >> $HOME/.bashrc ; _="project's venv location will be in the project folder as .venv ref. https://pipenv.readthedocs.io/en/latest/advanced/#pipenv.environments.PIPENV_VENV_IN_PROJECT"; | |
echo "export PIPENV_DEFAULT_PYTHON_VERSION=$py36x_latest" >> $HOME/.bashrc ; _='python version used by pipenv'; | |
echo 'eval "$(pipenv --completion)"' >> $HOME/.bashrc ; _='shell auto-completion ref. https://pipenv.readthedocs.io/en/latest/advanced/#shell-completion' | |
`# restart shell & aftermath check` | |
source $HOME/.bashrc ; | |
pipenv --version ; _='eg. pipenv, version 2018.11.26' ; | |
`#endregion pipenv installation` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment