diff --git a/.github/workflows/sub_package_update.yml b/.github/workflows/sub_package_update.yml deleted file mode 100644 index 2b09443..0000000 --- a/.github/workflows/sub_package_update.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Update SunPy Sub Packages -permissions: - contents: write - pull-requests: write - -on: - pull_request: - branches: - main -jobs: - update: - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - include: - - 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 - - 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 - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Install Cruft - run: pip3 install cruft - - - name: Check if update is available - continue-on-error: false - id: check - run: | - CHANGES=0 - if [ -f .cruft.json ]; then - if ! cruft check; then - CHANGES=1 - fi - else - echo "No .cruft.json file" - fi - - echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT" - - - 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" - - cruft update --skip-apply-ask --refresh-private-variables - git restore --staged - - - name: Create pull request - if: steps.check.output.has_changes == '1' - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - add-paths: ${{ matrix.add-paths }} - commit-message: ${{ matrix.commit-message }} - branch: ${{ matrix.branch }} - delete-branch: true - branch-suffix: timestamp - 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 - diff --git a/.gitignore b/.gitignore index 1413d60..5e581a5 100644 --- a/.gitignore +++ b/.gitignore @@ -120,6 +120,9 @@ venv.bak/ .spyderproject .spyproject +# Pycharm project settings +.idea + # Rope project settings .ropeproject diff --git a/cookiecutter.json b/cookiecutter.json index bb2869f..bcf0f81 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -21,12 +21,12 @@ "use_compiled_extensions": "n", "enable_dynamic_dev_versions": "n", "include_example_code": "n", + "include_cruft_update_github_workflow": "n", "_sphinx_theme": "alabaster", "_parent_project": "", "_install_requires": "", "_copy_without_render": [ "docs/_templates", "docs/_static", - ".github/workflows/sub_package_update.yml" ] } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 098fc45..d761a09 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -34,9 +34,16 @@ def process_version(enable_dynamic_dev_versions): remove_dir(os.path.join(PROJECT_DIRECTORY, '{{ cookiecutter.module_name }}', '_dev')) remove_file(os.path.join(PROJECT_DIRECTORY, '{{ cookiecutter.module_name }}', 'version.py')) + +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')) + + if __name__ == '__main__': process_license('{{ cookiecutter.license }}') process_version('{{ cookiecutter.enable_dynamic_dev_versions }}') + process_github_workflow('{{ cookiecutter.include_cruft_update_github_workflow }}') include_examples = '{{ cookiecutter.include_example_code }}' == 'y' use_compiled = '{{ cookiecutter.use_compiled_extensions }}' == 'y' diff --git a/{{ cookiecutter.package_name }}/pyproject.toml b/{{ cookiecutter.package_name }}/pyproject.toml index 8dffd2e..6f175e3 100644 --- a/{{ cookiecutter.package_name }}/pyproject.toml +++ b/{{ cookiecutter.package_name }}/pyproject.toml @@ -38,7 +38,7 @@ docs = [ "tomli; python_version <\"3.11\"", ] -{%0 if cookiecutter.include_example_code == 'y' %} +{%- if cookiecutter.include_example_code == 'y' %} [project.scripts] astropy_package_template_example = "{{ cookiecutter.module_name }}.example_mod:main" {% endif -%}