Skip to content

Instantly share code, notes, and snippets.

@BrandonLWhite
Last active January 28, 2022 21:13
Show Gist options
  • Save BrandonLWhite/41b2a16487eef8abd193d9481dfd37f3 to your computer and use it in GitHub Desktop.
Save BrandonLWhite/41b2a16487eef8abd193d9481dfd37f3 to your computer and use it in GitHub Desktop.
Python Dev Install
#!/bin/bash
# To execute this from a command prompt:
# curl https://gist.githubusercontent.com/BrandonLWhite/41b2a16487eef8abd193d9481dfd37f3/raw | bash
# TODO : Determine shell config file. (eg .profile, .zsh, etc). I guess though if we are piping this into bash it is always
# going to be .profile?
# Hell, maybe just add it to both?!
# Create a local user bin folder if one doesn't already exist (recent Linux distros already have this)
# and add it to the PATH if it isn't already there. This is so we don't have to keep adding stuff to the PATH.
mkdir -p $HOME/.local/bin
# TODO Add ~/.local/bin to the PATH if it isn't already. Find an existing script to do this.
# Install pyenv
curl https://pyenv.run | bash
# TODO : Must add to path now!
# Do this with a symlink for the pyenv,
# Then add the eval commands (see if I can get them from the pyenv output)
# Add the pyenv-alias-latest-patch-version so we can reference minor versions without specific patch versions
git clone https://github.com/upside-services/pyenv-alias-latest-patch-version.git $(pyenv root)/plugins/pyenv-alias-latest-patch-version
# Install all the versions we want
pyenv install 3.6:latest
pyenv install 3.9:latest
PIPX_VERSION=3.9
# Set the default version to 3.6, and also allow use of the pipx version.
# This lets 3.6 be ambient for projects that don't yet have .python-version, while letting pipx bind to
# a later version thus any CLI tools we install via pipx will run using the pipx version.
pyenv global 3.6 $PIPX_VERSION
# Now setup tools that use python, using pipx so they are isolated in their own virtual env.
PYENV_VERSION=$PIPX_VERSION python -m pip install --upgrade pip setuptools wheel pipx
pipx install tox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment