Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧰 Python Project Skeleton

This repository holds a base for Python based projects.

Getting started

To create a project from this base, clone the project and then set the upstream Github to a new repository.

This skeleton uses UV as a Python package and environment manager.

Run uv sync to initialise the uv project in your environment.

Pre-commit

This repository has basic (and opinionated) pre-commit checks for linting and formatting.

The pre-commit rules and configuration can be found in .pre-commit-config.yml.

Run uv run pre-commit install.

IMPORTANT: Note that Ruff is ran in pre-commit with --fix argument which can change files

Linting & Formatting

Basic Ruff settings can be found in settings.toml. Mostly default settings are used with the exception of line-width which is set to 120.

MyPy

Type checking is performed with MyPy and performed after linting during pre-commit. Ensure any packages added are also represented in the additional-dependencies in .pre-commit-config.yml.

Package installation

Below are some example commands for installing some of the more common packages with UV package manager. Adjust the commands as necessary.

Recommended environment packages: uv add python-dotenv httpx mypy

FastAPI: uv add fastapi --extra standard

Jupyter notebooks (especially for integrated VS Code notebooks): uv add --dev jupyter ipykernel ipython notebook tqdm

Common data packages: uv add pandas numpy scikit-learn matplotlib seaborn

HuggingFace packages: uv add datasets[torch] huggingface-hub transformers[torch]

PyTorch

For PyTorch and related packages depending on the CUDA version on your device, compatible PyTorch package, and device platform, add the following to the pyproject.toml:

[tool.uv.sources]
torch = [
  { index = "pytorch-cu126", marker = "sys_platform == 'linux' or sys_platform == 'win32'" },
]
torchvision = [
  { index = "pytorch-cu126", marker = "sys_platform == 'linux' or sys_platform == 'win32'" },
]

[[tool.uv.index]]
name = "pytorch-cu126"
url = "https://download.pytorch.org/whl/cu126"
explicit = true

Then run the following to fetch the correct packages: uv add torch torchvision

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages