diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..2d6e05d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,22 @@ +--- +name: Bug +about: Create a bug report to help us improve +labels: bug +--- + +## Description + + +## Steps to reproduce + + +## Current behavior + + +## Desired behavior + + +## Environment diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..16a57f9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature Request +about: Suggest a new feature or change +labels: feature request +--- + +## Description + + +## Possible Solution + + +## Additional context + + +## Related Issue + diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..2ab2344 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,13 @@ +--- +name: Question +about: Ask a question about how to use the template +labels: question +--- + + + +## Question diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..215477b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ + + + +## Checklist + +* [ ] Add test cases to all the changes you introduce +* [ ] Update the documentation for the changes diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..a001a90 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,19 @@ +# Security Policy + +## Supported Versions + +We will endeavour to support: + +* The most recent minor release with bug fixes. +* The latest minor release from the last major version for 6 months after a new + major version is released with critical bug fixes. +* All versions if a security vulnerability is found provided: + * Upgrading to a later version is non-trivial. + * Sufficient people are using that version to make support worthwhile. + +## Reporting a Vulnerability + +If you find what you think might be a security vulnerability with the project, +please do not create an issue on github. Instead please email +adrianlattes@disroot.org. I'll reply to your email promptly and try to get a +patch out ASAP. diff --git a/cookiecutter.json b/cookiecutter.json index 86b094b..34382fa 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -27,5 +27,6 @@ "GNU General Public License v3", "Not open source" ], + "security_advisories_email": "{{ cookiecutter.email }}", "__gh_slug": "{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" } diff --git a/tests/test_template.py b/tests/test_template.py index ce6e668..65a7e1f 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -69,6 +69,30 @@ def run_command( text=True, ) +@pytest.mark.parametrize("project", ["minimalist"], indirect=True) +def test_version(project: Result): + project_path = project.project_path + assert project_path is not None + project_name = os.path.basename(project_path) + version_file = project_path / "src" / project_name / "version.py" + + process = run_command(f"uv run python {version_file}", project_path) + + assert process.returncode == 0, f"Version failed with error: {process.stderr}" + + assert ( + project_name in process.stdout + ), f"Expected '{project_name}' not found in output: {process.stdout}" + +@pytest.mark.parametrize("project", ["default", "minimalist"], indirect=True) +def test_nix_build(project: Result): + project_path = project.project_path + assert project_path is not None + + process = run_command(f"nix build", project_path) + + assert process.returncode == 0, f"Version failed with error: {process.stderr}" + @pytest.mark.parametrize("project", ["click", "argparse", "minimalist"], indirect=True) def test_main_entrypoint(project: Result): diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug.md b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..62f0e86 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,27 @@ +--- +name: Bug +about: Create a bug report to help us improve {{ cookiecutter.project_slug }} +labels: bug +--- + +## Description + + +## Steps to reproduce + + +## Current behavior + + +## Desired behavior + + +## Environment diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.md b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..5b02188 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature Request +about: Suggest a new feature or change to {{ cookiecutter.project_slug }} +labels: feature request +--- + +## Description + + +## Possible Solution + + +## Additional context + + +## Related Issue + diff --git a/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/question.md b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..97f6918 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,15 @@ +--- +name: Question +about: Ask a question about how to use {{ cookiecutter.project_slug }} +labels: question +--- + + + +## Question diff --git a/{{cookiecutter.project_slug}}/.github/PULL_REQUEST_TEMPLATE.md b/{{cookiecutter.project_slug}}/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..9ddb83b --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ + + +## Checklist + +* [ ] Add test cases to all the changes you introduce +* [ ] Update the documentation for the changes diff --git a/{{cookiecutter.project_slug}}/.github/SECURITY.md b/{{cookiecutter.project_slug}}/.github/SECURITY.md new file mode 100644 index 0000000..418707f --- /dev/null +++ b/{{cookiecutter.project_slug}}/.github/SECURITY.md @@ -0,0 +1,19 @@ +# Security Policy + +## Supported Versions + +We will endeavour to support: + +* The most recent minor release with bug fixes. +* The latest minor release from the last major version for 6 months after a new + major version is released with critical bug fixes. +* All versions if a security vulnerability is found provided: + * Upgrading to a later version is non-trivial. + * Sufficient people are using that version to make support worthwhile. + +## Reporting a Vulnerability + +If you find what you think might be a security vulnerability with +{{ cookiecutter.project_slug }}, please do not create an issue on github. Instead please +email {{ cookiecutter.security_advisories_email }} I'll reply to your email promptly +and try to get a patch out ASAP. diff --git a/{{cookiecutter.project_slug}}/.github/workflows/docs.yml b/{{cookiecutter.project_slug}}/.github/workflows/docs.yml index e065153..baf0ed6 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/docs.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/docs.yml @@ -1,4 +1,3 @@ -{% if cookiecutter.use_mkdocs == 'y' %} name: docs on: @@ -39,11 +38,8 @@ jobs: - name: Install the project with docs dependencies run: uv sync --all-extras --dev --group docs - - name: Generate API documentation - run: python docs/gen_api_docs.py - - name: Build documentation - run: mkdocs build + run: uv run mkdocs build - name: Upload artifact uses: actions/upload-pages-artifact@v3 @@ -61,4 +57,3 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 -{% endif %} diff --git a/{{cookiecutter.project_slug}}/.github/workflows/test.yml b/{{cookiecutter.project_slug}}/.github/workflows/test.yml index a96cff3..a741956 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/test.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: python-version-file: "pyproject.toml" - name: Install the project - run: uv sync --all-extras --dev --group test + run: uv sync --all-extras --dev - name: Run tests run: uv run pytest tests -sv diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 09eaf78..2fb7030 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -11,8 +11,9 @@ repos: hooks: - id: commitizen name: commitizen - entry: commitizen - language: system + entry: cz check + args: [--allow-abort, --commit-msg-file] + language: python stages: [commit-msg] - repo: local hooks: diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index aac81fd..4544e28 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -3,22 +3,5 @@ {{ cookiecutter.project_short_description }} {% if cookiecutter.use_mkdocs == 'y' %} -## Documentation - -This project uses MkDocs for documentation. To build and view the documentation locally: - -```bash -# Install documentation dependencies -uv sync --group docs - -# Generate API documentation -python docs/gen_api_docs.py - -# Serve documentation locally -mkdocs serve -``` - -The documentation will be available at http://127.0.0.1:8000/ - -When you push to the main branch, the documentation will automatically be built and deployed to GitHub Pages. -{% endif %} +[docs](https://{{cookiecutter.github_username}}.github.io/{{cookiecutter.project_slug}}) +{%- endif %} diff --git a/{{cookiecutter.project_slug}}/docs/api/index.md b/{{cookiecutter.project_slug}}/docs/api/index.md deleted file mode 100644 index 65fdecc..0000000 --- a/{{cookiecutter.project_slug}}/docs/api/index.md +++ /dev/null @@ -1,7 +0,0 @@ -{% if cookiecutter.use_mkdocs == 'y' %} -# API Reference - -This section contains auto-generated API reference documentation. - -::: {{ cookiecutter.project_slug }} -{% endif %} diff --git a/{{cookiecutter.project_slug}}/docs/contributing.md b/{{cookiecutter.project_slug}}/docs/contributing.md index fa3f47b..3855430 100644 --- a/{{cookiecutter.project_slug}}/docs/contributing.md +++ b/{{cookiecutter.project_slug}}/docs/contributing.md @@ -1,47 +1,133 @@ -{% if cookiecutter.use_mkdocs == 'y' %} -# Contributing +So you've started using `{{ cookiecutter.project_slug }}` and want to show your +gratitude to the project, depending on your programming skills there are +different ways to do so. -Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. +# I don't know how to program -## Development +There are several ways you can contribute: -To set up this project for local development: +- [Open an issue](https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues/new) if you encounter + any bug or to let us know if you want a new feature to be implemented. +- Spread the word about the program. +- Review the [documentation](https://{{ cookiecutter.github_username }}.github.io/{{ cookiecutter.project_slug }}) and try to improve + it. -1. Clone the repository: - ```bash - git clone https://github.com/{{ cookiecutter.__gh_slug }}.git - cd {{ cookiecutter.project_slug }} - ``` +# I know how to program in Python -2. Set up your development environment: - ```bash - # Using uv (recommended) - uv sync --all-extras --dev +If you have some python knowledge there are some additional ways to contribute. +We've ordered the [issues](https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues) in +[milestones](https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/milestones), check the issues in +the smaller one, as it's where we'll be spending most of our efforts. Try the +[good first +issues](https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22), +as they are expected to be easier to get into the project. - # Or using pip - pip install -e ".[dev]" - ``` +We develop the program with +[TDD](https://en.wikipedia.org/wiki/Test-driven_development), so we expect any +contribution to have it's associated tests. We also try to maintain an updated +[documentation](https://{{ cookiecutter.github_username }}.github.io/{{ cookiecutter.project_slug }}) of the project, so think if +your contribution needs to update it. -3. Install pre-commit hooks: - ```bash - pre-commit install - ``` +We know that the expected code quality is above average. Therefore it might +be changeling to get the initial grasp of the project structure, know how to make the +tests, update the documentation or use all the project technology stack. but please +don't let this fact discourage you from contributing: -## Testing +- If you want to develop a new feature, explain how you'd like to do it in the related issue. +- If you don't know how to test your code, do the pull request without the tests + and we'll try to do them for you. -Run tests using pytest: +# Issues + +Questions, feature requests and bug reports are all welcome as issues. +**To report a security vulnerability, please see our [security +policy](https://github.com/{{ cookiecutter.github_username }}/{{ +cookiecutter.project_slug }}/security/policy) instead.** + +To make it as simple as possible for us to help you, please include the output +of the following call in your issue: ```bash -pytest +uv run src/{{ cookiecutter.project_slug }}/version.py ``` -## Documentation +Please try to always include the above unless you're unable to install `{{ +cookiecutter.project_slug }}` or know it's not relevant to your question or +feature request. -Build the documentation locally: +# Pull Requests -```bash -mkdocs serve -``` +*{{ cookiecutter.project_slug }}* is released regularly so you should see your +improvements release in a matter of days or weeks. + +!!! note + Unless your change is trivial (typo, docs tweak etc.), please create an + issue to discuss the change before creating a pull request. + +If you're looking for something to get your teeth into, check out the ["help +wanted"](https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) +label on github. + +# Development facilities + +To make contributing as easy and fast as possible, you'll want to run tests and +linting locally. + +You'll need to have python 3.10, 3.11, 3.12, or 3.13, uv and git installed. The +nix package manager is also recommended. + +* Clone your fork and go into the repository directory: + + ```bash + git clone git@github.com:/{{ cookiecutter.project_slug }}.git + cd {{ cookiecutter.project_slug }} + ``` + +* Set up the virtualenv for running tests: + + ```bash + uv sync + source env/bin/activate + ``` + +* Checkout a new branch and make your changes: + + ```bash + git checkout -b my-new-feature-branch + ``` + +* Fix formatting and imports: {{ cookiecutter.project_slug }} uses + [black](https://github.com/ambv/black) to enforce formatting and + [isort](https://github.com/timothycrosley/isort) to fix imports. + + ```bash + uv run black + ``` + +* Run tests and linting: + + ```bash + uv run pre-commit + ``` + + There are more sub-commands in Makefile like `test-code`, `test-examples`, + `mypy` or `security` which you might want to use, but generally `make` + should be all you need. + + If you need to pass specific arguments to pytest use the `ARGS` variable, + for example `make test ARGs='-k test_markdownlint_passes'`. + +* Build documentation: If you have changed the documentation, make sure it + builds the static site. Once built it will serve the documentation at + `localhost:8000`: + + ```bash + mkdocs serve + ``` + +* Commit, push, and create your pull request. + +* Make a new release: To generate the changelog of the new changes, build the + package, upload to pypi and clean the build files use `make bump`. -Then open `http://127.0.0.1:8000/` in your browser. -{% endif %} +We'd love you to contribute to *{{ cookiecutter.project_slug }}*! diff --git a/{{cookiecutter.project_slug}}/docs/gen_api_docs.py b/{{cookiecutter.project_slug}}/docs/gen_api_docs.py deleted file mode 100644 index c34d3be..0000000 --- a/{{cookiecutter.project_slug}}/docs/gen_api_docs.py +++ /dev/null @@ -1,69 +0,0 @@ -{% if cookiecutter.use_mkdocs == 'y' %} -#!/usr/bin/env python -""" -Script to automatically generate API documentation for the project. -This creates markdown files for each module in the project. -""" -import os -import pkgutil -import importlib -from pathlib import Path - -# Configuration -PACKAGE_NAME = "{{ cookiecutter.project_slug }}" -API_DOCS_DIR = Path("docs/api") - - -def generate_module_docs(module_name, api_dir): - """Generate documentation for a module.""" - # Create the output file path - rel_path = module_name.replace(f"{PACKAGE_NAME}.", "").replace(".", "/") - output_path = api_dir / f"{rel_path}.md" - - # Create parent directories if they don't exist - output_path.parent.mkdir(parents=True, exist_ok=True) - - # Create the markdown content - content = f"# {module_name}\n\n::: {module_name}\n" - - # Write the content to the file - with open(output_path, "w") as f: - f.write(content) - - print(f"Generated docs for {module_name} at {output_path}") - - -def discover_modules(package_name): - """Discover all modules in the package.""" - package = importlib.import_module(package_name) - modules = [package_name] - - if hasattr(package, "__path__"): - for _, name, is_pkg in pkgutil.iter_modules(package.__path__, f"{package_name}."): - modules.append(name) - if is_pkg: - modules.extend(discover_modules(name)) - - return modules - - -def main(): - """Main function to generate API documentation.""" - # Ensure the API docs directory exists - api_dir = Path(API_DOCS_DIR) - api_dir.mkdir(parents=True, exist_ok=True) - - # Discover all modules - modules = discover_modules(PACKAGE_NAME) - - # Generate documentation for each module - for module_name in modules: - try: - generate_module_docs(module_name, api_dir) - except Exception as e: - print(f"Error generating docs for {module_name}: {e}") - - -if __name__ == "__main__": - main() -{% endif %} diff --git a/{{cookiecutter.project_slug}}/docs/index.md b/{{cookiecutter.project_slug}}/docs/index.md index 08989af..a848124 100644 --- a/{{cookiecutter.project_slug}}/docs/index.md +++ b/{{cookiecutter.project_slug}}/docs/index.md @@ -1,6 +1,3 @@ -{% if cookiecutter.use_mkdocs == 'y' %} -# {{ cookiecutter.project_name }} - {{ cookiecutter.project_short_description }} ## Installation @@ -24,4 +21,3 @@ from {{ cookiecutter.project_slug }} import example ## License {{ cookiecutter.open_source_license }} -{% endif %} diff --git a/{{cookiecutter.project_slug}}/docs/reference.md b/{{cookiecutter.project_slug}}/docs/reference.md new file mode 100644 index 0000000..c012b1c --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/reference.md @@ -0,0 +1 @@ +::: {{ cookiecutter.project_slug }} diff --git a/{{cookiecutter.project_slug}}/flake.nix b/{{cookiecutter.project_slug}}/flake.nix index 39ba129..67e870d 100644 --- a/{{cookiecutter.project_slug}}/flake.nix +++ b/{{cookiecutter.project_slug}}/flake.nix @@ -45,6 +45,14 @@ # Add necessary overrides # https://pyproject-nix.github.io/uv2nix/overriding/index.html }); + csscompressor = prev.csscompressor.overrideAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs + ++ [ (final.resolveBuildSystem { setuptools = [ ]; }) ]; + }); + jsmin = prev.csscompressor.overrideAttrs (old: { + nativeBuildInputs = old.nativeBuildInputs + ++ [ (final.resolveBuildSystem { setuptools = [ ]; }) ]; + }); }; pkgs = nixpkgs.legacyPackages.x86_64-linux; diff --git a/{{cookiecutter.project_slug}}/mkdocs.yml b/{{cookiecutter.project_slug}}/mkdocs.yml index ab09a50..f19f8ab 100644 --- a/{{cookiecutter.project_slug}}/mkdocs.yml +++ b/{{cookiecutter.project_slug}}/mkdocs.yml @@ -1,4 +1,3 @@ -{% if cookiecutter.use_mkdocs == 'y' %} site_name: {{ cookiecutter.project_name }} site_description: {{ cookiecutter.project_short_description }} site_author: {{ cookiecutter.full_name }} @@ -26,18 +25,44 @@ theme: - navigation.tracking - navigation.expand - navigation.indexes + - navigation.top + - navigation.footer - content.code.copy + - content.code.annotate markdown_extensions: - - pymdownx.highlight: - anchor_linenums: true - - pymdownx.superfences - - pymdownx.inlinehilite - - pymdownx.snippets + - abbr + - def_list - admonition + # We need the markdown-include to inject files into other files + - markdown_include.include: + base_path: docs + - meta + - toc: + permalink: true + baselevel: 2 + - pymdownx.arithmatex + - pymdownx.betterem: + smart_enable: all + - pymdownx.caret + - pymdownx.critic - pymdownx.details + - pymdownx.emoji: + emoji_generator: '!!python/name:pymdownx.emoji.to_svg' + - pymdownx.inlinehilite + - pymdownx.magiclink + - pymdownx.mark + - pymdownx.smartsymbols + - pymdownx.superfences: + custom_fences: + - name: mermaid + class: mermaid + format: !!python/name:pymdownx.superfences.fence_code_format - pymdownx.tabbed: alternate_style: true + - pymdownx.tasklist: + custom_checkbox: true + - pymdownx.tilde plugins: - search @@ -48,9 +73,15 @@ plugins: show_source: true show_submodules: true docstring_style: google + - autolinks + - git-revision-date-localized: + type: timeago + fallback_to_build_date: true + - minify: + minify_html: true + - section-index nav: - - Home: index.md - - API Reference: api/ + - {{ cookiecutter.project_name }}: index.md + - Reference: reference.md - Contributing: contributing.md -{% endif %} diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 3a1f4ec..2ab1c07 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -36,8 +36,14 @@ dev = [ ] {%- if cookiecutter.use_mkdocs == "y" %} docs = [ + "markdown-include", "mkdocs", + "mkdocs-autolinks-plugin", + "mkdocs-git-revision-date-localized-plugin", + "mkdocs-htmlproofer-plugin", "mkdocs-material", + "mkdocs-minify-plugin", + "mkdocs-section-index", "mkdocstrings", "mkdocstrings-python", ] @@ -51,6 +57,7 @@ addopts = "-ra --cov=src" [tool.coverage.report] exclude_also = [ + 'pragma: no cover', 'def __repr__', 'raise NotImplementedError', 'if TYPE_CHECKING:', @@ -69,5 +76,29 @@ tag_format = "v${version}" version_scheme = "semver" update_changelog_on_bump = true +[tool.black] +line-length = 88 +target-version = ['py310', 'py311', 'py312', 'py313'] +include = '\.pyi?$' +exclude = ''' +/( + \.eggs + | \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + # The following are specific to Black, you probably don't want those. + | blib2to3 + | tests/data + | profiling +)/ +''' + [tool.isort] profile = "black" +src_paths = ["src", "test"] diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py index e69de29..981459f 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py @@ -0,0 +1 @@ +"""{{ cookiecutter.project_short_description }}.""" diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/version.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/version.py new file mode 100644 index 0000000..00eb123 --- /dev/null +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/version.py @@ -0,0 +1,23 @@ +"""Utilities to retrieve the information of the program version.""" + +# Do not edit the version manually, let `make bump` do it. + +__version__ = "0.1.0" + + +def version_info() -> str: + import platform + import sys + from textwrap import dedent + """Display the version of the program, python and the platform.""" + return dedent( + f"""\ + ------------------------------------------------------------------ + {{cookiecutter.project_slug}}: {__version__} + Python: {sys.version.split(" ", maxsplit=1)[0]} + Platform: {platform.platform()} + ------------------------------------------------------------------""" + ) + +if __name__ == "__main__": + print(version_info())