Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c0b7704
refactor: migrate from rye to uv package manager
safurrier Feb 22, 2025
b9b3d61
feat: upgrade to Python 3.12 and modernize Dockerfile with uv
safurrier Feb 22, 2025
312b652
feat: add compile-deps target and simplify setup process
safurrier Feb 22, 2025
e25fc85
feat: add simple example code with clean-example command
safurrier Feb 22, 2025
fd81eab
docs: update documentation and template files for uv migration
safurrier Feb 22, 2025
77d2bc5
Remove unneeded files
safurrier Feb 22, 2025
cfb15f3
feat: add uv-based Python version management and installation
safurrier Feb 22, 2025
3c6fc11
docs: add Python version selection instructions to README
safurrier Feb 22, 2025
d08dd61
refactor: simplify Python version management using uv's auto-install
safurrier Feb 22, 2025
49d12c6
refactor: simplify Python setup using UV_PYTHON_VERSION env var
safurrier Feb 22, 2025
85eb9dc
refactor: update Makefile to use local virtual environment
safurrier Feb 22, 2025
6a180fe
fix: use python3 explicitly for venv creation
safurrier Feb 22, 2025
dcaf397
refactor: update venv creation to use uv instead of python3 -m venv
safurrier Feb 22, 2025
6645de8
The changes look good. I've updated the Makefile to use `uv run -m` i…
safurrier Feb 22, 2025
29ca1cb
build: simplify project dependencies to essential dev tools
safurrier Feb 22, 2025
0cb29e0
build: configure hatchling to include src directory in wheel build
safurrier Feb 22, 2025
4cb1986
fix: add setup dependency to quality check targets in Makefile
safurrier Feb 22, 2025
f3400ac
docs: add license, contributing guide and update repo references
safurrier Feb 22, 2025
444ec84
feat: add project initialization script and dependencies
safurrier Feb 22, 2025
cb3f9fc
feat: add ensure-scripts target to make scripts executable
safurrier Feb 22, 2025
ca35e77
build: update minimum Python version to 3.9
safurrier Feb 22, 2025
398c1ce
feat: add make init target for project initialization
safurrier Feb 22, 2025
e3c3cdf
chore: make init_project.py executable
safurrier Feb 22, 2025
f2c7392
feat: add example code handling options to init script
safurrier Feb 22, 2025
55075d2
feat: add pre-commit hooks configuration to setup process
safurrier Feb 22, 2025
8c3da70
fix: reorder git init and pre-commit hook installation in setup process
safurrier Feb 22, 2025
cc0f7d9
feat: add auto-install of pre-commit hooks during setup
safurrier Feb 22, 2025
037a008
docs: update README with Python version and pre-commit details
safurrier Feb 22, 2025
ff9cba7
docs: update badge from Tests to Code Quality Checks in README
safurrier Feb 22, 2025
658df0d
ruff fixes
safurrier Feb 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,39 @@ on:
pull_request:

jobs:
precommit:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Rye
uses: eifinger/setup-rye@v2

- name: Sync Rye
run: rye sync

- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install uv
run: pip install uv

- name: Install dependencies
run: |
uv pip compile pyproject.toml -o requirements.txt
uv pip compile pyproject.toml --extra dev -o requirements-dev.txt
uv pip sync requirements.txt requirements-dev.txt

- name: Run MyPy
run: rye run mypy src

run: uv pip run mypy src
- name: Run Linter
run: rye lint src

run: uv pip run ruff check src
- name: Run Formatter
run: rye format src

run: uv pip run ruff format src
- name: Run Tests
run: rye run py.test tests --cov=src --cov-report=term-missing
run: uv pip run pytest tests --cov=src --cov-report=term-missing --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.xml
fail_ci_if_error: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ docker/.env
.mypy_cache/*
.pytest_cache/*
.ruff_cache/*
.aider*
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- Integration with uv for dependency management
- Modern Python development tools:
- ruff for linting and formatting
- mypy for type checking
- pytest with coverage reporting
- GitHub Actions workflow for automated testing
- Docker development environment improvements

### Changed
- Switched from pip/venv to uv for environment management
- Updated example code to pass mypy type checking
- Modernized project structure and development workflow
- Updated Python version to 3.12

### Removed
- Legacy dependency management approach
- Outdated Docker configuration elements

### Fixed
- Type hints in example code to pass mypy checks
- Docker environment management
- Development workflow and quality checks

## [0.1.0] - 2024-04-14
- Initial fork from eugeneyan/python-collab-template
- Added Docker environment management
- Setup package installation configuration
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing to Python Collab Template

Thank you for your interest in contributing to this project!

## Getting Started

1. Fork the repository
2. Clone your fork: `git clone git@github.com:your-username/python-collab-template.git`
3. Create a new branch: `git checkout -b feature-name`
4. Make your changes
5. Run quality checks: `make check`
6. Commit your changes: `git commit -m "Description of changes"`
7. Push to your fork: `git push origin feature-name`
8. Open a Pull Request

## Development Setup

```bash
# Install dependencies and set up environment
make setup

# Run all quality checks
make check
```

## Code Quality Standards

- All code must be typed with proper type hints
- Tests must be included for new features
- Documentation must be updated when necessary
- All quality checks must pass (`make check`)

## Pull Request Process

1. Update the README.md with details of significant changes
2. Update the CHANGELOG.md following the existing format
3. The PR will be merged once you have the sign-off of at least one maintainer

## Questions?

Feel free to open an issue for any questions or concerns.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Alex Furrier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
73 changes: 51 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,42 +1,71 @@
install-rye:
curl -sSf https://rye-up.com/get | bash
.PHONY: compile-deps setup clean-pyc clean-test clean-venv clean test mypy lint format check clean-example dev-env refresh-containers rebuild-images build-image push-image

setup:
rye sync
# Development Setup
#################
compile-deps: # Compile dependencies from pyproject.toml
uv pip compile pyproject.toml -o requirements.txt
uv pip compile pyproject.toml --extra dev -o requirements-dev.txt

clean-pyc:
PYTHON_VERSION ?= 3.12

ensure-uv: # Install uv if not present
@which uv > /dev/null || (curl -LsSf https://astral.sh/uv/install.sh | sh)

setup: ensure-uv compile-deps ensure-scripts install-hooks # Install dependencies
UV_PYTHON_VERSION=$(PYTHON_VERSION) uv venv
UV_PYTHON_VERSION=$(PYTHON_VERSION) uv pip sync requirements.txt requirements-dev.txt

install-hooks: # Install pre-commit hooks if in a git repo with hooks configured
@if [ -d .git ] && [ -f .pre-commit-config.yaml ]; then \
echo "Installing pre-commit hooks..."; \
uv run pre-commit install; \
fi

ensure-scripts: # Ensure scripts directory exists and files are executable
mkdir -p scripts
chmod +x scripts/*.py

# Cleaning
#########
clean-pyc: # Remove Python compilation artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean-test:
clean-test: # Remove test and coverage artifacts
rm -f .coverage
rm -f .coverage.*

clean: clean-pyc clean-test
clean-venv: # Remove virtual environment
rm -rf .venv

test: clean setup
rye run py.test tests --cov=src --cov-report=term-missing
clean: clean-pyc clean-test clean-venv

mypy:
rye run mypy src
# Testing and Quality Checks
#########################
test: setup # Run pytest with coverage
uv run -m pytest tests --cov=src --cov-report=term-missing

lint:
rye lint src
mypy: setup # Run type checking
uv run -m mypy src

format:
rye format src
lint: setup # Run ruff linter
uv run -m ruff check src

# TODO: Sphinx not working with Rye yet
# docs: FORCE
# cd docs; rye run sphinx-apidoc -o ./source ./src
# cd docs; rye run sphinx-build -b html ./source ./build
format: setup # Run ruff formatter
uv run -m ruff format src

FORCE:
check: setup test mypy lint format # Run all quality checks

check: setup test mypy format lint
# Project Management
##################
clean-example: # Remove example code (use this to start your own project)
rm -rf src/example.py tests/test_example.py
touch src/__init__.py tests/__init__.py

init: setup # Initialize a new project
uv run python scripts/init_project.py

# Docker
########
Expand Down Expand Up @@ -65,4 +94,4 @@ build-image:

push-image: build-image
@echo Pushing image to container registry
@docker push ${IMAGE_NAME}:${IMAGE_TAG}
@docker push ${IMAGE_NAME}:${IMAGE_TAG}
Loading
Loading