Skip to content

Commit 070dbef

Browse files
authored
Integrate with copier template. (#16)
1 parent bcbc8b7 commit 070dbef

32 files changed

+684
-32
lines changed

.github/FUNDING.yml.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [{{ repo_namespace }}]

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
cache: "pip"
2121
- run: make dev-lint
2222
- run: make lint
23-
test:
23+
tests:
2424
runs-on: ubuntu-latest
2525
strategy:
2626
matrix:
@@ -32,8 +32,8 @@ jobs:
3232
with:
3333
python-version: ${{ matrix.python-version }}
3434
cache: "pip"
35-
- run: make dev-test
36-
- run: make test
35+
- run: make dev-tests
36+
- run: make tests
3737
- name: Upload coverage to Codecov
3838
uses: codecov/codecov-action@v3
3939
if: matrix.python-version == '3.8'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Read the Docs Pull Request Preview
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
8+
permissions:
9+
pull-requests: write
10+
11+
jobs:
12+
documentation-links:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: readthedocs/actions/preview@v1
16+
with:
17+
project-slug: "{{ repo_name }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Custom
22
*.swp
33
.DS_Store
4+
.copier-answers.yml
45
Pipfile
56

67
# Byte-compiled / optimized / DLL files

.gitignore.jinja

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Custom
2+
*.swp
3+
.DS_Store
4+
{%- if project_name == "Serious Scaffold Python" %}
5+
.copier-answers.yml
6+
{%- endif %}
7+
Pipfile
8+
9+
# Byte-compiled / optimized / DLL files
10+
__pycache__/
11+
*.py[cod]
12+
*$py.class
13+
14+
# C extensions
15+
*.so
16+
17+
# Distribution / packaging
18+
.Python
19+
build/
20+
develop-eggs/
21+
dist/
22+
downloads/
23+
eggs/
24+
.eggs/
25+
lib/
26+
lib64/
27+
parts/
28+
sdist/
29+
var/
30+
wheels/
31+
pip-wheel-metadata/
32+
share/python-wheels/
33+
*.egg-info/
34+
.installed.cfg
35+
*.egg
36+
MANIFEST
37+
38+
# PyInstaller
39+
# Usually these files are written by a python script from a template
40+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
41+
*.manifest
42+
*.spec
43+
44+
# Installer logs
45+
pip-log.txt
46+
pip-delete-this-directory.txt
47+
48+
# Unit test / coverage reports
49+
htmlcov/
50+
.tox/
51+
.nox/
52+
.coverage
53+
.coverage.*
54+
.cache
55+
nosetests.xml
56+
coverage.xml
57+
*.cover
58+
*.py,cover
59+
.hypothesis/
60+
.pytest_cache/
61+
62+
# Translations
63+
*.mo
64+
*.pot
65+
66+
# Django stuff:
67+
*.log
68+
local_settings.py
69+
db.sqlite3
70+
db.sqlite3-journal
71+
72+
# Flask stuff:
73+
instance/
74+
.webassets-cache
75+
76+
# Scrapy stuff:
77+
.scrapy
78+
79+
# Sphinx documentation
80+
docs/_build/
81+
82+
# PyBuilder
83+
target/
84+
85+
# Jupyter Notebook
86+
.ipynb_checkpoints
87+
88+
# IPython
89+
profile_default/
90+
ipython_config.py
91+
92+
# pyenv
93+
.python-version
94+
95+
# pipenv
96+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
98+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
99+
# install all needed dependencies.
100+
#Pipfile.lock
101+
102+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
103+
__pypackages__/
104+
105+
# Celery stuff
106+
celerybeat-schedule
107+
celerybeat.pid
108+
109+
# SageMath parsed files
110+
*.sage.py
111+
112+
# Environments
113+
.env
114+
.venv
115+
env/
116+
venv/
117+
ENV/
118+
env.bak/
119+
venv.bak/
120+
121+
# Spyder project settings
122+
.spyderproject
123+
.spyproject
124+
125+
# Rope project settings
126+
.ropeproject
127+
128+
# mkdocs documentation
129+
/site
130+
131+
# mypy
132+
.mypy_cache/
133+
.dmypy.json
134+
dmypy.json
135+
136+
# Pyre type checker
137+
.pyre/

.pre-commit-config.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
requirements/docs.txt,
2626
requirements/lint.txt,
2727
requirements/package.txt,
28-
requirements/test.txt,
28+
requirements/tests.txt,
2929
]
3030
- id: sort-simple-yaml
3131
files: .pre-commit-config.yaml
@@ -43,7 +43,7 @@ repos:
4343
entry: pipenv run python -m isort
4444
require_serial: true
4545
types_or: [cython, pyi, python]
46-
args: ['--filter-files']
46+
args: ["--filter-files"]
4747
- id: mypy
4848
name: mypy
4949
language: system
@@ -61,3 +61,8 @@ repos:
6161
language: system
6262
entry: pipenv run toml-sort -a -i
6363
types: [toml]
64+
- id: forbidden-files
65+
name: forbidden files
66+
entry: found Copier update rejection files; review them and remove them
67+
language: fail
68+
files: "\\.rej$"

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"autofix",
1616
"automodule",
1717
"codecov",
18+
"huxuan",
1819
"isort",
1920
"mypy",
2021
"pipenv",

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: clean deepclean install dev version pre-commit lint black mypy ruff toml-sort test freeze build upload docs docs-autobuild
1+
.PHONY: clean deepclean install dev version pre-commit lint black mypy ruff toml-sort tests freeze build upload docs docs-autobuild
22

