From 56967bb861f1c73671514dab64859fb106b4033d Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Mon, 2 Sep 2024 09:48:11 +0200 Subject: [PATCH 1/7] Fix repo metadata --- {{cookiecutter.project_name}}/docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index 312f8699..b9b82546 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -37,7 +37,7 @@ html_context = { "display_github": True, # Integrate GitHub "github_user": "{{cookiecutter.github_user}}", - "github_repo": "{{cookiecutter.project_repo}}", + "github_repo": "{{cookiecutter.project_name}}", "github_version": "main", "conf_py_path": "/docs/", } From 7a5cace01ff1ded020a19ae4678cc77b7305e2f7 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Mon, 2 Sep 2024 09:56:23 +0200 Subject: [PATCH 2/7] Use variable --- cookiecutter.json | 3 ++- {{cookiecutter.project_name}}/docs/conf.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index ea87fe6d..fce5a04f 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -5,7 +5,8 @@ "author_full_name": "Your Name", "author_email": "yourname@example.com", "github_user": "your_github_username", - "project_repo": "https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.project_name }}", + "github_repo": "{{ cookiecutter.project_name }}", + "project_repo": "https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}", "license": [ "MIT License", "BSD 2-Clause License", diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index b9b82546..4197a427 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -37,7 +37,7 @@ html_context = { "display_github": True, # Integrate GitHub "github_user": "{{cookiecutter.github_user}}", - "github_repo": "{{cookiecutter.project_name}}", + "github_repo": {% if cookiecutter.project_name == cookiecutter.github_repo %}project_name{% else %}"{{cookiecutter.github_repo}}"{% endif %}, "github_version": "main", "conf_py_path": "/docs/", } From ea1732b2a8ad82896325d8be9e590473bc749993 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Mon, 2 Sep 2024 10:02:21 +0200 Subject: [PATCH 3/7] get rid of confusing variable --- .github/assets/cookiecutter-scverse-instance.json | 2 +- cookiecutter.json | 1 - {{cookiecutter.project_name}}/README.md | 4 ++-- {{cookiecutter.project_name}}/pyproject.toml | 5 +++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/assets/cookiecutter-scverse-instance.json b/.github/assets/cookiecutter-scverse-instance.json index a2a83089..41f7a2a6 100644 --- a/.github/assets/cookiecutter-scverse-instance.json +++ b/.github/assets/cookiecutter-scverse-instance.json @@ -6,7 +6,7 @@ "author_full_name": "scverse community", "author_email": "core-team@scverse.org", "github_user": "scverse", - "project_repo": "https://github.com/scverse/cookiecutter-scverse-instance", + "github_repo": "cookiecutter-scverse-instance", "license": "BSD 3-Clause License", "_copy_without_render": [ ".github/workflows/**.yaml", diff --git a/cookiecutter.json b/cookiecutter.json index fce5a04f..cf40b568 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -6,7 +6,6 @@ "author_email": "yourname@example.com", "github_user": "your_github_username", "github_repo": "{{ cookiecutter.project_name }}", - "project_repo": "https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}", "license": [ "MIT License", "BSD 2-Clause License", diff --git a/{{cookiecutter.project_name}}/README.md b/{{cookiecutter.project_name}}/README.md index 06123708..d907f1fa 100644 --- a/{{cookiecutter.project_name}}/README.md +++ b/{{cookiecutter.project_name}}/README.md @@ -4,7 +4,7 @@ [![Documentation][badge-docs]][link-docs] [badge-tests]: https://img.shields.io/github/actions/workflow/status/{{ cookiecutter.github_user }}/{{ cookiecutter.project_name }}/test.yaml?branch=main -[link-tests]: {{ cookiecutter.project_repo }}/actions/workflows/test.yml +[link-tests]: https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}/actions/workflows/test.yml [badge-docs]: https://img.shields.io/readthedocs/{{ cookiecutter.project_name }} {{ cookiecutter.project_description }} @@ -33,7 +33,7 @@ pip install {{ cookiecutter.project_name }} 1. Install the latest development version: ```bash -pip install git+{{ cookiecutter.project_repo }}.git@main +pip install git+https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}.git@main ``` ## Release notes diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml index 7a7a36e3..5f91b7dd 100644 --- a/{{cookiecutter.project_name}}/pyproject.toml +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -15,9 +15,10 @@ authors = [ maintainers = [ {name = "{{ cookiecutter.author_full_name }}", email = "{{ cookiecutter.author_email }}"}, ] +# https://docs.pypi.org/project_metadata/#project-urls urls.Documentation = "https://{{ cookiecutter.project_name }}.readthedocs.io/" -urls.Source = "{{ cookiecutter.project_repo }}" -urls.Home-page = "{{ cookiecutter.project_repo }}" +urls.Source = "https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}" +urls.Homepage = "https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}" dependencies = [ "anndata", # for debug logging (referenced from the issue template) From 062754f8bb23084192b54fa6fedb70db6b21dfd4 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Mon, 2 Sep 2024 12:16:39 +0200 Subject: [PATCH 4/7] Add tests --- .gitignore | 4 +--- scripts/tests/test_build.py | 31 +++++++++++++++++++++++++++++++ scripts/tests/test_cruft.py | 5 ++--- 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 scripts/tests/test_build.py diff --git a/.gitignore b/.gitignore index 342a7a52..de09a764 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,7 @@ # Tests and coverage __pycache__/ -.ruff_cache/ -/.pytest_cache/ -/.cache/ +.*cache/ /data/ /node_modules/ diff --git a/scripts/tests/test_build.py b/scripts/tests/test_build.py new file mode 100644 index 00000000..e8d00fb4 --- /dev/null +++ b/scripts/tests/test_build.py @@ -0,0 +1,31 @@ +from __future__ import annotations + +import re +from pathlib import Path +from typing import TYPE_CHECKING + +import pytest +from cookiecutter.main import cookiecutter + +if TYPE_CHECKING: + from collections.abc import Mapping + from typing import Any + + +HERE = Path(__file__).parent + + +@pytest.mark.parametrize( + ("params", "path", "pattern"), + [ + ({}, "docs/conf.py", r'"github_repo": project_name,'), + ({"github_repo": "floob"}, "docs/conf.py", r'"github_repo": "floob",'), + ], +) +def test_build(tmp_path: Path, params: Mapping[str, Any], path: Path | str, pattern: re.Pattern | str): + cookiecutter(str(HERE.parent.parent), output_dir=tmp_path, no_input=True, extra_context=params) + proj_dir = tmp_path / "project-name" + assert proj_dir.is_dir() + path = proj_dir / path + pattern = re.compile(pattern, re.MULTILINE) + assert pattern.search(path.read_text()) diff --git a/scripts/tests/test_cruft.py b/scripts/tests/test_cruft.py index 1e34ab38..e4b25229 100644 --- a/scripts/tests/test_cruft.py +++ b/scripts/tests/test_cruft.py @@ -36,9 +36,8 @@ class MockRelease: @pytest.fixture def con(response_mock) -> GitHubConnection: resp = json.dumps({"login": "scverse-bot"}) - with catch_warnings(): - with response_mock(f"GET https://api.github.com:443/users/scverse-bot -> 200 :{resp}"): - return GitHubConnection("scverse-bot") + with catch_warnings(), response_mock(f"GET https://api.github.com:443/users/scverse-bot -> 200 :{resp}"): + return GitHubConnection("scverse-bot") @pytest.fixture From 9fab97d94a703b087dc670ef017f62f88bcf8dde Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Mon, 2 Sep 2024 12:19:08 +0200 Subject: [PATCH 5/7] simplify cache ignore --- {{cookiecutter.project_name}}/.gitignore | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/{{cookiecutter.project_name}}/.gitignore b/{{cookiecutter.project_name}}/.gitignore index eeec7e29..060fcc5d 100644 --- a/{{cookiecutter.project_name}}/.gitignore +++ b/{{cookiecutter.project_name}}/.gitignore @@ -6,8 +6,7 @@ buck-out/ # Compiled files .venv/ __pycache__/ -.mypy_cache/ -.ruff_cache/ +.*cache/ # Distribution / packaging /build/ @@ -15,8 +14,6 @@ __pycache__/ /*.egg-info/ # Tests and coverage -/.pytest_cache/ -/.cache/ /data/ /node_modules/ From 319d30b3b9692a92cfc4775782acc55964dcd097 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Mon, 2 Sep 2024 12:19:30 +0200 Subject: [PATCH 6/7] remove useless ignore --- {{cookiecutter.project_name}}/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/.gitignore b/{{cookiecutter.project_name}}/.gitignore index 060fcc5d..4c50fed6 100644 --- a/{{cookiecutter.project_name}}/.gitignore +++ b/{{cookiecutter.project_name}}/.gitignore @@ -11,7 +11,6 @@ __pycache__/ # Distribution / packaging /build/ /dist/ -/*.egg-info/ # Tests and coverage /data/ From 99e43198f78335da5de8dbaccc1dcca4c0cc0679 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Mon, 2 Sep 2024 12:22:16 +0200 Subject: [PATCH 7/7] More useless things --- .gitignore | 8 ++++---- {{cookiecutter.project_name}}/.gitignore | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index de09a764..a295123a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,14 +2,14 @@ .DS_Store *~ +# Caches +__pycache__/ +.*cache/ + # Distribution / packaging -/build/ /dist/ -/*.egg-info/ # Tests and coverage -__pycache__/ -.*cache/ /data/ /node_modules/ diff --git a/{{cookiecutter.project_name}}/.gitignore b/{{cookiecutter.project_name}}/.gitignore index 4c50fed6..d01a5d5d 100644 --- a/{{cookiecutter.project_name}}/.gitignore +++ b/{{cookiecutter.project_name}}/.gitignore @@ -9,7 +9,6 @@ __pycache__/ .*cache/ # Distribution / packaging -/build/ /dist/ # Tests and coverage