Python Setup
We use Hatch to manage Python environments. The environments are defined in the pyproject.toml file.
When you run Hatch commands, environments are created in .venvs/ in the project root directory. You can also run hatch env create to create the default environment explicitly, and then configure your IDE to use this environment (.venvs/default) for Python development.
INFO
Sail's Hatch environments use
uvas the package installer for both local development and CI. For custom package indexes or mirrors, configureuvusingUV_INDEX_URLor its configuration files.uvdoes not read pip-specific settings such asPIP_INDEX_URLorpip.conf. The environments also includepipfor manual package installation and IDE support.Hatch will download prebuilt Python interpreters when the specified Python version for an environment is not installed on your host. Note that the prebuilt Python interpreters only track the minor version of Python. If downloading prebuilt Python interpreters fails (e.g. due to network issues), or if you want precise control over the patch version of Python being used in Hatch environments, you can install Python manually so that Hatch can pick up the Python installations. For example, you can use pyenv to install multiple Python versions and run the following command in the project root directory.
bashpyenv local 3.8.19 3.9.19 3.10.14 3.11.9The above command creates a
.python-versionfile (ignored by Git) in the project root directory, so that multiple Python versions are available onPATHdue to the pyenv shim. These Python versions are then available to Hatch for the environment creation.
