Skip to content

Commit aff8be9

Browse files
committed
Initial commit
0 parents  commit aff8be9

File tree

47 files changed

+3848
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3848
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "Switchbox Copier Template",
3+
"image": "mcr.microsoft.com/devcontainers/python:1-3.13-bookworm",
4+
"features": {
5+
"ghcr.io/guiyomh/features/just:0.1.0": { "version": "1.42.4" }
6+
},
7+
"postCreateCommand": "./.devcontainer/postCreateCommand.sh",
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"ms-python.python",
12+
"tamasfe.even-better-toml",
13+
"charliermarsh.ruff",
14+
"nefrob.vscode-just-syntax"
15+
],
16+
"settings": {
17+
"python.testing.pytestArgs": ["tests"],
18+
"python.testing.unittestEnabled": false,
19+
"python.testing.pytestEnabled": true
20+
}
21+
}
22+
}
23+
}

.devcontainer/postCreateCommand.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
# Install uv
4+
curl -LsSf https://astral.sh/uv/install.sh | sh
5+
6+
# Install Dependencies (project + dev)
7+
uv sync --group dev
8+
9+
# Install pre-commit hooks
10+
uv run pre-commit install --install-hooks

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.12'
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v6
20+
with:
21+
enable-cache: 'true'
22+
- name: Install deps
23+
run: uv sync --group dev
24+
- name: Run tests
25+
run: uv run pytest -q

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.venv/
2+
.uv/
3+
.pytest_cache/
4+
.ruff_cache/
5+
*.pyc
6+
__pycache__/
7+
site/
8+
dist/
9+
build/
10+
.DS_Store
11+
tmp/

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-merge-conflict
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace
9+
- id: check-json
10+
- id: check-toml
11+
- id: check-yaml
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.12.7
14+
hooks:
15+
- id: ruff-check
16+
args: [--exit-non-zero-on-fix]
17+
- id: ruff-format

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Contributing
2+
3+
Thanks for your interest in contributing! This repo contains a Copier template; contributions typically change files under `template/` or the template config `copier.yml`.
4+
5+
## Dev setup
6+
7+
```bash
8+
uv sync --group dev
9+
uv run pre-commit install --install-hooks
10+
```
11+
12+
## Run tests
13+
14+
```bash
15+
uv run pytest -q
16+
```
17+
18+
## Docs
19+
20+
```bash
21+
uv run mkdocs serve
22+
```
23+
24+
## PR guidelines
25+
26+
- Keep changes minimal and Copier-native (prefer conditional paths over post-gen scripts)
27+
- Add/adjust tests if conditionals change
28+
- Ensure CI is green (pytest + pre-commit)

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Switchbox Copier Template
2+
3+
This is a standalone Copier template for Switchbox projects. It supports:
4+
5+
- Python-focused development with modern tooling
6+
- Optional features: Data science tools, package publishing, GitHub Actions, AWS CLI
7+
- Python stack options: type checker (mypy/ty), always includes deptry and devcontainers
8+
- Conditional files and directories via Copier-native templated paths, no post-gen cleanup
9+
10+
## Quick start
11+
12+
Install Copier:
13+
14+
```bash
15+
pipx install copier # or: uv tool install copier
16+
```
17+
18+
Generate a project (example: Python + Data Science tools):
19+
20+
```bash
21+
copier copy --defaults --force \
22+
--data python_data_science="y" --data python_package="y" \
23+
. /path/to/new-project
24+
```
25+
26+
See `copier/copier.yml` for all questions and defaults.
27+
28+
## Development
29+
30+
- Install dev deps with uv:
31+
32+
```bash
33+
uv sync --group dev
34+
```
35+
36+
- Run tests (pytest runs copier to generate scenarios and asserts outputs):
37+
38+
```bash
39+
uv run pytest -q
40+
```
41+
42+
- Lint/format:
43+
44+
```bash
45+
uv run pre-commit run -a
46+
```
47+
48+
## Docs
49+
50+
This repo ships MkDocs. To serve locally:
51+
52+
```bash
53+
uv run mkdocs serve
54+
```
55+
56+
## Using the Template
57+
58+
To create a new project from this template:
59+
60+
```bash
61+
# Install copier
62+
uv tool install copier
63+
64+
# Create a new project (requires --trust for git initialization)
65+
copier copy --trust https://github.com/your-org/copier-sb.git my-new-project
66+
```
67+
68+
The template will:
69+
- 🔧 Initialize a git repository
70+
- 📁 Add all generated files to git
71+
- 💾 Create an initial commit
72+
- 🚀 Set up your development environment
73+
74+
### Project Types
75+
76+
You can select one or more of these project types:
77+
- **Python Data Science**: Includes polars, pyarrow, seaborn, numpy, Quarto notebooks
78+
- **Python Package**: Includes build tools, twine, MkDocs documentation
79+
- **R Data Science**: Includes R, renv, Quarto, R extensions
80+
81+
**Note**: You must select at least one project type.
82+
83+
## License
84+
85+
MIT