33
# Construct pipenv run command with or without site-packages flag when not in CI environment and pipenv command exists.
44
SITE_PACKAGES_FLAG = $(shell [ "${SS_SITE_PACKAGES}" = "true" ] && echo --site-packages)
@@ -7,18 +7,19 @@ PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 &&
77
# Remove common intermediate files.
88
clean:
99
-rm -rf \
10-
*.egg-info \
10+
.copier-answers.yml \
1111
.coverage \
1212
.mypy_cache \
1313
.pytest_cache \
1414
.ruff_cache \
1515
Pipfile* \
1616
coverage.xml \
1717
dist \
18-
docs\_build
18+
docs/_build
19+
find . -name '*.egg-info' -print0 | xargs -0 rm -rf
1920
find . -name '*.pyc' -print0 | xargs -0 rm -f
2021
find . -name '*.swp' -print0 | xargs -0 rm -f
21-
find . -name '.DS_Store' -print0 | xargs -0 rm -rf
22+
find . -name '.DS_Store' -print0 | xargs -0 rm -r
2223
find . -name '__pycache__' -print0 | xargs -0 rm -rf
2324

2425
deepclean: clean
@@ -32,7 +33,7 @@ dev-%:
3233
${PIPRUN} pip install -e .[$*] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt
3334

3435
dev:
35-
${PIPRUN} pip install -e .[docs,lint,package,test] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt
36+
${PIPRUN} pip install -e .[docs,lint,package,tests] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt
3637
-[ "${CI}" != "true" ] && pre-commit install --hook-type pre-push
3738

3839
version:
@@ -58,8 +59,8 @@ ruff:
5859
toml-sort:
5960
${PIPRUN} toml-sort -a -i pyproject.toml
6061

61-
test:
62-
${PIPRUN} python -m pytest --cov=src --cov-fail-under=$(or $(SS_TEST_COVERAGE_THRESHOLD),0) .
62+
tests:
63+
${PIPRUN} python -m pytest .
6364

6465
freeze:
6566
@${PIPRUN} pip freeze --exclude-editable

Makefile.jinja

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
.PHONY: clean deepclean install dev version pre-commit lint black mypy ruff toml-sort tests freeze build upload docs docs-autobuild
2+
3+
# Construct pipenv run command with or without site-packages flag when not in CI environment and pipenv command exists.
4+
SITE_PACKAGES_FLAG = $(shell [ "${SS_SITE_PACKAGES}" = "true" ] && echo --site-packages)
5+
PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && echo pipenv ${SITE_PACKAGES_FLAG} run)
6+
7+
# Remove common intermediate files.
8+
clean:
9+
-rm -rf \
10+
{%- if project_name == "Serious Scaffold Python" %}
11+
.copier-answers.yml \
12+
{%- endif %}
13+
.coverage \
14+
.mypy_cache \
15+
.pytest_cache \
16+
.ruff_cache \
17+
Pipfile* \
18+
coverage.xml \
19+
dist \
20+
docs/_build
21+
find . -name '*.egg-info' -print0 | xargs -0 rm -rf
22+
find . -name '*.pyc' -print0 | xargs -0 rm -f
23+
find . -name '*.swp' -print0 | xargs -0 rm -f
24+
find . -name '.DS_Store' -print0 | xargs -0 rm -r
25+
find . -name '__pycache__' -print0 | xargs -0 rm -rf
26+
27+
deepclean: clean
28+
-pre-commit uninstall --hook-type pre-push
29+
-pipenv --venv >/dev/null 2>&1 && pipenv --rm
30+
31+
install:
32+
${PIPRUN} pip install -e . -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt
33+
34+
dev-%:
35+
${PIPRUN} pip install -e .[$*] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt
36+
37+
dev:
38+
${PIPRUN} pip install -e .[docs,lint,package,tests] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt
39+
-[ "${CI}" != "true" ] && pre-commit install --hook-type pre-push
40+
41+
version:
42+
${PIPRUN} python -m setuptools_scm
43+
44+
pre-commit:
45+
pre-commit run --all-files
46+
47+
black:
48+
${PIPRUN} python -m black docs tests src
49+
50+
lint: isort mypy ruff toml-sort
51+
52+
isort:
53+
${PIPRUN} python -m isort .
54+
55+
mypy:
56+
${PIPRUN} python -m mypy docs tests src
57+
58+
ruff:
59+
${PIPRUN} python -m ruff docs tests src
60+
61+
toml-sort:
62+
${PIPRUN} toml-sort -a -i pyproject.toml
63+
64+
tests:
65+
${PIPRUN} python -m pytest .
66+
67+
freeze:
68+
@${PIPRUN} pip freeze --exclude-editable
69+
70+
build:
71+
${PIPRUN} python -m build
72+
73+
upload:
74+
${PIPRUN} python -m twine upload dist/*
75+
76+
docs:
77+
${PIPRUN} python -m sphinx.cmd.build docs docs/_build
78+
79+
docs-autobuild:
80+
${PIPRUN} python -m sphinx_autobuild docs docs/_build

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
A serious Python project template for out-of-box and production usage.
44

55
[![GitHub](https://img.shields.io/github/license/huxuan/serious-scaffold-python)](https://github.com/huxuan/serious-scaffold-python/blob/main/LICENSE)
6-
[![Lint & Test Status](https://github.com/huxuan/serious-scaffold-python/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/huxuan/serious-scaffold-python/actions/workflows/ci.yml)
6+
[![CI Status](https://github.com/huxuan/serious-scaffold-python/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/huxuan/serious-scaffold-python/actions/workflows/ci.yml)
77
[![codecov](https://codecov.io/gh/huxuan/serious-scaffold-python/branch/main/graph/badge.svg?token=4JPKXI122N)](https://codecov.io/gh/huxuan/serious-scaffold-python)
8-
[![Documentation Status](https://readthedocs.org/projects/serious-scaffold-python/badge/?version=latest)](https://serious-scaffold-python.readthedocs.io/en/latest/?badge=latest)
8+
[![Documentation Status](https://readthedocs.org/projects/serious-scaffold-python/badge/)](https://serious-scaffold-python.readthedocs.io/)
99
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1010
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
1111
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
@@ -34,12 +34,28 @@ If you find this helpful, please consider [sponsorship](https://github.com/spons
3434
- [`pre-commit`](https://github.com/pre-commit/pre-commit) with [general hooks](https://github.com/pre-commit/pre-commit-hooks) and local linters.
3535
- `Makefile` as the entry point for common actions.
3636
- VSCode settings with recommended extensions.
37-
- GitHub workflows for lint, test, package and documentation preview.
37+
- GitHub workflows for lint, tests, package and documentation preview.
38+
39+
## Usage
40+
41+
1. [Install Copier](https://copier.readthedocs.io/en/stable/#installation).
42+
1. Generate the project with the following command.
43+
44+
```
45+
copier gh:huxuan/serious-scaffold-python /path/to/project
46+
```
47+
48+
1. Initialize the project with git.
49+
50+
```
51+
cd /path/to/project && git init
52+
```
53+
54+
1. Happy hacking.
3855

3956
## Roadmap
4057

4158
- More detailed documentation for all aspects.
42-
- [Copier](https://copier.readthedocs.io/) integration.
4359
- [GitHub Dependabot](https://github.com/dependabot) integration.
4460
- [GitHub issue and pull request templates](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests).
4561
- [Gitlab CI/CD](https://docs.gitlab.com/ee/ci/) integration.

0 commit comments

Comments
 (0)