If you prefer to run each step yourself instead of using scripts/setup.sh.
Brew is one way to install direnv and pyenv on macOS. On Ubuntu/Debian, use apt instead.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Or use the .pkg installer.
pyenv lets you install and switch between multiple Python versions.
macOS:
brew install pyenvUbuntu / Debian:
sudo apt update && sudo apt install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl libncurses-dev \
xz-utils tk-dev libffi-dev liblzma-dev
curl https://pyenv.run | bashThen install the version you want and set it as your default:
pyenv install 3.13.2
pyenv global 3.13.2Verify it's working:
python3 --versionLoad/unload environment variables from your .envrc. In this case we use it to set the $PYTHONPATH without resorting to sys.path.insert hacks.
macOS:
brew install direnvUbuntu / Debian:
sudo apt install direnvReplace newname below with your project name:
git mv mylib newname
sed -i '' -e 's/mylib/newname/' tests/* .projections.json .github/workflows/python-app.yml .envrc pyproject.toml pyrightconfig.jsonThe version of Python that your project uses is needed by the GitHub Action that runs the tests, and perhaps by your local Python installation tool.
You can create it like this:
echo 3.13.2 > .python-versionThe open source MIT license is used by default (see the LICENSE file). Is it appropriate for this project?
If it is, don't forget to set the year and the name of the copyright holder:
sed -i '' -e "s,<YEAR>,$(date +%Y)," LICENSE
FULL_NAME="$(getent passwd $USER | cut -d : -f 5 | cut -d , -f 1)"
sed -i '' -e "s,<COPYRIGHT HOLDER>,$FULL_NAME," LICENSEIf you're on OS X use:
FULL_NAME="$(bin/osx/getent-passwd.sh $USER | cut -d : -f 5 | cut -d , -f 1)"You need to get everything installed, and that first test running. Start by creating a virtual environment:
python3 -m venv .venv
source .venv/bin/activateNow we can install our development tools:
pip install --upgrade pip
pip install pip-tools
make updateAs you add new development or production dependencies (or both), you can run this command to install them:
make updateMake sure you install
- ruff
- pylance
Note: Pylance incorporates the Pyright type checker so you only need to install Pylance. When Pylance is installed, the Pyright extension will disable itself.
The .projections.json is config for Vim projectionist plugin [1].
This config makes it easy to switch between "alternate" files in the Vim editor; you can easily jump between a Python module and its test file.
[1] https://github.com/tpope/vim-projectionist.
Ruff is a standalone package which runs a linter and a formatter over your code, replacing the need for Black, isort or flake8. Althoug you can add the Ruff extension to your VSCode (editor), you can also add it to your .pre-commit-config.yaml to check your code on a git commit.
pre-commit install