From 4c49712559fb2bef80f5bee8d8104b54bd4eb214 Mon Sep 17 00:00:00 2001 From: Samuel Bennett Date: Fri, 19 Jan 2024 11:21:56 +0000 Subject: [PATCH] Update {{ cookiecutter.package_name }}/.github/workflows/sub_package_update.yml Co-authored-by: Stuart Mumford --- cookiecutter.json | 2 +- hooks/post_gen_project.py | 2 +- tests/test_rendered_tox.py | 2 ++ .../.github/workflows/sub_package_update.yml | 19 +++++++----- .../pyproject.toml | 31 +++++++++---------- {{ cookiecutter.package_name }}/setup.py | 8 ++--- {{ cookiecutter.package_name }}/tox.ini | 2 +- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index 56d71ca..d370543 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -4,6 +4,7 @@ "short_description": "", "author_name": "", "author_email": "", + "project_url": "", "license": [ "BSD 3-Clause", "GNU GPL v3+", @@ -11,7 +12,6 @@ "BSD 2-Clause", "Other" ], - "project_url": "", "minimum_python_version": [ "3.9", "3.10", diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index d761a09..94ff8ab 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -37,7 +37,7 @@ def process_version(enable_dynamic_dev_versions): def process_github_workflow(include_cruft_update_github_workflow): if include_cruft_update_github_workflow != "y": - remove_dir(os.path.join(PROJECT_DIRECTORY, '{{ cookiecutter.module_name }}', '.github')) + remove_dir(os.path.join(PROJECT_DIRECTORY, '.github')) if __name__ == '__main__': diff --git a/tests/test_rendered_tox.py b/tests/test_rendered_tox.py index 6fc78d8..cf71cdd 100644 --- a/tests/test_rendered_tox.py +++ b/tests/test_rendered_tox.py @@ -11,6 +11,8 @@ def test_tox_runs(cookiejar_examples, tox_project): cj = cookiejar_examples # We have to git init so that setuptools_scm and it's generated manifest path = str(cj.project_path) + print("==============================") + print("PATH IS : {}".format(path)) subprocess.call(["git", "config", "--global", "init.defaultBranch", "main"]) subprocess.call(["git", "init", path]) diff --git a/{{ cookiecutter.package_name }}/.github/workflows/sub_package_update.yml b/{{ cookiecutter.package_name }}/.github/workflows/sub_package_update.yml index 2b09443..9946610 100644 --- a/{{ cookiecutter.package_name }}/.github/workflows/sub_package_update.yml +++ b/{{ cookiecutter.package_name }}/.github/workflows/sub_package_update.yml @@ -1,4 +1,8 @@ -name: Update SunPy Sub Packages +""" +This template is taken from the cruft example code, for further information please see: +https://cruft.github.io/cruft/#automating-updates-with-github-actions +""" +name: Automatic Update from package template permissions: contents: write pull-requests: write @@ -17,13 +21,13 @@ jobs: - add-paths: . body: Use this to merge the changes to the repo branch: cruft/update - commit-message: "SunPy package template update" - title: New Updates to SunPy Template + commit-message: "Automate package template update" + title: Incoming updates from package template - add-paths: .cruft.json body: Use this to reject changes in the repo branch: cruft/reject commit-message: "Chore: reject this cruft update" - title: Reject new SunPy template updates + title: Reject new updates from package template steps: - uses: actions/checkout@v3 @@ -52,10 +56,9 @@ jobs: - name: Run update if available if: steps.check.outputs.has_changes == '1' - # this needs to be sunpy details I think? run: | - git config --global user.email "" - git config --global user.name "SunPy Org" + git config --global user.email "gromit@cruft.com" + git config --global user.name "Gromit" cruft update --skip-apply-ask --refresh-private-variables git restore --staged @@ -73,5 +76,5 @@ jobs: title: ${{ matrix.title }} body: | This is an autogenerated PR. ${{ matrix.body }} - [Cruft](https://cruft.github.io/cruft/) has detected updates from the SunPy Package Template + [Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template diff --git a/{{ cookiecutter.package_name }}/pyproject.toml b/{{ cookiecutter.package_name }}/pyproject.toml index 6f175e3..35dd992 100644 --- a/{{ cookiecutter.package_name }}/pyproject.toml +++ b/{{ cookiecutter.package_name }}/pyproject.toml @@ -3,11 +3,11 @@ requires = [ "setuptools>=62.1", "setuptools_scm[toml]>=6.2", "wheel", -{% if cookiecutter.use_compiled_extensions == 'y' %} +{%- if cookiecutter.use_compiled_extensions == 'y' %} "extension-helpers", "oldest-supported-numpy", "cython" -{% endif %} +{% endif -%} ] build-backend = "setuptools.build_meta" @@ -17,16 +17,21 @@ description = "{{ cookiecutter.short_description }}" readme = "README.rst" requires-python = ">={{ cookiecutter.minimum_python_version }}" license = { file = "licenses/LICENSE.rst", content-type = "text/plain" } -{% if cookiecutter.author_name and cookiecutter.author_email %} +{%- if cookiecutter.author_name and cookiecutter.author_email %} authors = [ { name = "{{ cookiecutter.author_name }}", email = "{{ cookiecutter.author_email }}" }, ] -{% endif %} +{%- endif %} dependencies = [ - {{ cookiecutter._install_requires }} + {{- cookiecutter._install_requires -}} ] dynamic = ["version"] +{% if cookiecutter.include_example_code == 'y' -%} +[project.scripts] +open_astronomy_package_template_example = "{{ cookiecutter.module_name }}.example_mod:main" + +{% endif -%} [project.optional-dependencies] test = [ "pytest", @@ -38,15 +43,10 @@ docs = [ "tomli; python_version <\"3.11\"", ] -{%- if cookiecutter.include_example_code == 'y' %} -[project.scripts] -astropy_package_template_example = "{{ cookiecutter.module_name }}.example_mod:main" -{% endif -%} - -{%- if cookiecutter.project_url %} +{% if cookiecutter.project_url -%} [project.urls] repository = "{{ cookiecutter.project_url }}" -{% endif -%} +{%- endif %} [tool.setuptools] zip-safe = false @@ -55,12 +55,11 @@ include-package-data = true [tool.setuptools.packages.find] [tool.setuptools_scm] -{%- if cookiecutter.enable_dynamic_dev_versions == 'y' %} +{% if cookiecutter.enable_dynamic_dev_versions == 'y' -%} write_to = "{{ cookiecutter.module_name }}/_version.py" -{% else %} +{%- else -%} write_to = "{{ cookiecutter.module_name }}/version.py" -{% endif -%} - +{%- endif %} [tool.pytest.ini_options] testpaths = [ diff --git a/{{ cookiecutter.package_name }}/setup.py b/{{ cookiecutter.package_name }}/setup.py index 1e3530c..c98cd51 100755 --- a/{{ cookiecutter.package_name }}/setup.py +++ b/{{ cookiecutter.package_name }}/setup.py @@ -2,10 +2,8 @@ from setuptools import setup {%- if cookiecutter.use_compiled_extensions == 'y' %} from extension_helpers import get_extensions -{% endif -%} +{%- endif %} -{%- if cookiecutter.use_compiled_extensions == 'y' %} -setup( +setup( {%- if cookiecutter.use_compiled_extensions == 'y' -%} ext_modules=get_extensions() -) -{% endif -%} +{%- endif -%} ) diff --git a/{{ cookiecutter.package_name }}/tox.ini b/{{ cookiecutter.package_name }}/tox.ini index 58f8528..549c04e 100644 --- a/{{ cookiecutter.package_name }}/tox.ini +++ b/{{ cookiecutter.package_name }}/tox.ini @@ -57,7 +57,7 @@ commands = description = invoke sphinx-build to build the HTML docs change_dir = docs -extras = +extras = docs commands = sphinx-build -j auto --color -W --keep-going -b html -d _build/.doctrees . _build/html {posargs}