Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
80 changes: 63 additions & 17 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,72 @@
"customizations": {
"vscode": {
"settings": {
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.ruff": true
},
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": true,
"source.fixAll.ruff": true
"todo-tree.regex.enableMultiLine": true,
"editor.rulers": [
{
"column": 72,
"color": "#4a4f63"
},
{
"column": 88,
"color": "#7a8ad1"
}
],
"autoDocstring.docstringFormat": "google-notypes",
"autoDocstring.startOnNewLine": true,
"better-comments.tags": [
{
"tag": "!!",
"color": "#F6FF33",
"strikethrough": false,
"backgroundColor": "transparent"
},
{
"tag": "#!",
"color": "#3498DB",
"strikethrough": false,
"backgroundColor": "transparent"
},
{
"tag": "TODO",
"color": "#FF8C00",
"strikethrough": false,
"backgroundColor": "transparent"
},
{
"tag": "//",
"color": "#68FF33",
"strikethrough": false,
"backgroundColor": "transparent"
},
{
"tag": "**",
"color": "#FF33EC",
"strikethrough": false,
"backgroundColor": "transparent"
}
],
"[python]": {
"editor.formatOnType": true
},
"python.defaultInterpreterPath": "/home/jovyan/envs/env/bin/python",
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.rulers": [88],
"ruff.lint.enable": true,
"ruff.format.enable": true,
"ruff.organizeImports": true,
"ruff.fixAll": true
"prettier.printWidth": 88,
"prettier.proseWrap": "always"
},
"extensions": ["ms-python.python", "charliermarsh.ruff"]
"extensions": [
"njpwerner.autodocstring",
"aaron-bond.better-comments",
"esbenp.prettier-vscode",
"ms-python.python",
"ms-python.debugpy",
"Gruntfuggly.todo-tree"
]
}
},
"features": {
Expand Down
12 changes: 4 additions & 8 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/bin/bash

set -e

echo "Checking for uv..."
if ! command -v uv &> /dev/null; then
echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh > /dev/null 2>&1
echo "✅ uv installed."
else
echo "✅ uv already installed."
fi
echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh > /dev/null 2>&1
echo "✅ uv installed."

echo "Installing system dependencies..."
sudo apt-get update > /dev/null 2>&1
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-mkdocs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ runs:
echo "Deploying Docs Version: ${{ inputs.docs-version }}"
uv run mike deploy --push --update-aliases "${{ inputs.docs-version }}" latest

- name: Set Default Version
- name: Set Default Version to Docs
shell: bash
run: |
echo "Setting 'Latest' as Default Version"
Expand Down
4 changes: 3 additions & 1 deletion .github/actions/setup-python-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ runs:
using: composite
steps:
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v5
uses: astral-sh/setup-uv@v7
with:
version: "0.9.23"
python-version: ${{ inputs.src-python-version }}
enable-cache: true

- name: Install dependencies with uv
id: install-deps
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI/CD Pipeline

on:
push:
branches: ["*"]
branches: [main, dev]
pull_request:
branches: [main, dev]

Expand All @@ -18,14 +18,14 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v6

- name: Setup Python & Install Dependencies
- name: Setup Python Environment
uses: ./.github/actions/setup-python-env
with:
src-python-version: ${{ env.SRC_PYTHON_VERSION }}
uv-group: "pipeline"
uv-extra: "--all-extras"

build-deploy-mkdocs:
build-deploy-docs:
if: github.ref == 'refs/heads/main'
name: Build MkDocs Documentation
runs-on: ubuntu-latest
Expand All @@ -42,7 +42,7 @@ jobs:
with:
fetch-depth: 0

- name: Setup Python & Install Dependencies
- name: Setup Python Environment
uses: ./.github/actions/setup-python-env
with:
src-python-version: ${{ env.SRC_PYTHON_VERSION }}
Expand All @@ -52,7 +52,7 @@ jobs:
id: version
uses: ./.github/actions/obtain-version

- name: Build MkDocs Site with Mike
- name: Build Documentation
uses: ./.github/actions/build-mkdocs
with:
docs-version: ${{ steps.version.outputs.version }}
Expand All @@ -61,7 +61,7 @@ jobs:
if: github.ref == 'refs/heads/main'
name: Create Release
runs-on: ubuntu-latest
needs: build-deploy-mkdocs
needs: build-deploy-docs

permissions:
contents: write
Expand All @@ -72,7 +72,7 @@ jobs:
with:
fetch-depth: 0

- name: Setup Python & Install Dependencies
- name: Setup Python Environment
uses: ./.github/actions/setup-python-env
with:
src-python-version: ${{ env.SRC_PYTHON_VERSION }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/saved_objects/
/runs/
__pycache__/
.vscode/
.mypy_cache/
/results/
*build/
Expand Down
20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# Declare all phony targets
.PHONY: install clean doc pipeline all
.PHONY: setup \
clean-cache-temp-files \
doc \
pipeline all

# Default target
.DEFAULT_GOAL := all

# Install project dependencies
install:
setup:
@echo "Installing dependencies..."
@uv sync --all-extras
@echo "✅ Dependencies installed."

# Clean cache and temporary files
clean:
clean-cache-temp-files:
@echo "Cleaning cache and temporary files..."
@find . -type d -name __pycache__ -exec rm -rf {} +
@find . -type d -name .pytest_cache -exec rm -rf {} +
@find . -type d -name .mypy_cache -exec rm -rf {} +
@find . -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete
@echo "✅ Clean complete."

# Serve documentation locally
doc:
@echo "Serving documentation..."
@uv run mkdocs serve

# Run code checks and tests
pipeline: clean
pipeline: clean-cache-temp-files
@echo "✅ Pipeline complete."

# Run full workflow including install and docs
all: install pipeline doc
all: setup pipeline doc
@echo "✅ All tasks complete."
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
</a>
</p>

# 🐍 Python Project Template
# Python Project Template

Python Project Template provides a ready-to-use structure for Python projects,
integrating best practices for code quality, testing, security, documentation, and
CI/CD. It helps developers start new projects quickly with a maintainable and
professional foundation.
integrating best practices for code quality, testing, security, documentation, and CI/CD.
It helps developers start new projects quickly with a maintainable and professional
foundation.

## Features

Expand All @@ -32,9 +32,9 @@ And more.

## Getting Started

Before starting, ensure that you have required Python installed and a virtual
environment set up. It is recommended to create an isolated environment (e.g., using
`venv`) to manage dependencies cleanly. Additionally, ensure that
Before starting, ensure that you have required Python installed and a virtual environment
set up. It is recommended to create an isolated environment (e.g., using `venv`) to
manage dependencies cleanly. Additionally, ensure that
[`uv`](https://github.com/astral-sh/uv) is installed in your environment to handle
grouped dependency installations.

Expand Down Expand Up @@ -80,4 +80,3 @@ make all

This ensures that the project environment is fully prepared for development and
validation.

1 change: 1 addition & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"mkdocs_repo_url": "https://github.com/user-name/repo-name",
"mkdocs_site_url": "https://repo-name-web-site",
"add_dev_container_folder": ["yes", "no"],
"add_vscode_folder": ["yes", "no"],
"add_notebooks_folder": ["yes", "no"],
"add_prompts_folder": ["yes", "no"],
"_copy_without_render": ["*action.yml", "*.js"]
Expand Down
15 changes: 7 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
</a>
</p>

# 🐍 Python Project Template
# Python Project Template

Python Project Template provides a ready-to-use structure for Python projects,
integrating best practices for code quality, testing, security, documentation, and
CI/CD. It helps developers start new projects quickly with a maintainable and
professional foundation.
integrating best practices for code quality, testing, security, documentation, and CI/CD.
It helps developers start new projects quickly with a maintainable and professional
foundation.

## Features

Expand All @@ -32,9 +32,9 @@ And more.

## Getting Started

Before starting, ensure that you have required Python installed and a virtual
environment set up. It is recommended to create an isolated environment (e.g., using
`venv`) to manage dependencies cleanly. Additionally, ensure that
Before starting, ensure that you have required Python installed and a virtual environment
set up. It is recommended to create an isolated environment (e.g., using `venv`) to
manage dependencies cleanly. Additionally, ensure that
[`uv`](https://github.com/astral-sh/uv) is installed in your environment to handle
grouped dependency installations.

Expand Down Expand Up @@ -80,4 +80,3 @@ make all

This ensures that the project environment is fully prepared for development and
validation.

17 changes: 15 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import os
import shutil
from pathlib import Path

project_dir = Path.cwd()

def remove(path: Path) -> None:
"""
Removes a file or directory at the specified path.

If the path points to a file, it is deleted. If it points to a
directory, the entire directory tree is removed recursively.

Args:
path: The filesystem path to remove.

Returns:
None
"""

if path.is_file():
path.unlink()
elif path.is_dir():
shutil.rmtree(path)

folders = {
folders: dict[str, str] = {
".devcontainer": "{{ cookiecutter.add_dev_container_folder }}",
".vscode": "{{ cookiecutter.add_vscode_folder }}",
"notebooks": "{{ cookiecutter.add_notebooks_folder }}",
"prompts": "{{ cookiecutter.add_prompts_folder }}",
}
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "python-project-template"
version = "2.4.8"
version = "2.5.0"
description = "Python project template"
authors = [
{name = "Daniel Bazo Correa", email = "none@none.com"},
Expand Down Expand Up @@ -35,10 +35,10 @@ required-environments = [
[dependency-groups]
documentation = [
"mkdocs==1.6.1",
"mkdocs-material==9.7.0",
"mkdocs-material==9.7.1",
"mkdocs-git-revision-date-localized-plugin==1.5.0",
"mkdocs-git-authors-plugin==0.10.0",
"mkdocs-enumerate-headings-plugin==0.6.2",
"mkdocs-awesome-nav==3.2.0",
"mkdocs-awesome-nav==3.3.0",
"mike==2.1.3"
]
]
Loading