copier-helper.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
TEMPLATE_DIR="$(cd "$(dirname "$0")" && pwd)"
5+
OUT_DIR="${1:-$TEMPLATE_DIR/tmp/generated}"
6+
7+
# Clean up existing output directory
8+
rm -rf "$OUT_DIR"
9+
mkdir -p "$OUT_DIR"
10+
11+
uvx copier copy --defaults --force --trust \
12+
--data author="Switchbox" \
13+
--data email="hello@switch.box" \
14+
--data author_github_handle="switchbox-data" \
15+
--data project_name="example-project" \
16+
--data project_slug="example_project" \
17+
--data project_description="Example" \
18+
--data python_data_science="y" \
19+
--data python_package="y" \
20+
--data r_data_science="n" \
21+
--data use_github="y" \
22+
--data open_source_license="MIT license" \
23+
--data aws="n" \
24+
"$TEMPLATE_DIR/copier" "$OUT_DIR"
25+
26+
echo "Generated at: $OUT_DIR"

copier/copier.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
_min_copier_version: "9.0.0"
2+
_answers_file: .copier-answers.yml
3+
_subdirectory: template
4+
_exclude:
5+
- ".copierignore"
6+
_templates_suffix: .jinja
7+
8+
author:
9+
type: str
10+
default: "Florian Maas"
11+
help: Your full name
12+
13+
email:
14+
type: str
15+
default: "fpgmaas@gmail.com"
16+
help: Your email address
17+
18+
author_github_handle:
19+
type: str
20+
default: "fpgmaas"
21+
help: Your GitHub handle (without @)
22+
23+
project_name:
24+
type: str
25+
default: "example-project"
26+
help: Project name (also used for repo name)
27+
28+
project_slug:
29+
type: str
30+
default: "[[ project_name|lower|replace('-', '_') ]]"
31+
help: Importable Python package name
32+
33+
project_description:
34+
type: str
35+
default: "This is a template repository for Python projects that use uv for their dependency management."
36+
37+
type_checker:
38+
type: str
39+
choices: ["mypy", "ty"]
40+
default: "ty"
41+
when: "{{ python == 'y' }}"
42+
43+
python_data_science:
44+
type: str
45+
choices: ["y", "n"]
46+
default: "y"
47+
help: "Include Python data science tools (polars, pyarrow, seaborn, numpy, quarto, notebooks) - At least one of: python_data_science, python_package, or r_data_science must be selected"
48+
49+
python_package:
50+
type: str
51+
choices: ["y", "n"]
52+
default: "y"
53+
help: "Include Python package publishing tools (build, twine, mkdocs documentation) - At least one of: python_data_science, python_package, or r_data_science must be selected"
54+
55+
r_data_science:
56+
type: str
57+
choices: ["y", "n"]
58+
default: "n"
59+
help: "Include R data science tools (R, renv, Quarto, R extensions) - At least one of: python_data_science, python_package, or r_data_science must be selected"
60+
61+
use_github:
62+
type: str
63+
choices: ["y", "n"]
64+
default: "y"
65+
help: Include GitHub Actions and issue templates
66+
67+
open_source_license:
68+
type: str
69+
choices:
70+
- "MIT license"
71+
- "BSD license"
72+
- "ISC license"
73+
- "Apache Software License 2.0"
74+
- "GNU General Public License v3"
75+
- "Not open source"
76+
default: "MIT license"
77+
78+
aws:
79+
type: str
80+
choices: ["y", "n"]
81+
default: "y"
82+
83+
# Computed variables
84+
python: "{{ 'y' if (python_data_science == 'y' or python_package == 'y') else 'n' }}"
85+
86+
# Post-generation tasks
87+
_tasks:
88+
- command: git init
89+
description: "🔧 Initialize git repository"
90+
- command: git add .
91+
description: "📁 Add all files to git staging"
92+
- command: git commit -m "🎉 Initial commit from copier template"
93+
description: "💾 Create initial commit"

0 commit comments

Comments
 (0)