diff --git a/.github/workflows/run-tests.yml.jinja b/.github/workflows/run-tests.yml.jinja index d99c81e..d10f363 100644 --- a/.github/workflows/run-tests.yml.jinja +++ b/.github/workflows/run-tests.yml.jinja @@ -28,7 +28,7 @@ jobs: run_tests: strategy: matrix: - python_version: ["3.10", "3.11", "3.12", "3.13"] + python_version: ["3.10", "3.11", "3.12", "3.13", "3.14"] os: [ubuntu-24.04, macos-14] runs-on: ${{ matrix.os }} env: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25361c8..797c28e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,12 +34,12 @@ repos: additional_dependencies: - mdformat-gfm - repo: https://github.com/adrienverge/yamllint - rev: v1.37.1 + rev: v1.38.0 hooks: - id: yamllint exclude: pre-commit-config.yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.14.11" + rev: "v0.14.13" hooks: - id: ruff-format - id: ruff-check diff --git a/copier.yaml b/copier.yaml index fdcb170..3426374 100644 --- a/copier.yaml +++ b/copier.yaml @@ -4,9 +4,9 @@ project_name: help: >- What is the name of your project? This will be used in the package name - and other places. Please use "_" - underscores instead of spaces where - necessary, e.g. "my_project". + and other places. Dashes will be converted + to underscores for the Python package/module + name (e.g. "my-project" -> "my_project"). project_description: type: str @@ -15,6 +15,11 @@ project_description: This will be used in the package metadata and other places. +python_package_name: + type: str + default: "{{ project_name|replace('-', '_') }}" + when: false + author_name: type: str default: "Your Name" diff --git a/docs/src/python-api.md.jinja b/docs/src/python-api.md.jinja index 64ba9f4..94b628c 100644 --- a/docs/src/python-api.md.jinja +++ b/docs/src/python-api.md.jinja @@ -1,9 +1,9 @@ # Python API ```{eval-rst} -{{ project_name }}.main +{{ python_package_name }}.main ------------------- -.. automodule:: src.{{ project_name }}.main +.. automodule:: src.{{ python_package_name }}.main :members: :private-members: :undoc-members: diff --git a/pyproject.toml b/pyproject.toml index 4d6233c..ab67934 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,4 +62,4 @@ pythonpath = [ "." ] [tool.vulture] min_confidence = 90 -paths = [ "src/{{ project_name }}", "tests" ] +paths = [ "src/{{ python_package_name }}", "tests" ] diff --git a/pyproject.toml.jinja b/pyproject.toml.jinja index f4e3987..b52ebf0 100644 --- a/pyproject.toml.jinja +++ b/pyproject.toml.jinja @@ -22,7 +22,7 @@ dependencies = [ "fire>=0.7.0", "jinja2>=3.1.6", ] -scripts.{{ project_name }} = "{{ project_name }}.cli:trigger" +scripts.{{ project_name }} = "{{ python_package_name }}.cli:trigger" [dependency-groups] dev = [ @@ -46,7 +46,7 @@ notebooks = [ root = "." version_scheme = "no-guess-dev" local_scheme = "no-local-version" -version_file = "src/{{ project_name }}/_version.py" +version_file = "src/{{ python_package_name }}/_version.py" [tool.ruff] target-version = "py311" @@ -95,4 +95,4 @@ formats = "ipynb,py:light" [tool.vulture] min_confidence = 90 -paths = [ "src/{{ project_name }}", "tests" ] +paths = [ "src/{{ python_package_name }}", "tests" ] diff --git a/src/notebooks/example_notebook.ipynb.jinja b/src/notebooks/example_notebook.ipynb.jinja index f95bf6e..4fc73b6 100644 --- a/src/notebooks/example_notebook.ipynb.jinja +++ b/src/notebooks/example_notebook.ipynb.jinja @@ -31,7 +31,7 @@ "outputs": [], "source": [ "# show an import from a local package\n", - "from {{ project_name }} import show_message" + "from {{ python_package_name }} import show_message" ] }, { diff --git a/src/notebooks/example_notebook.py.jinja b/src/notebooks/example_notebook.py.jinja index dec781f..adf7896 100644 --- a/src/notebooks/example_notebook.py.jinja +++ b/src/notebooks/example_notebook.py.jinja @@ -30,7 +30,7 @@ # Clicking it applies the formatting to the notebook. # show an import from a local package -from {{ project_name }} import show_message +from {{ python_package_name }} import show_message # use the function within the notebook to show it works show_message("Hello, notebook!") diff --git a/src/{{ project_name }}/__init__.py b/src/{{ python_package_name }}/__init__.py similarity index 100% rename from src/{{ project_name }}/__init__.py rename to src/{{ python_package_name }}/__init__.py diff --git a/src/{{ project_name }}/cli.py.jinja b/src/{{ python_package_name }}/cli.py.jinja similarity index 76% rename from src/{{ project_name }}/cli.py.jinja rename to src/{{ python_package_name }}/cli.py.jinja index 8982c76..dfe67da 100644 --- a/src/{{ project_name }}/cli.py.jinja +++ b/src/{{ python_package_name }}/cli.py.jinja @@ -1,13 +1,13 @@ """ -CLI for nviz +CLI for {{ python_package_name }} """ import fire -from {{ project_name }}.main import show_message +from {{ python_package_name }}.main import show_message -class {{ project_name }}CLI: +class {{ python_package_name }}CLI: def show_message( self, message: str = "Hello, world!", @@ -33,4 +33,4 @@ def trigger() -> None: """ Trigger the CLI to run. """ - fire.Fire({{ project_name }}CLI) + fire.Fire({{ python_package_name }}CLI) diff --git a/src/{{ project_name }}/main.py b/src/{{ python_package_name }}/main.py similarity index 100% rename from src/{{ project_name }}/main.py rename to src/{{ python_package_name }}/main.py diff --git a/tests/test_main.py.jinja b/tests/test_main.py.jinja index 329c9dc..b8f6c86 100644 --- a/tests/test_main.py.jinja +++ b/tests/test_main.py.jinja @@ -2,7 +2,7 @@ Tests for the main module. """ -from {{ project_name }}.main import show_message +from {{ python_package_name }}.main import show_message def test_show_message(my_data: str) -> None: diff --git a/tests/test_template.py b/tests/test_template.py index 3be232a..fb623dc 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -20,7 +20,7 @@ def test_template(tmp_path: Path) -> None: src_path=str(template_path), dst_path=dst_path, data={ - "project_name": "demo_project", + "project_name": "demo-project", "project_description": "A demo project for testing Copier templates.", "author_name": "Test Author", "author_orcid": "https://orcid.org/0000-0000-0000-0000", @@ -28,6 +28,7 @@ def test_template(tmp_path: Path) -> None: }, quiet=True, overwrite=True, + vcs_ref="HEAD", ) # Assert a file from the template was created