Skip to content

Instantly share code, notes, and snippets.

@frgomes
Last active April 5, 2025 23:44
Show Gist options
  • Save frgomes/3c3cb367c63502e6675d65996416b58e to your computer and use it in GitHub Desktop.
Save frgomes/3c3cb367c63502e6675d65996416b58e to your computer and use it in GitHub Desktop.
python :: bootstrap development environment
#!/bin/bash
####################################################################################
# This file is intended to be sourced by a CI server, or used in development mode. #
####################################################################################
# Install uv :: https://pypi.org/project/uv/
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$PATH:${HOME}/.local/bin"
# Here we install some arbitrary version of Python.
# Notice that hatch, to be installed later, has the ability to download and use multiple versions of Python.
v=3.10.12
uv python install ${v}
# Create a virtual environment dependent on cpython installed in the previous step
venv=cpython$(echo ${v} | cut -d'.' -f1-2 | tr -d '.')
p=$(uv python list | grep cpython-${v}-linux-x86_64-gnu | sed -E 's/[ \t]+/ /g' | cut -d' ' -f2)
uv venv -v -p ${p} ~/.virtualenvs/${venv}
source ~/.virtualenvs/${venv}/bin/activate
# Install pip into your cpython installation
pip install pip
# Install pipx into your cpython installation
uv pip install pipx
# Install hatch :: https://hatch.pypa.io
# Notice that we employ pipx, not pip, so that hatch is installed onto a completely isolated location.
pipx install hatch
# adjust PATH
export PATH=${PATH}:${HOME}/.local/bin
# show versions
echo ------------------------------------------------------------------------------------------------------------------------
echo Python environment was set up successfully:
python --version
pip --version
hatch --version
echo ------------------------------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment