From 54ef051461279a28667b80ef9f1dd944d2ab69b5 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 6 Dec 2022 21:25:37 +0800 Subject: [PATCH 01/27] Minor test. --- copier.yaml | 3 +++ docs/{conf.py => conf.py.jinja} | 2 +- docs/{index.rst => index.rst.jinja} | 2 +- {{_copier_conf.answers_file}}.jinja | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 copier.yaml rename docs/{conf.py => conf.py.jinja} (97%) rename docs/{index.rst => index.rst.jinja} (81%) create mode 100644 {{_copier_conf.answers_file}}.jinja diff --git a/copier.yaml b/copier.yaml new file mode 100644 index 00000000..269187d1 --- /dev/null +++ b/copier.yaml @@ -0,0 +1,3 @@ +project_name: + type: str + help: What is your project name? diff --git a/docs/conf.py b/docs/conf.py.jinja similarity index 97% rename from docs/conf.py rename to docs/conf.py.jinja index b2aa3af0..95dc4405 100644 --- a/docs/conf.py +++ b/docs/conf.py.jinja @@ -9,7 +9,7 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = "serious-scaffold" +project = "{{project_name}}" package = project.replace("-", "_") author = metadata.metadata(package)["Author"] copyright = f"2022, {author}" # noqa: A001 diff --git a/docs/index.rst b/docs/index.rst.jinja similarity index 81% rename from docs/index.rst rename to docs/index.rst.jinja index 2fbb07a2..4af1b07a 100644 --- a/docs/index.rst +++ b/docs/index.rst.jinja @@ -1,4 +1,4 @@ -Welcome to serious-scaffold's documentation! +Welcome to {{project_name}}'s documentation! ============================================ .. toctree:: diff --git a/{{_copier_conf.answers_file}}.jinja b/{{_copier_conf.answers_file}}.jinja new file mode 100644 index 00000000..2e5b1f4e --- /dev/null +++ b/{{_copier_conf.answers_file}}.jinja @@ -0,0 +1 @@ +{{_copier_answers|to_nice_yaml}} From 4ec92401266bb7e5a6ebf4d4c90bba60e837ca13 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 6 Dec 2022 21:53:22 +0800 Subject: [PATCH 02/27] Add pre-commit for copier reject files. --- .pre-commit-config.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 27f118e5..1f94cc60 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: entry: pipenv run python -m isort require_serial: true types_or: [cython, pyi, python] - args: ['--filter-files'] + args: ["--filter-files"] - id: mypy name: mypy language: system @@ -61,3 +61,8 @@ repos: language: system entry: pipenv run toml-sort -a -i types: [toml] + - id: forbidden-files + name: forbidden files + entry: found Copier update rejection files; review them and remove them + language: fail + files: "\\.rej$" From f48dc441513d3dae7defabe1e56a43bf7945552d Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 6 Dec 2022 21:53:39 +0800 Subject: [PATCH 03/27] Tempalte configuration. --- .vscode/settings.json | 1 + copier.yaml | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2bb9879b..6bd8caa6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,6 +15,7 @@ "autofix", "automodule", "codecov", + "huxuan", "isort", "mypy", "pipenv", diff --git a/copier.yaml b/copier.yaml index 269187d1..f3546a76 100644 --- a/copier.yaml +++ b/copier.yaml @@ -1,3 +1,29 @@ project_name: type: str - help: What is your project name? + help: "Project name in CamelCase:" + default: Serious Scaffold Python + +repo_namespace: + type: str + help: "GitHub username, organization or Gitlab namespace:" + default: huxuan + +github_username: + type: str + help: "Github username:" + default: "{{ repo_namespace }}" + +repo_name: + type: str + help: "Repo name:" + default: "{{ project_name|lower|replace(' ', '-') }}" + +package_name: + type: str + help: "Package name:" + default: "{{ repo_name|regex_replace('-python$','') }}" + +module_name: + type: str + help: "Module name:" + default: "{{ package_name|lower|replace('-', '_') }}" From ffb689db109700f9d745d75c336556591b762695 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 6 Dec 2022 23:01:01 +0800 Subject: [PATCH 04/27] Init template. --- .github/FUNDING.yml | 1 - .github/FUNDING.yml.jinja | 1 + ...ocs-preview.yml => readthedocs-preview.yml.jinja} | 2 +- .vscode/{settings.json => settings.json.jinja} | 2 +- copier.yaml | 10 ++++++++++ docs/cli/index.rst | 6 ------ docs/cli/index.rst.jinja | 6 ++++++ docs/modules/{index.rst => index.rst.jinja} | 2 +- docs/modules/serious_scaffold.settings.rst | 5 ----- docs/modules/serious_scaffold.settings.rst.jinja | 5 +++++ pyproject.toml => pyproject.toml.jinja | 12 ++++++------ .../__init__.py | 0 src/{serious_scaffold => {{ module_name }}}/cli.py | 0 .../settings.py.jinja} | 2 +- tests/{cli_test.py => cli_test.py.jinja} | 2 +- tests/pkg_test.py | 8 -------- tests/pkg_test.py.jinja | 8 ++++++++ tests/{settings_test.py => settings_test.py.jinja} | 4 ++-- 18 files changed, 43 insertions(+), 33 deletions(-) delete mode 100644 .github/FUNDING.yml create mode 100644 .github/FUNDING.yml.jinja rename .github/workflows/{readthedocs-preview.yml => readthedocs-preview.yml.jinja} (83%) rename .vscode/{settings.json => settings.json.jinja} (98%) delete mode 100644 docs/cli/index.rst create mode 100644 docs/cli/index.rst.jinja rename docs/modules/{index.rst => index.rst.jinja} (61%) delete mode 100644 docs/modules/serious_scaffold.settings.rst create mode 100644 docs/modules/serious_scaffold.settings.rst.jinja rename pyproject.toml => pyproject.toml.jinja (86%) rename src/{serious_scaffold => {{ module_name }}}/__init__.py (100%) rename src/{serious_scaffold => {{ module_name }}}/cli.py (100%) rename src/{serious_scaffold/settings.py => {{ module_name }}/settings.py.jinja} (92%) rename tests/{cli_test.py => cli_test.py.jinja} (85%) delete mode 100644 tests/pkg_test.py create mode 100644 tests/pkg_test.py.jinja rename tests/{settings_test.py => settings_test.py.jinja} (54%) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 79aa7fa0..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: [huxuan] diff --git a/.github/FUNDING.yml.jinja b/.github/FUNDING.yml.jinja new file mode 100644 index 00000000..844e95aa --- /dev/null +++ b/.github/FUNDING.yml.jinja @@ -0,0 +1 @@ +github: [{ { github_name } }] diff --git a/.github/workflows/readthedocs-preview.yml b/.github/workflows/readthedocs-preview.yml.jinja similarity index 83% rename from .github/workflows/readthedocs-preview.yml rename to .github/workflows/readthedocs-preview.yml.jinja index 43f65889..8f905414 100644 --- a/.github/workflows/readthedocs-preview.yml +++ b/.github/workflows/readthedocs-preview.yml.jinja @@ -14,4 +14,4 @@ jobs: steps: - uses: readthedocs/actions/preview@v1 with: - project-slug: "serious-scaffold-python" + project-slug: "{{ repo_name }}" diff --git a/.vscode/settings.json b/.vscode/settings.json.jinja similarity index 98% rename from .vscode/settings.json rename to .vscode/settings.json.jinja index 6bd8caa6..9c309b70 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json.jinja @@ -15,7 +15,7 @@ "autofix", "automodule", "codecov", - "huxuan", + "{{ github_name }}", "isort", "mypy", "pipenv", diff --git a/copier.yaml b/copier.yaml index f3546a76..7e4b690c 100644 --- a/copier.yaml +++ b/copier.yaml @@ -13,6 +13,16 @@ github_username: help: "Github username:" default: "{{ repo_namespace }}" +author_name: + type: str + help: "Author name:" + default: "{{ github_username }}" + +author_email: + type: str + help: "Author email:" + default: "i@{{ author_name }}.org" + repo_name: type: str help: "Repo name:" diff --git a/docs/cli/index.rst b/docs/cli/index.rst deleted file mode 100644 index 2a2a7513..00000000 --- a/docs/cli/index.rst +++ /dev/null @@ -1,6 +0,0 @@ -Command Line Interface -====================== - -.. click:: serious_scaffold.cli:typer_click_object - :prog: serious-scaffold-cli - :nested: full diff --git a/docs/cli/index.rst.jinja b/docs/cli/index.rst.jinja new file mode 100644 index 00000000..da395198 --- /dev/null +++ b/docs/cli/index.rst.jinja @@ -0,0 +1,6 @@ +Command Line Interface +====================== + +.. click:: {{ module_name }}.cli:typer_click_object + :prog: {{ package_name }}-cli + :nested: full diff --git a/docs/modules/index.rst b/docs/modules/index.rst.jinja similarity index 61% rename from docs/modules/index.rst rename to docs/modules/index.rst.jinja index f8c1b9cd..a5a3e818 100644 --- a/docs/modules/index.rst +++ b/docs/modules/index.rst.jinja @@ -4,4 +4,4 @@ Modules .. toctree:: :maxdepth: 1 - serious_scaffold.settings + {{ module_name }}.settings diff --git a/docs/modules/serious_scaffold.settings.rst b/docs/modules/serious_scaffold.settings.rst deleted file mode 100644 index 3a750116..00000000 --- a/docs/modules/serious_scaffold.settings.rst +++ /dev/null @@ -1,5 +0,0 @@ -serious_scaffold.settings -========================= - -.. automodule:: serious_scaffold.settings - :members: diff --git a/docs/modules/serious_scaffold.settings.rst.jinja b/docs/modules/serious_scaffold.settings.rst.jinja new file mode 100644 index 00000000..cb92c2f9 --- /dev/null +++ b/docs/modules/serious_scaffold.settings.rst.jinja @@ -0,0 +1,5 @@ +{{ module_name }}.settings +========================= + +.. automodule:: {{ module_name }}.settings + :members: diff --git a/pyproject.toml b/pyproject.toml.jinja similarity index 86% rename from pyproject.toml rename to pyproject.toml.jinja index 94de545a..044c7924 100644 --- a/pyproject.toml +++ b/pyproject.toml.jinja @@ -7,8 +7,8 @@ requires = [ [project] authors = [ - {name = "Serious Scaffold"}, - {name = "huxuan", email = "i@huxuan.org"}, + {name = "{{ project_name }}"}, + {name = "{{ author_name }}", email = "{{ author_email }}"}, ] classifiers = [ "Development Status :: 4 - Beta", @@ -31,16 +31,16 @@ keywords = [ "project template", "template", ] -name = "serious_scaffold" +name = "{{ package_name }}" readme = "README.md" requires-python = ">=3.8" [project.scripts] -serious-scaffold-cli = "serious_scaffold.cli:app" +{{ package_name }}-cli = "{{ module_name }}.cli:app" [project.urls] -homepage = "https://github.com/huxuan/serious-scaffold-python/" -issue = "https://github.com/huxuan/serious-scaffold-python/issues" +homepage = "https://github.com/{{ repo_namespace }}{{ repo_name }}/" +issue = "https://github.com/{{ repo_namespace }}{{ repo_name }}/issues" [tool.mypy] check_untyped_defs = true diff --git a/src/serious_scaffold/__init__.py b/src/{{ module_name }}/__init__.py similarity index 100% rename from src/serious_scaffold/__init__.py rename to src/{{ module_name }}/__init__.py diff --git a/src/serious_scaffold/cli.py b/src/{{ module_name }}/cli.py similarity index 100% rename from src/serious_scaffold/cli.py rename to src/{{ module_name }}/cli.py diff --git a/src/serious_scaffold/settings.py b/src/{{ module_name }}/settings.py.jinja similarity index 92% rename from src/serious_scaffold/settings.py rename to src/{{ module_name }}/settings.py.jinja index d3f3ee1c..4ab171df 100644 --- a/src/serious_scaffold/settings.py +++ b/src/{{ module_name }}/settings.py.jinja @@ -14,7 +14,7 @@ class Settings(BaseSettings): class Config: """Config for settings.""" - env_prefix = "SERIOUS_SCAFFOLD_" + env_prefix = "{{ module_name }}_" class GlobalSettings(BaseSettings): diff --git a/tests/cli_test.py b/tests/cli_test.py.jinja similarity index 85% rename from tests/cli_test.py rename to tests/cli_test.py.jinja index f20268cf..2f94a627 100644 --- a/tests/cli_test.py +++ b/tests/cli_test.py.jinja @@ -1,7 +1,7 @@ """Tests for cli.""" from typer.testing import CliRunner -from serious_scaffold.cli import app +from {{ module_name }}.cli import app runner = CliRunner() diff --git a/tests/pkg_test.py b/tests/pkg_test.py deleted file mode 100644 index 1fc66d8b..00000000 --- a/tests/pkg_test.py +++ /dev/null @@ -1,8 +0,0 @@ -"""Unit tests for pkg.""" - -import serious_scaffold - - -def test_pkg() -> None: - """Unit test for pkg.""" - assert serious_scaffold.__package__ == "serious_scaffold" diff --git a/tests/pkg_test.py.jinja b/tests/pkg_test.py.jinja new file mode 100644 index 00000000..78d7b6e2 --- /dev/null +++ b/tests/pkg_test.py.jinja @@ -0,0 +1,8 @@ +"""Unit tests for pkg.""" + +import {{ module_name }} + + +def test_pkg() -> None: + """Unit test for pkg.""" + assert {{ module_name }}.__package__ == "{{ module_name }}" diff --git a/tests/settings_test.py b/tests/settings_test.py.jinja similarity index 54% rename from tests/settings_test.py rename to tests/settings_test.py.jinja index 1bfda499..276d9f5b 100644 --- a/tests/settings_test.py +++ b/tests/settings_test.py.jinja @@ -1,10 +1,10 @@ """Tests for settings.""" import os -from serious_scaffold.settings import global_settings, settings +from {{ module_name }}.settings import global_settings, settings def test_settings() -> None: """Test for default settings.""" - assert settings.logging_level == os.getenv("SERIOUS_SCAFFOLD_LOGGING_LEVEL", "INFO") + assert settings.logging_level == os.getenv("{{ module_name }}_LOGGING_LEVEL", "INFO") assert str(global_settings.ci).lower() == os.getenv("CI", "False").lower() From 281f5036a84496f3cb10df46f07361305854113a Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 6 Dec 2022 23:10:04 +0800 Subject: [PATCH 05/27] Fix template. --- .github/FUNDING.yml.jinja | 2 +- .vscode/{settings.json.jinja => settings.json} | 2 +- docs/conf.py.jinja | 2 +- docs/index.rst.jinja | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename .vscode/{settings.json.jinja => settings.json} (98%) diff --git a/.github/FUNDING.yml.jinja b/.github/FUNDING.yml.jinja index 844e95aa..43e235cc 100644 --- a/.github/FUNDING.yml.jinja +++ b/.github/FUNDING.yml.jinja @@ -1 +1 @@ -github: [{ { github_name } }] +github: [{{ github_name }}] diff --git a/.vscode/settings.json.jinja b/.vscode/settings.json similarity index 98% rename from .vscode/settings.json.jinja rename to .vscode/settings.json index 9c309b70..6bd8caa6 100644 --- a/.vscode/settings.json.jinja +++ b/.vscode/settings.json @@ -15,7 +15,7 @@ "autofix", "automodule", "codecov", - "{{ github_name }}", + "huxuan", "isort", "mypy", "pipenv", diff --git a/docs/conf.py.jinja b/docs/conf.py.jinja index 95dc4405..eaf3713e 100644 --- a/docs/conf.py.jinja +++ b/docs/conf.py.jinja @@ -9,7 +9,7 @@ from importlib import metadata # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = "{{project_name}}" +project = "{{ project_name }}" package = project.replace("-", "_") author = metadata.metadata(package)["Author"] copyright = f"2022, {author}" # noqa: A001 diff --git a/docs/index.rst.jinja b/docs/index.rst.jinja index 4af1b07a..878f7a70 100644 --- a/docs/index.rst.jinja +++ b/docs/index.rst.jinja @@ -1,4 +1,4 @@ -Welcome to {{project_name}}'s documentation! +Welcome to {{ project_name }}'s documentation! ============================================ .. toctree:: From 9b4482ae63ff60dbc12ab7ffcc39cac9e593cded Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 6 Dec 2022 23:15:50 +0800 Subject: [PATCH 06/27] Fix upper case for env. --- src/{{ module_name }}/settings.py.jinja | 2 +- tests/settings_test.py.jinja | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/{{ module_name }}/settings.py.jinja b/src/{{ module_name }}/settings.py.jinja index 4ab171df..f46d00ee 100644 --- a/src/{{ module_name }}/settings.py.jinja +++ b/src/{{ module_name }}/settings.py.jinja @@ -14,7 +14,7 @@ class Settings(BaseSettings): class Config: """Config for settings.""" - env_prefix = "{{ module_name }}_" + env_prefix = "{{ module_name|upper }}_" class GlobalSettings(BaseSettings): diff --git a/tests/settings_test.py.jinja b/tests/settings_test.py.jinja index 276d9f5b..dfb35178 100644 --- a/tests/settings_test.py.jinja +++ b/tests/settings_test.py.jinja @@ -6,5 +6,5 @@ from {{ module_name }}.settings import global_settings, settings def test_settings() -> None: """Test for default settings.""" - assert settings.logging_level == os.getenv("{{ module_name }}_LOGGING_LEVEL", "INFO") + assert settings.logging_level == os.getenv("{{ module_name|upper }}_LOGGING_LEVEL", "INFO") assert str(global_settings.ci).lower() == os.getenv("CI", "False").lower() From f443f129ffb91a2acc9dedcc276181c12a4aa10a Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 6 Dec 2022 23:17:04 +0800 Subject: [PATCH 07/27] Add README.md.jinja. --- README.md.jinja | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md.jinja diff --git a/README.md.jinja b/README.md.jinja new file mode 100644 index 00000000..27f56dca --- /dev/null +++ b/README.md.jinja @@ -0,0 +1 @@ +# {{ project_name }} From b5e8a2282a2051e75e75ab344dba5fc29a249c66 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Mon, 12 Dec 2022 16:30:12 +0800 Subject: [PATCH 08/27] Add copier jinja. --- README.md.jinja | 51 ++++++++++++++++++++++++++++++++++++++++++++ copier.yaml | 14 ++++++------ pyproject.toml.jinja | 2 +- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/README.md.jinja b/README.md.jinja index 27f56dca..caf520e6 100644 --- a/README.md.jinja +++ b/README.md.jinja @@ -1 +1,52 @@ # {{ project_name }} + +{{ project_description }} + +[![GitHub](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }}/)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/blob/main/LICENSE) +[![Lint & Test Status](https://github.com/{{ repo_namespace }}/{{ repo_name }}/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/branch/main/graph/badge.svg?token=4JPKXI122N)](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/) +[![Documentation Status](https://readthedocs.org/projects/{{ repo_name }}/badge/?version=latest)](https://{{ repo_name }}/.readthedocs.io/en/latest/?badge=latest) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) +[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/) +[![{{ project_name }}](https://img.shields.io/badge/serious%20scaffold-python-blue)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/) +[![PyPI](https://img.shields.io/pypi/v/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) + + + +If you find this helpful, please consider [sponsorship](https://github.com/sponsors/huxuan). + +## Features + +- Basic Python project structure as a package with tests and documentation. +- Categorized requirements management with constraints for different environments. +- [`typer`](https://github.com/tiangolo/typer) for CLI with tests and automatic documentation generation. +- [`pydantic`](https://github.com/pydantic/pydantic) for [settings](https://pydantic-docs.helpmanual.io/usage/settings/) with tests and documentation as module samples. +- [`setuptools-scm`](https://github.com/pypa/setuptools_scm/) to extract the version for the package. +- [`black`](https://github.com/psf/black), [`isort`](https://pycqa.github.io/isort/), [`mypy`](http://www.mypy-lang.org/), [`ruff`](https://github.com/charliermarsh/ruff) and [`toml-sort`](https://github.com/pappasam/toml-sort) as linters. +- [`pre-commit`](https://github.com/pre-commit/pre-commit) with [general hooks](https://github.com/pre-commit/pre-commit-hooks) and local linters. +- `Makefile` as the entry point for common actions. +- VSCode settings with recommended extensions. +- GitHub workflows for lint, test, package and documentation preview. + +## Roadmap + +- More detailed documentation for all aspects. +- [Copier](https://copier.readthedocs.io/) integration. +- [GitHub Dependabot](https://github.com/dependabot) integration. +- [GitHub issue and pull request templates](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests). +- [Gitlab CI/CD](https://docs.gitlab.com/ee/ci/) integration. +- [Gitlab issue and merge request templates](https://docs.gitlab.com/ee/user/project/description_templates.html). + +## License + +MIT + +## Contributing + +Any suggestions, discussions and bug fixing are all welcome. diff --git a/copier.yaml b/copier.yaml index 7e4b690c..4ba6095c 100644 --- a/copier.yaml +++ b/copier.yaml @@ -3,20 +3,20 @@ project_name: help: "Project name in CamelCase:" default: Serious Scaffold Python -repo_namespace: +project_description: type: str - help: "GitHub username, organization or Gitlab namespace:" - default: huxuan + help: "Brief project description:" + default: A serious Python project template for out-of-box and production usage. -github_username: +repo_namespace: type: str - help: "Github username:" - default: "{{ repo_namespace }}" + help: "Repo namespace, it should be the name of an user or an organization:" + default: huxuan author_name: type: str help: "Author name:" - default: "{{ github_username }}" + default: "{{ repo_namespace }}" author_email: type: str diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index 044c7924..311feab8 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -19,7 +19,7 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] -description = "A serious python project template for out-of-box and production usage." +description = "{{ project_description }}" dynamic = [ "version", "dependencies", From 11de58148f670cbe3625b0f3cfbc9f55b91a759e Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Mon, 12 Dec 2022 17:18:12 +0800 Subject: [PATCH 09/27] Unify name for tests. --- .github/FUNDING.yml | 1 + .github/workflows/ci.yml | 6 +- .github/workflows/readthedocs-preview.yml | 17 ++++ .pre-commit-config.yaml | 2 +- Makefile | 8 +- README.md | 6 +- README.md.jinja | 8 +- pyproject.toml | 113 ++++++++++++++++++++++ pyproject.toml.jinja | 6 +- requirements/{test.txt => tests.txt} | 0 tests/cli_test.py.jinja | 2 +- tests/pkg_test.py.jinja | 4 +- tests/settings_test.py.jinja | 2 +- 13 files changed, 153 insertions(+), 22 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/readthedocs-preview.yml create mode 100644 pyproject.toml rename requirements/{test.txt => tests.txt} (100%) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..79aa7fa0 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [huxuan] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04695700..0b7a8901 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: cache: "pip" - run: make dev-lint - run: make lint - test: + tests: runs-on: ubuntu-latest strategy: matrix: @@ -32,8 +32,8 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: "pip" - - run: make dev-test - - run: make test + - run: make dev-tests + - run: make tests - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 if: matrix.python-version == '3.8' diff --git a/.github/workflows/readthedocs-preview.yml b/.github/workflows/readthedocs-preview.yml new file mode 100644 index 00000000..43f65889 --- /dev/null +++ b/.github/workflows/readthedocs-preview.yml @@ -0,0 +1,17 @@ +name: Read the Docs Pull Request Preview + +on: + pull_request_target: + types: + - opened + +permissions: + pull-requests: write + +jobs: + documentation-links: + runs-on: ubuntu-latest + steps: + - uses: readthedocs/actions/preview@v1 + with: + project-slug: "serious-scaffold-python" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f94cc60..1af0a0d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: requirements/docs.txt, requirements/lint.txt, requirements/package.txt, - requirements/test.txt, + requirements/tests.txt, ] - id: sort-simple-yaml files: .pre-commit-config.yaml diff --git a/Makefile b/Makefile index 3af4dcac..8a88059b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean deepclean install dev version pre-commit lint black mypy ruff toml-sort test freeze build upload docs docs-autobuild +.PHONY: clean deepclean install dev version pre-commit lint black mypy ruff toml-sort tests freeze build upload docs docs-autobuild # Construct pipenv run command with or without site-packages flag when not in CI environment and pipenv command exists. SITE_PACKAGES_FLAG = $(shell [ "${SS_SITE_PACKAGES}" = "true" ] && echo --site-packages) @@ -32,7 +32,7 @@ dev-%: ${PIPRUN} pip install -e .[$*] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt dev: - ${PIPRUN} pip install -e .[docs,lint,package,test] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt + ${PIPRUN} pip install -e .[docs,lint,package,tests] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt -[ "${CI}" != "true" ] && pre-commit install --hook-type pre-push version: @@ -58,8 +58,8 @@ ruff: toml-sort: ${PIPRUN} toml-sort -a -i pyproject.toml -test: - ${PIPRUN} python -m pytest --cov=src --cov-fail-under=$(or $(SS_TEST_COVERAGE_THRESHOLD),0) . +tests: + ${PIPRUN} python -m pytest --cov=src --cov-fail-under=$(or $(SS_TESTS_COVERAGE_THRESHOLD),0) . freeze: @${PIPRUN} pip freeze --exclude-editable diff --git a/README.md b/README.md index 94fe51a7..2aac1b79 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ A serious Python project template for out-of-box and production usage. [![GitHub](https://img.shields.io/github/license/huxuan/serious-scaffold-python)](https://github.com/huxuan/serious-scaffold-python/blob/main/LICENSE) -[![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) +[![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) [![codecov](https://codecov.io/gh/huxuan/serious-scaffold-python/branch/main/graph/badge.svg?token=4JPKXI122N)](https://codecov.io/gh/huxuan/serious-scaffold-python) -[![Documentation Status](https://readthedocs.org/projects/serious-scaffold-python/badge/?version=latest)](https://serious-scaffold-python.readthedocs.io/en/latest/?badge=latest) +[![Documentation Status](https://readthedocs.org/projects/serious-scaffold-python/badge/)](https://serious-scaffold-python.readthedocs.io/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) @@ -34,7 +34,7 @@ If you find this helpful, please consider [sponsorship](https://github.com/spons - [`pre-commit`](https://github.com/pre-commit/pre-commit) with [general hooks](https://github.com/pre-commit/pre-commit-hooks) and local linters. - `Makefile` as the entry point for common actions. - VSCode settings with recommended extensions. -- GitHub workflows for lint, test, package and documentation preview. +- GitHub workflows for lint, tests, package and documentation preview. ## Roadmap diff --git a/README.md.jinja b/README.md.jinja index caf520e6..e1f47b9b 100644 --- a/README.md.jinja +++ b/README.md.jinja @@ -3,13 +3,13 @@ {{ project_description }} [![GitHub](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }}/)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/blob/main/LICENSE) -[![Lint & Test Status](https://github.com/{{ repo_namespace }}/{{ repo_name }}/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/actions/workflows/ci.yml) +[![CI Status](https://github.com/{{ repo_namespace }}/{{ repo_name }}/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/branch/main/graph/badge.svg?token=4JPKXI122N)](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/) -[![Documentation Status](https://readthedocs.org/projects/{{ repo_name }}/badge/?version=latest)](https://{{ repo_name }}/.readthedocs.io/en/latest/?badge=latest) +[![Documentation Status](https://readthedocs.org/projects/{{ repo_name }}/badge/)](https://{{ repo_name }}/.readthedocs.io/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/) -[![{{ project_name }}](https://img.shields.io/badge/serious%20scaffold-python-blue)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/) +[![Serious Scaffold Python](https://img.shields.io/badge/serious%20scaffold-python-blue)](https://github.com/huxuan/serious-scaffold-python) [![PyPI](https://img.shields.io/pypi/v/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) @@ -32,7 +32,7 @@ If you find this helpful, please consider [sponsorship](https://github.com/spons - [`pre-commit`](https://github.com/pre-commit/pre-commit) with [general hooks](https://github.com/pre-commit/pre-commit-hooks) and local linters. - `Makefile` as the entry point for common actions. - VSCode settings with recommended extensions. -- GitHub workflows for lint, test, package and documentation preview. +- GitHub workflows for lint, tests, package and documentation preview. ## Roadmap diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..38f5f529 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,113 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools", + "setuptools-scm", +] + +[project] +authors = [ + {name = "Serious Scaffold Python"}, + {name = "huxuan", email = "i@huxuan.org"}, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +description = "A serious Python project template for out-of-box and production usage." +dynamic = [ + "version", + "dependencies", + "optional-dependencies", +] +keywords = [ + "out-of-box", + "production", + "project template", + "template", +] +name = "serious-scaffold" +readme = "README.md" +requires-python = ">=3.8" + +[project.scripts] +serious-scaffold-cli = "serious_scaffold.cli:app" + +[project.urls] +homepage = "https://github.com/huxuan/serious-scaffold-python/" +issue = "https://github.com/huxuan/serious-scaffold-python/issues" + +[tool.mypy] +check_untyped_defs = true +disallow_any_unimported = true +disallow_untyped_defs = true +enable_error_code = [ + "ignore-without-code", +] +no_implicit_optional = true +show_error_codes = true +warn_return_any = true +warn_unused_ignores = true + +[tool.pytest.ini_options] +addopts = "-l -s -v --color=yes --durations=0 --cov-report xml" +log_cli = true +log_cli_level = "info" +log_date_format = "%Y-%m-%d %H:%M:%S" +log_format = "%(asctime)s %(levelname)s %(message)s" +minversion = "6.0" + +[tool.ruff] +extend-ignore = [ + "D203", + "D204", + "D213", + "D215", + "D400", + "D404", + "D406", + "D407", + "D408", + "D409", + "D413", +] +extend-select = [ + "I", + "D", + "U", + "N", + "S", + "C", + "FBT", + "B", + "A", + "I25", + "T", + "Q", + "ANN", + "YTT", + "BLE", + "C90", + "RUF", + "M", +] +fix = true +per-file-ignores = {"tests/*" = ["S101"]} +src = ["src"] +target-version = "py38" + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} + +[tool.setuptools.dynamic.optional-dependencies] +docs = {file = ["requirements/docs.txt"]} +lint = {file = ["requirements/lint.txt"]} +package = {file = ["requirements/package.txt"]} +tests = {file = ["requirements/tests.txt"]} + +[tool.setuptools_scm] diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index 311feab8..77af0c13 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -39,8 +39,8 @@ requires-python = ">=3.8" {{ package_name }}-cli = "{{ module_name }}.cli:app" [project.urls] -homepage = "https://github.com/{{ repo_namespace }}{{ repo_name }}/" -issue = "https://github.com/{{ repo_namespace }}{{ repo_name }}/issues" +homepage = "https://github.com/{{ repo_namespace }}/{{ repo_name }}/" +issue = "https://github.com/{{ repo_namespace }}/{{ repo_name }}/issues" [tool.mypy] check_untyped_defs = true @@ -108,6 +108,6 @@ dependencies = {file = ["requirements.txt"]} docs = {file = ["requirements/docs.txt"]} lint = {file = ["requirements/lint.txt"]} package = {file = ["requirements/package.txt"]} -test = {file = ["requirements/test.txt"]} +tests = {file = ["requirements/tests.txt"]} [tool.setuptools_scm] diff --git a/requirements/test.txt b/requirements/tests.txt similarity index 100% rename from requirements/test.txt rename to requirements/tests.txt diff --git a/tests/cli_test.py.jinja b/tests/cli_test.py.jinja index 2f94a627..73565fbb 100644 --- a/tests/cli_test.py.jinja +++ b/tests/cli_test.py.jinja @@ -7,7 +7,7 @@ runner = CliRunner() def test_app() -> None: - """Test for cli.""" + """Tests for cli.""" result = runner.invoke(app) assert result.exit_code == 0 assert result.output == "" diff --git a/tests/pkg_test.py.jinja b/tests/pkg_test.py.jinja index 78d7b6e2..20a8a7e9 100644 --- a/tests/pkg_test.py.jinja +++ b/tests/pkg_test.py.jinja @@ -1,8 +1,8 @@ -"""Unit tests for pkg.""" +"""Tests for pkg.""" import {{ module_name }} def test_pkg() -> None: - """Unit test for pkg.""" + """Tests for pkg.""" assert {{ module_name }}.__package__ == "{{ module_name }}" diff --git a/tests/settings_test.py.jinja b/tests/settings_test.py.jinja index dfb35178..464eb721 100644 --- a/tests/settings_test.py.jinja +++ b/tests/settings_test.py.jinja @@ -5,6 +5,6 @@ from {{ module_name }}.settings import global_settings, settings def test_settings() -> None: - """Test for default settings.""" + """Tests for settings.""" assert settings.logging_level == os.getenv("{{ module_name|upper }}_LOGGING_LEVEL", "INFO") assert str(global_settings.ci).lower() == os.getenv("CI", "False").lower() From db3e4f02810ebf5657296a22fdf59bf4e83285f9 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Mon, 12 Dec 2022 17:19:59 +0800 Subject: [PATCH 10/27] Fix FUNDING template. --- .github/FUNDING.yml.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml.jinja b/.github/FUNDING.yml.jinja index 43e235cc..d354a8b1 100644 --- a/.github/FUNDING.yml.jinja +++ b/.github/FUNDING.yml.jinja @@ -1 +1 @@ -github: [{{ github_name }}] +github: [{{ repo_namespace }}] From ff00269101041224d42b5f13c7a650b8a9484151 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Mon, 12 Dec 2022 17:26:19 +0800 Subject: [PATCH 11/27] Unify README template. --- README.md.jinja | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md.jinja b/README.md.jinja index e1f47b9b..6dfb0343 100644 --- a/README.md.jinja +++ b/README.md.jinja @@ -2,19 +2,19 @@ {{ project_description }} -[![GitHub](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }}/)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/blob/main/LICENSE) +[![GitHub](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }})](https://github.com/{{ repo_namespace }}/{{ repo_name }}/blob/main/LICENSE) [![CI Status](https://github.com/{{ repo_namespace }}/{{ repo_name }}/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/{{ repo_namespace }}/{{ repo_name }}/actions/workflows/ci.yml) -[![codecov](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/branch/main/graph/badge.svg?token=4JPKXI122N)](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/) -[![Documentation Status](https://readthedocs.org/projects/{{ repo_name }}/badge/)](https://{{ repo_name }}/.readthedocs.io/) +[![codecov](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}/branch/main/graph/badge.svg?token=4JPKXI122N)](https://codecov.io/gh/{{ repo_namespace }}/{{ repo_name }}) +[![Documentation Status](https://readthedocs.org/projects/{{ repo_name }}/badge/)](https://{{ repo_name }}.readthedocs.io/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/) +[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![Serious Scaffold Python](https://img.shields.io/badge/serious%20scaffold-python-blue)](https://github.com/huxuan/serious-scaffold-python) [![PyPI](https://img.shields.io/pypi/v/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) From 15f7db1be7a438b30865c492734a7a2f7bd3cb75 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Mon, 12 Dec 2022 17:36:40 +0800 Subject: [PATCH 12/27] Add generated contents. --- README.md.jinja | 2 ++ docs/cli/index.rst | 6 ++++ docs/conf.py | 41 ++++++++++++++++++++++ docs/index.rst | 15 ++++++++ docs/modules/index.rst | 7 ++++ docs/modules/serious_scaffold.settings.rst | 5 +++ pyproject.toml | 1 + pyproject.toml.jinja | 1 + src/serious_scaffold/__init__.py | 1 + src/serious_scaffold/cli.py | 16 +++++++++ src/serious_scaffold/settings.py | 30 ++++++++++++++++ tests/cli_test.py | 13 +++++++ tests/pkg_test.py | 8 +++++ tests/settings_test.py | 10 ++++++ 14 files changed, 156 insertions(+) create mode 100644 docs/cli/index.rst create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/modules/index.rst create mode 100644 docs/modules/serious_scaffold.settings.rst create mode 100644 src/serious_scaffold/__init__.py create mode 100644 src/serious_scaffold/cli.py create mode 100644 src/serious_scaffold/settings.py create mode 100644 tests/cli_test.py create mode 100644 tests/pkg_test.py create mode 100644 tests/settings_test.py diff --git a/README.md.jinja b/README.md.jinja index 6dfb0343..7a00c5db 100644 --- a/README.md.jinja +++ b/README.md.jinja @@ -19,6 +19,8 @@ +Many efforts have been made to ease the project setup, but most of them are only language-specified basic components. In practice, we have to deal with much more details, especially for team projects. Many commonly used tools and configurations need to be handled properly. Moreover, different people tend to have different favors in various aspects. If you are tired of the inefficient setup process and endless discussion, [Serious Scaffold Python](https://github.com/huxuan/serious-scaffold-python) is here to terminate those for Python Projects. + If you find this helpful, please consider [sponsorship](https://github.com/sponsors/huxuan). ## Features diff --git a/docs/cli/index.rst b/docs/cli/index.rst new file mode 100644 index 00000000..2a2a7513 --- /dev/null +++ b/docs/cli/index.rst @@ -0,0 +1,6 @@ +Command Line Interface +====================== + +.. click:: serious_scaffold.cli:typer_click_object + :prog: serious-scaffold-cli + :nested: full diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..11107564 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,41 @@ +"""Configuration file for the Sphinx documentation builder. + +For the full list of built-in configuration values, see the documentation: +https://www.sphinx-doc.org/en/master/usage/configuration.html +""" + +from importlib import metadata + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = "Serious Scaffold Python" +package = project.replace("-", "_") +author = metadata.metadata(package)["Author"] +copyright = f"2022, {author}" # noqa: A001 +release = metadata.version(package) +version = ".".join(release.split(".")[:2]) + + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", + "sphinx.ext.viewcode", + "sphinx_click", + "sphinxcontrib.autodoc_pydantic", +] + +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + +autodoc_pydantic_settings_show_field_summary = False +autodoc_pydantic_settings_show_json = False + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = "furo" +html_static_path = ["_static"] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 00000000..227ddb4a --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,15 @@ +Welcome to Serious Scaffold Python's documentation! +============================================ + +.. toctree:: + :maxdepth: 2 + + cli/index + modules/index + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/modules/index.rst b/docs/modules/index.rst new file mode 100644 index 00000000..f8c1b9cd --- /dev/null +++ b/docs/modules/index.rst @@ -0,0 +1,7 @@ +Modules +======= + +.. toctree:: + :maxdepth: 1 + + serious_scaffold.settings diff --git a/docs/modules/serious_scaffold.settings.rst b/docs/modules/serious_scaffold.settings.rst new file mode 100644 index 00000000..3a750116 --- /dev/null +++ b/docs/modules/serious_scaffold.settings.rst @@ -0,0 +1,5 @@ +serious_scaffold.settings +========================= + +.. automodule:: serious_scaffold.settings + :members: diff --git a/pyproject.toml b/pyproject.toml index 38f5f529..03a9a96b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ disallow_untyped_defs = true enable_error_code = [ "ignore-without-code", ] +exclude = ["src/{{ module_name }}"] no_implicit_optional = true show_error_codes = true warn_return_any = true diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index 77af0c13..0daa6b11 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -49,6 +49,7 @@ disallow_untyped_defs = true enable_error_code = [ "ignore-without-code", ] +exclude = ["src/{{ '{{ module_name }}' }}"] no_implicit_optional = true show_error_codes = true warn_return_any = true diff --git a/src/serious_scaffold/__init__.py b/src/serious_scaffold/__init__.py new file mode 100644 index 00000000..8a8721b5 --- /dev/null +++ b/src/serious_scaffold/__init__.py @@ -0,0 +1 @@ +"""Init for the project.""" diff --git a/src/serious_scaffold/cli.py b/src/serious_scaffold/cli.py new file mode 100644 index 00000000..5a4957d9 --- /dev/null +++ b/src/serious_scaffold/cli.py @@ -0,0 +1,16 @@ +"""Command Line Interface.""" +import typer + +app = typer.Typer() + + +@app.command() +def run() -> None: + """Run command.""" + + +typer_click_object = typer.main.get_command(app) + + +if __name__ == "__main__": + app() # pragma: no cover diff --git a/src/serious_scaffold/settings.py b/src/serious_scaffold/settings.py new file mode 100644 index 00000000..d3f3ee1c --- /dev/null +++ b/src/serious_scaffold/settings.py @@ -0,0 +1,30 @@ +"""Settings Module.""" +import logging +from logging import getLevelName +from typing import Optional + +from pydantic import BaseSettings + + +class Settings(BaseSettings): + """Project specific settings.""" + + logging_level: Optional[str] = getLevelName(logging.INFO) + + class Config: + """Config for settings.""" + + env_prefix = "SERIOUS_SCAFFOLD_" + + +class GlobalSettings(BaseSettings): + """System level settings.""" + + ci: bool = False + + +#: Instance for project specific settings. +settings = Settings() + +#: Instance for system level settings. +global_settings = GlobalSettings() diff --git a/tests/cli_test.py b/tests/cli_test.py new file mode 100644 index 00000000..c3bf2eb4 --- /dev/null +++ b/tests/cli_test.py @@ -0,0 +1,13 @@ +"""Tests for cli.""" +from typer.testing import CliRunner + +from serious_scaffold.cli import app + +runner = CliRunner() + + +def test_app() -> None: + """Tests for cli.""" + result = runner.invoke(app) + assert result.exit_code == 0 + assert result.output == "" diff --git a/tests/pkg_test.py b/tests/pkg_test.py new file mode 100644 index 00000000..35e7fbe5 --- /dev/null +++ b/tests/pkg_test.py @@ -0,0 +1,8 @@ +"""Tests for pkg.""" + +import serious_scaffold + + +def test_pkg() -> None: + """Tests for pkg.""" + assert serious_scaffold.__package__ == "serious_scaffold" diff --git a/tests/settings_test.py b/tests/settings_test.py new file mode 100644 index 00000000..3c7dee5c --- /dev/null +++ b/tests/settings_test.py @@ -0,0 +1,10 @@ +"""Tests for settings.""" +import os + +from serious_scaffold.settings import global_settings, settings + + +def test_settings() -> None: + """Tests for settings.""" + assert settings.logging_level == os.getenv("SERIOUS_SCAFFOLD_LOGGING_LEVEL", "INFO") + assert str(global_settings.ci).lower() == os.getenv("CI", "False").lower() From 0e7242efc773953781330768b29ea7fb666b38aa Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 11:49:38 +0800 Subject: [PATCH 13/27] Add .gitignore template. --- .gitignore | 3 ++ .gitignore.jinja | 134 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 .gitignore.jinja diff --git a/.gitignore b/.gitignore index ca061553..42e91f80 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ .DS_Store Pipfile +# NOTE: Only ignore answers within template project. +.copier-answers.yml + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/.gitignore.jinja b/.gitignore.jinja new file mode 100644 index 00000000..ca061553 --- /dev/null +++ b/.gitignore.jinja @@ -0,0 +1,134 @@ +# Custom +*.swp +.DS_Store +Pipfile + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ From b79c7b4676f9d124b28633da18b936937ed24392 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 15:22:30 +0800 Subject: [PATCH 14/27] Fix package name in docs conf. --- docs/conf.py | 2 +- docs/conf.py.jinja | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 11107564..b2aa3af0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = "Serious Scaffold Python" +project = "serious-scaffold" package = project.replace("-", "_") author = metadata.metadata(package)["Author"] copyright = f"2022, {author}" # noqa: A001 diff --git a/docs/conf.py.jinja b/docs/conf.py.jinja index eaf3713e..0a372a8d 100644 --- a/docs/conf.py.jinja +++ b/docs/conf.py.jinja @@ -9,7 +9,7 @@ from importlib import metadata # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = "{{ project_name }}" +project = "{{ package_name }}" package = project.replace("-", "_") author = metadata.metadata(package)["Author"] copyright = f"2022, {author}" # noqa: A001 From 9728196ff45cdf2ac08166169a5d61c8abc2f281 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 15:24:47 +0800 Subject: [PATCH 15/27] Remove .copier-answers.yml in make clean. --- Makefile | 1 + Makefile.jinja | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 Makefile.jinja diff --git a/Makefile b/Makefile index 8a88059b..826a08b3 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && clean: -rm -rf \ *.egg-info \ + .copier-answers.yml \ .coverage \ .mypy_cache \ .pytest_cache \ diff --git a/Makefile.jinja b/Makefile.jinja new file mode 100644 index 00000000..8a88059b --- /dev/null +++ b/Makefile.jinja @@ -0,0 +1,77 @@ +.PHONY: clean deepclean install dev version pre-commit lint black mypy ruff toml-sort tests freeze build upload docs docs-autobuild + +# Construct pipenv run command with or without site-packages flag when not in CI environment and pipenv command exists. +SITE_PACKAGES_FLAG = $(shell [ "${SS_SITE_PACKAGES}" = "true" ] && echo --site-packages) +PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && echo pipenv ${SITE_PACKAGES_FLAG} run) + +# Remove common intermediate files. +clean: + -rm -rf \ + *.egg-info \ + .coverage \ + .mypy_cache \ + .pytest_cache \ + .ruff_cache \ + Pipfile* \ + coverage.xml \ + dist \ + docs\_build + find . -name '*.pyc' -print0 | xargs -0 rm -f + find . -name '*.swp' -print0 | xargs -0 rm -f + find . -name '.DS_Store' -print0 | xargs -0 rm -rf + find . -name '__pycache__' -print0 | xargs -0 rm -rf + +deepclean: clean + -pre-commit uninstall --hook-type pre-push + -pipenv --venv >/dev/null 2>&1 && pipenv --rm + +install: + ${PIPRUN} pip install -e . -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt + +dev-%: + ${PIPRUN} pip install -e .[$*] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt + +dev: + ${PIPRUN} pip install -e .[docs,lint,package,tests] -c constraints/$(or $(SS_CONSTRAINTS_VERSION),default).txt + -[ "${CI}" != "true" ] && pre-commit install --hook-type pre-push + +version: + ${PIPRUN} python -m setuptools_scm + +pre-commit: + pre-commit run --all-files + +black: + ${PIPRUN} python -m black docs tests src + +lint: isort mypy ruff toml-sort + +isort: + ${PIPRUN} python -m isort . + +mypy: + ${PIPRUN} python -m mypy docs tests src + +ruff: + ${PIPRUN} python -m ruff docs tests src + +toml-sort: + ${PIPRUN} toml-sort -a -i pyproject.toml + +tests: + ${PIPRUN} python -m pytest --cov=src --cov-fail-under=$(or $(SS_TESTS_COVERAGE_THRESHOLD),0) . + +freeze: + @${PIPRUN} pip freeze --exclude-editable + +build: + ${PIPRUN} python -m build + +upload: + ${PIPRUN} python -m twine upload dist/* + +docs: + ${PIPRUN} python -m sphinx.cmd.build docs docs/_build + +docs-autobuild: + ${PIPRUN} python -m sphinx_autobuild docs docs/_build From cfaae83c86c3b2a72b6dd1c508e40dc7a5044ae1 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 15:29:17 +0800 Subject: [PATCH 16/27] Fix package name in docs index. --- docs/index.rst | 2 +- docs/index.rst.jinja | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 227ddb4a..2fbb07a2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,4 +1,4 @@ -Welcome to Serious Scaffold Python's documentation! +Welcome to serious-scaffold's documentation! ============================================ .. toctree:: diff --git a/docs/index.rst.jinja b/docs/index.rst.jinja index 878f7a70..c2bb3890 100644 --- a/docs/index.rst.jinja +++ b/docs/index.rst.jinja @@ -1,4 +1,4 @@ -Welcome to {{ project_name }}'s documentation! +Welcome to {{ package_name }}'s documentation! ============================================ .. toctree:: From 7723ef591f8d0ef1595306a003e3f254c8390cd5 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 16:24:57 +0800 Subject: [PATCH 17/27] Fix tests. --- Makefile | 2 +- Makefile.jinja | 2 +- pyproject.toml | 8 +++++++- pyproject.toml.jinja | 6 ++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 826a08b3..888f9d96 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ toml-sort: ${PIPRUN} toml-sort -a -i pyproject.toml tests: - ${PIPRUN} python -m pytest --cov=src --cov-fail-under=$(or $(SS_TESTS_COVERAGE_THRESHOLD),0) . + ${PIPRUN} python -m pytest . freeze: @${PIPRUN} pip freeze --exclude-editable diff --git a/Makefile.jinja b/Makefile.jinja index 8a88059b..5a7adddf 100644 --- a/Makefile.jinja +++ b/Makefile.jinja @@ -59,7 +59,7 @@ toml-sort: ${PIPRUN} toml-sort -a -i pyproject.toml tests: - ${PIPRUN} python -m pytest --cov=src --cov-fail-under=$(or $(SS_TESTS_COVERAGE_THRESHOLD),0) . + ${PIPRUN} python -m pytest . freeze: @${PIPRUN} pip freeze --exclude-editable diff --git a/pyproject.toml b/pyproject.toml index 03a9a96b..851d9d75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,12 @@ serious-scaffold-cli = "serious_scaffold.cli:app" homepage = "https://github.com/huxuan/serious-scaffold-python/" issue = "https://github.com/huxuan/serious-scaffold-python/issues" +[tool.coverage.report] +fail_under = 100 + +[tool.coverage.run] +omit = ["src/{{ module_name }}/*"] + [tool.mypy] check_untyped_defs = true disallow_any_unimported = true @@ -56,7 +62,7 @@ warn_return_any = true warn_unused_ignores = true [tool.pytest.ini_options] -addopts = "-l -s -v --color=yes --durations=0 --cov-report xml" +addopts = "-l -s --durations=0 --cov=src --cov-report term --cov-report xml" log_cli = true log_cli_level = "info" log_date_format = "%Y-%m-%d %H:%M:%S" diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index 0daa6b11..6660202c 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -42,6 +42,9 @@ requires-python = ">=3.8" homepage = "https://github.com/{{ repo_namespace }}/{{ repo_name }}/" issue = "https://github.com/{{ repo_namespace }}/{{ repo_name }}/issues" +[tool.coverage.report] +fail_under = 100 + [tool.mypy] check_untyped_defs = true disallow_any_unimported = true @@ -49,14 +52,13 @@ disallow_untyped_defs = true enable_error_code = [ "ignore-without-code", ] -exclude = ["src/{{ '{{ module_name }}' }}"] no_implicit_optional = true show_error_codes = true warn_return_any = true warn_unused_ignores = true [tool.pytest.ini_options] -addopts = "-l -s -v --color=yes --durations=0 --cov-report xml" +addopts = "-l -s --durations=0 --cov=src --cov-report term --cov-report xml" log_cli = true log_cli_level = "info" log_date_format = "%Y-%m-%d %H:%M:%S" From 1b7b38d9a8be99508c74f07645c22fbdd87b2fdc Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 16:36:57 +0800 Subject: [PATCH 18/27] Test for condition. --- .gitignore.jinja | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore.jinja b/.gitignore.jinja index ca061553..08df0ee0 100644 --- a/.gitignore.jinja +++ b/.gitignore.jinja @@ -1,6 +1,7 @@ # Custom *.swp .DS_Store +{% if project_name == "Serious Scaffold Python" %}.copier-answers.yml{% endif %} Pipfile # Byte-compiled / optimized / DLL files From 12329dcf3e2c8ca0baf436ec577d8e0f84c6723d Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 16:40:31 +0800 Subject: [PATCH 19/27] Update .gitignore. --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 42e91f80..cecba5bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,8 @@ # Custom *.swp .DS_Store -Pipfile - -# NOTE: Only ignore answers within template project. .copier-answers.yml +Pipfile # Byte-compiled / optimized / DLL files __pycache__/ From 6709ec090e87bba4d95c6f146a2158f95e27f47e Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 16:44:37 +0800 Subject: [PATCH 20/27] Add condition in Makefile, pyproject and gitignore template. --- .gitignore.jinja | 4 +++- Makefile.jinja | 3 +++ pyproject.toml | 8 ++++++-- pyproject.toml.jinja | 12 ++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.gitignore.jinja b/.gitignore.jinja index 08df0ee0..d9a1adf1 100644 --- a/.gitignore.jinja +++ b/.gitignore.jinja @@ -1,7 +1,9 @@ # Custom *.swp .DS_Store -{% if project_name == "Serious Scaffold Python" %}.copier-answers.yml{% endif %} +{%- if project_name == "Serious Scaffold Python" %} +.copier-answers.yml +{%- endif %} Pipfile # Byte-compiled / optimized / DLL files diff --git a/Makefile.jinja b/Makefile.jinja index 5a7adddf..9f079197 100644 --- a/Makefile.jinja +++ b/Makefile.jinja @@ -8,6 +8,9 @@ PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && clean: -rm -rf \ *.egg-info \ +{%- if project_name == "Serious Scaffold Python" %} + .copier-answers.yml \ +{%- endif %} .coverage \ .mypy_cache \ .pytest_cache \ diff --git a/pyproject.toml b/pyproject.toml index 851d9d75..d757c070 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,9 @@ issue = "https://github.com/huxuan/serious-scaffold-python/issues" fail_under = 100 [tool.coverage.run] -omit = ["src/{{ module_name }}/*"] +omit = [ + "src/{{ module_name }}/*", +] [tool.mypy] check_untyped_defs = true @@ -55,7 +57,9 @@ disallow_untyped_defs = true enable_error_code = [ "ignore-without-code", ] -exclude = ["src/{{ module_name }}"] +exclude = [ + "src/{{ module_name }}", +] no_implicit_optional = true show_error_codes = true warn_return_any = true diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index 6660202c..367ecb37 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -45,6 +45,13 @@ issue = "https://github.com/{{ repo_namespace }}/{{ repo_name }}/issues" [tool.coverage.report] fail_under = 100 +[tool.coverage.run] +omit = [ +{%- if project_name == "Serious Scaffold Python" %} + "src/{{ '{{ module_name }}' }}/*", +{%- endif %} +] + [tool.mypy] check_untyped_defs = true disallow_any_unimported = true @@ -52,6 +59,11 @@ disallow_untyped_defs = true enable_error_code = [ "ignore-without-code", ] +exclude = [ +{%- if project_name == "Serious Scaffold Python" %} + "src/{{ '{{ module_name }}' }}", +{%- endif %} +] no_implicit_optional = true show_error_codes = true warn_return_any = true From 25565c0c708ecaff4884c216b8e85c5ebf85c62b Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 17:41:47 +0800 Subject: [PATCH 21/27] Update docs conf & index template. --- docs/conf.py | 9 ++++----- docs/conf.py.jinja | 9 ++++----- docs/index.rst | 4 ++-- docs/index.rst.jinja | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b2aa3af0..274f2d4a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,11 +9,10 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = "serious-scaffold" -package = project.replace("-", "_") -author = metadata.metadata(package)["Author"] -copyright = f"2022, {author}" # noqa: A001 -release = metadata.version(package) +author = "huxuan" +copyright = "2022, huxuan" # noqa: A001 +project = "Serious Scaffold Python" +release = metadata.version("serious-scaffold") version = ".".join(release.split(".")[:2]) diff --git a/docs/conf.py.jinja b/docs/conf.py.jinja index 0a372a8d..678aff2c 100644 --- a/docs/conf.py.jinja +++ b/docs/conf.py.jinja @@ -9,11 +9,10 @@ from importlib import metadata # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = "{{ package_name }}" -package = project.replace("-", "_") -author = metadata.metadata(package)["Author"] -copyright = f"2022, {author}" # noqa: A001 -release = metadata.version(package) +author = "{{ author_name }}" +copyright = "2022, {{ author_name }}" # noqa: A001 +project = "{{ project_name }}" +release = metadata.version("{{ package_name }}") version = ".".join(release.split(".")[:2]) diff --git a/docs/index.rst b/docs/index.rst index 2fbb07a2..20e61e8e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,5 @@ -Welcome to serious-scaffold's documentation! -============================================ +Welcome to Serious Scaffold Python's documentation! +=================================================== .. toctree:: :maxdepth: 2 diff --git a/docs/index.rst.jinja b/docs/index.rst.jinja index c2bb3890..878f7a70 100644 --- a/docs/index.rst.jinja +++ b/docs/index.rst.jinja @@ -1,4 +1,4 @@ -Welcome to {{ package_name }}'s documentation! +Welcome to {{ project_name }}'s documentation! ============================================ .. toctree:: From f9419538732b1ba4c605d85ad0df4d06c6005dd2 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 17:53:51 +0800 Subject: [PATCH 22/27] Update pyproject template. --- pyproject.toml | 1 - pyproject.toml.jinja | 1 - 2 files changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d757c070..706dbaf5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,6 @@ requires = [ [project] authors = [ - {name = "Serious Scaffold Python"}, {name = "huxuan", email = "i@huxuan.org"}, ] classifiers = [ diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index 367ecb37..3a869cf0 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -7,7 +7,6 @@ requires = [ [project] authors = [ - {name = "{{ project_name }}"}, {name = "{{ author_name }}", email = "{{ author_email }}"}, ] classifiers = [ From 5dc74faf8bf706e8c966a571d1f254720a7d073b Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 17:55:01 +0800 Subject: [PATCH 23/27] Fix docs index template. --- docs/index.rst.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst.jinja b/docs/index.rst.jinja index 878f7a70..64582c56 100644 --- a/docs/index.rst.jinja +++ b/docs/index.rst.jinja @@ -1,5 +1,5 @@ Welcome to {{ project_name }}'s documentation! -============================================ +=================================================== .. toctree:: :maxdepth: 2 From f18bff83517ec705f8f576ce89158fa7d16f644c Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 18:04:05 +0800 Subject: [PATCH 24/27] Fix Makefile template. --- Makefile | 6 +++--- Makefile.jinja | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 888f9d96..b70c8182 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && # Remove common intermediate files. clean: -rm -rf \ - *.egg-info \ .copier-answers.yml \ .coverage \ .mypy_cache \ @@ -16,10 +15,11 @@ clean: Pipfile* \ coverage.xml \ dist \ - docs\_build + docs/_build + find . -name '*.egg-info' -print0 | xargs -0 rm -rf find . -name '*.pyc' -print0 | xargs -0 rm -f find . -name '*.swp' -print0 | xargs -0 rm -f - find . -name '.DS_Store' -print0 | xargs -0 rm -rf + find . -name '.DS_Store' -print0 | xargs -0 rm -r find . -name '__pycache__' -print0 | xargs -0 rm -rf deepclean: clean diff --git a/Makefile.jinja b/Makefile.jinja index 9f079197..6295a002 100644 --- a/Makefile.jinja +++ b/Makefile.jinja @@ -7,7 +7,6 @@ PIPRUN := $(shell [ "${CI}" != "true" ] && command -v pipenv > /dev/null 2>&1 && # Remove common intermediate files. clean: -rm -rf \ - *.egg-info \ {%- if project_name == "Serious Scaffold Python" %} .copier-answers.yml \ {%- endif %} @@ -18,10 +17,11 @@ clean: Pipfile* \ coverage.xml \ dist \ - docs\_build + docs/_build + find . -name '*.egg-info' -print0 | xargs -0 rm -rf find . -name '*.pyc' -print0 | xargs -0 rm -f find . -name '*.swp' -print0 | xargs -0 rm -f - find . -name '.DS_Store' -print0 | xargs -0 rm -rf + find . -name '.DS_Store' -print0 | xargs -0 rm -r find . -name '__pycache__' -print0 | xargs -0 rm -rf deepclean: clean From 69b32de020725c244688708b9e7a0345c78bbf81 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 18:05:07 +0800 Subject: [PATCH 25/27] Fix settings docs template. --- ...ld.settings.rst.jinja => {{ module_name }}.settings.rst.jinja} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/modules/{serious_scaffold.settings.rst.jinja => {{ module_name }}.settings.rst.jinja} (100%) diff --git a/docs/modules/serious_scaffold.settings.rst.jinja b/docs/modules/{{ module_name }}.settings.rst.jinja similarity index 100% rename from docs/modules/serious_scaffold.settings.rst.jinja rename to docs/modules/{{ module_name }}.settings.rst.jinja From 92e897f603c0dad4d3fa1143932c06f51227ff17 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 18:28:07 +0800 Subject: [PATCH 26/27] Add exclude for copier. --- copier.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/copier.yaml b/copier.yaml index 4ba6095c..67f792da 100644 --- a/copier.yaml +++ b/copier.yaml @@ -1,3 +1,15 @@ +_exclude: + - "*.py[co]" + - ".DS_Store" + - ".git" + - ".svn" + - "__pycache__" + - "copier.yaml" + - "copier.yml" + - "docs/modules/serious_scaffold.settings.rst" + - "src/serious_scaffold" + - "~*" + project_name: type: str help: "Project name in CamelCase:" From 2a36ca6ba51675ee4509d13093c5f227b3ceafea Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 13 Dec 2022 21:34:42 +0800 Subject: [PATCH 27/27] Add usage in README and remove copier in roadmap. --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2aac1b79..4e3ecdbe 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,26 @@ If you find this helpful, please consider [sponsorship](https://github.com/spons - VSCode settings with recommended extensions. - GitHub workflows for lint, tests, package and documentation preview. +## Usage + +1. [Install Copier](https://copier.readthedocs.io/en/stable/#installation). +1. Generate the project with the following command. + + ``` + copier gh:huxuan/serious-scaffold-python /path/to/project + ``` + +1. Initialize the project with git. + + ``` + cd /path/to/project && git init + ``` + +1. Happy hacking. + ## Roadmap - More detailed documentation for all aspects. -- [Copier](https://copier.readthedocs.io/) integration. - [GitHub Dependabot](https://github.com/dependabot) integration. - [GitHub issue and pull request templates](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests). - [Gitlab CI/CD](https://docs.gitlab.com/ee/ci/) integration.