Skip to content

Latest commit

 

History

History
147 lines (95 loc) · 3.51 KB

File metadata and controls

147 lines (95 loc) · 3.51 KB

Manual setup

If you prefer to run each step yourself instead of using scripts/setup.sh.

Install brew (optional)

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.

Install Python via pyenv

pyenv lets you install and switch between multiple Python versions.

macOS:

brew install pyenv

Ubuntu / 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 | bash

Then install the version you want and set it as your default:

pyenv install 3.13.2
pyenv global 3.13.2

Verify it's working:

python3 --version

Install direnv

Load/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 direnv

Ubuntu / Debian:

sudo apt install direnv

Rename the main package

Replace 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.json

Choosing the Python version

The 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-version

Reviewing the license

The 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," LICENSE

If you're on OS X use:

FULL_NAME="$(bin/osx/getent-passwd.sh $USER | cut -d : -f 5 | cut -d , -f 1)"

Install packages

You need to get everything installed, and that first test running. Start by creating a virtual environment:

python3 -m venv .venv
source .venv/bin/activate

Now we can install our development tools:

pip install --upgrade pip
pip install pip-tools
make update

As you add new development or production dependencies (or both), you can run this command to install them:

make update

VS Code plugins

Make 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.

VIM plugins

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.

Run a linter & format your code on check in

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