Skip to content

Commit

Permalink
fix: rename cookiecutter input parameter based on suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
bobleesj committed Jan 2, 2025
1 parent 0fbf422 commit b978513
Show file tree
Hide file tree
Showing 46 changed files with 70 additions and 58 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ repos:
rev: v4.6.0
hooks:
- id: check-yaml
exclude: '^{{ cookiecutter.repo_name }}/.*\.yml$' # {{ cookiecutter.repo_name }} contains jinja variables in .yml, hook fails
exclude: '^{{ cookiecutter.github_repo_name }}/.*\.yml$' # {{ cookiecutter.github_repo_name }} contains jinja variables in .yml, hook fails
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
exclude: '^{{ cookiecutter.repo_name }}/.*\.toml$' # {{ cookiecutter.repo_name }} contains jinja variables in pyproject.toml, hook fails
exclude: '^{{ cookiecutter.github_repo_name }}/.*\.toml$' # {{ cookiecutter.github_repo_name }} contains jinja variables in pyproject.toml, hook fails
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
exclude: '^({{ cookiecutter.repo_name }}/.*\.py|hooks/post_gen_project\.py)$' # {{ cookiecutter.repo_name }} contains jinja variables in .py, hook fails. hooks/post_gen_project.py contains jinja variables of # (c) {% now 'utc', '%Y' %} which is not a valid black format
exclude: '^({{ cookiecutter.github_repo_name }}/.*\.py|hooks/post_gen_project\.py)$' # {{ cookiecutter.github_repo_name }} contains jinja variables in .py, hook fails. hooks/post_gen_project.py contains jinja variables of # (c) {% now 'utc', '%Y' %} which is not a valid black format
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
exclude: '^({{ cookiecutter.repo_name }}/.*\.py|hooks/post_gen_project\.py)$' # Same comment as black above
exclude: '^({{ cookiecutter.github_repo_name }}/.*\.py|hooks/post_gen_project\.py)$' # Same comment as black above
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Ignore jinja2 variables within the cookiecutter project
{{ cookiecutter.repo_name }}
{{ cookiecutter.github_repo_name }}
6 changes: 3 additions & 3 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"license_holders": "The Trustees of Columbia University in the City of New York",
"project_name": "diffpy.my-project",
"github_org": "diffpy",
"repo_name": "diffpy.my-project",
"package_dist_name": "{{ cookiecutter.project_name|replace(' ', '-')|lower }}",
"github_repo_name": "diffpy.my-project",
"conda_pypi_package_dist_name": "{{ cookiecutter.project_name|replace(' ', '-')|lower }}",
"package_dir_name": "{{ cookiecutter.project_name|replace(' ', '_')|replace('-', '_')|lower }}",
"project_short_description": "Python package for doing science.",
"keywords": "diffraction, PDF, X-ray, neutron",
"minimum_supported_python_version": "3.11",
"maximum_supported_python_version": "3.13",
"project_needs_c_code_compiled": ["No", "Yes"],
"project_needs_headless_GUI_testing": ["No", "Yes"],
"project_has_gui_tests": ["No", "Yes"],
"_copy_without_render": ["*.html", "*.js", ".github/*"]
}
2 changes: 1 addition & 1 deletion doc/source/conda_forge_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you are interested in learning more about each component within ``meta.yaml``

2. module_name (diffpy.my_project): diffpy.srreal

3. repo_name (diffpy.srreal):
3. github_repo_name (diffpy.srreal):

4. version (1.0.0): 1.3.1

Expand Down
8 changes: 4 additions & 4 deletions doc/source/cookiecutter_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ WARNINGS

5. Create a new branch called ``black``.

6. Create ``pyproject.toml``. Copy and paste the ``[tools.black]`` and ``[tool.codespell]`` sections from ``pyproject.toml`` in the ``{{ cookiecutter.repo_name }}`` folder path.
6. Create ``pyproject.toml``. Copy and paste the ``[tools.black]`` and ``[tool.codespell]`` sections from ``pyproject.toml`` in the ``{{ cookiecutter.github_repo_name }}`` folder path.

7. Run ``black src`` (note: some of the older packages do not have an ``src`` directory, so you may have to run black on a different directory).

Expand All @@ -71,7 +71,7 @@ WARNINGS

11. Type ``git checkout main && git pull upstream main`` and create a new branch called ``precommit``.

12. Copy and paste the ``.flake8`` and ``.pre-commit-config.yaml`` files from ``{{ cookiecutter.repo_name }}`` to the top directory level. Cross-check with https://github.com/diffpy/diffpy.utils.
12. Copy and paste the ``.flake8`` and ``.pre-commit-config.yaml`` files from ``{{ cookiecutter.github_repo_name }}`` to the top directory level. Cross-check with https://github.com/diffpy/diffpy.utils.

13. Run ``pre-commit run --all-files``. Fix any spelling suggestions from Codespell. To ignore a specific word or line, add it under ``.codespell/ignore_words.txt`` or ``.codespell/ignore_lines.txt``. To ignore specific file types, add the file extensions i.e. ``*.gr`` in ``skip = line`` under ``[tool.codespell]`` in ``pyproject.toml``. Include explanations for each addition.

Expand Down Expand Up @@ -110,11 +110,11 @@ Please follow the instructions in the `installation <_cookiecutter-installation>

4. project_name: <name_of_project (e.g. ``diffpy.pdfmorph``)>

5. package_dist_name: (default)
5. conda_pypi_package_dist_name: (default)

6. package_dir_name: (default)

7. repo_name: (default)
7. github_repo_name: (default)

8. minimum_python_version: (default -- this is 3.11)

Expand Down
16 changes: 14 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __gen_init__(module_name):
# File coded by: Billinge Group members and community contributors.
#
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/graphs/contributors
# https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/graphs/contributors
#
# See LICENSE.rst for license information.
#
Expand Down Expand Up @@ -149,7 +149,7 @@ def update_workflow():
workflow_input = {"PROJECT": "{{ cookiecutter.project_name }}",
"GITHUB_ADMIN_USERNAME": "{{ cookiecutter.project_owner_github_username }}",
"C_EXTENSION": str("{{ cookiecutter.project_needs_c_code_compiled }}"=="Yes").lower(),
"HEADLESS": str("{{ cookiecutter.project_needs_headless_GUI_testing }}"=="Yes").lower(),
"HEADLESS": str("{{ cookiecutter.project_has_gui_tests }}"=="Yes").lower(),
"VERSION": "v0"}

def get_central_workflows():
Expand Down Expand Up @@ -219,5 +219,17 @@ def main():
" \nGitHub issues: https://github.com/Billingegroup/cookiecutter/issues\n"
)

# Dynamically check if the user has selected a non-default Python version
max_python_version = "3.13"
min_pyhton_version = "3.11"

if ("{{ cookiecutter.minimum_supported_python_version }}" != min_pyhton_version
or "{{ cookiecutter.maximum_supported_python_version }}" != max_python_version):
print(
"ACTION REQUIRED (non-default Python versions): You've entered Python versions outside of the default according to "
"https://scientific-python.org/specs/spec-0000/. Please specify Python versions following the instructions in the link below:\n"
"\nFAQ: https://Billingegroup.github.io/cookiecutter/frequently-asked-questions.html#github-actions\n"
)

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion news/import-package-dir.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**Changed:**

* import package_dir_name in the `__init__.py` instead of package_dist_name to ensure package import is lowercased
* import package_dir_name in the `__init__.py` instead of `conda_pypi_package_dist_name` to ensure package import is lowercased

**Deprecated:**

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ exclude = '''

[tool.pytest.ini_options]
addopts = [
"--ignore={{ cookiecutter.repo_name }}",
"--ignore={{ cookiecutter.github_repo_name }}",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Contributors
------------

For a list of contributors, visit
https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/graphs/contributors
https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/graphs/contributors
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
|Icon| |title|_
===============

.. |title| replace:: {{ cookiecutter.package_dist_name }}
.. _title: https://{{ cookiecutter.github_org }}.github.io/{{ cookiecutter.repo_name }}
.. |title| replace:: {{ cookiecutter.conda_pypi_package_dist_name }}
.. _title: https://{{ cookiecutter.github_org }}.github.io/{{ cookiecutter.github_repo_name }}

.. |Icon| image:: https://avatars.githubusercontent.com/{{ cookiecutter.github_org }}
:target: https://{{ cookiecutter.github_org }}.github.io/{{ cookiecutter.repo_name }}
:target: https://{{ cookiecutter.github_org }}.github.io/{{ cookiecutter.github_repo_name }}
:height: 100px

|PyPi| |Forge| |PythonVersion| |PR|
Expand All @@ -15,38 +15,38 @@
.. |Black| image:: https://img.shields.io/badge/code_style-black-black
:target: https://github.com/psf/black

.. |CI| image:: https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg
:target: https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/actions/workflows/matrix-and-codecov-on-merge-to-main.yml
.. |CI| image:: https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg
:target: https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/actions/workflows/matrix-and-codecov-on-merge-to-main.yml

.. |Codecov| image:: https://codecov.io/gh/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/branch/main/graph/badge.svg
:target: https://codecov.io/gh/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}
.. |Codecov| image:: https://codecov.io/gh/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/branch/main/graph/badge.svg
:target: https://codecov.io/gh/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}

.. |Forge| image:: https://img.shields.io/conda/vn/conda-forge/{{ cookiecutter.package_dist_name }}
:target: https://anaconda.org/conda-forge/{{ cookiecutter.package_dist_name }}
.. |Forge| image:: https://img.shields.io/conda/vn/conda-forge/{{ cookiecutter.conda_pypi_package_dist_name }}
:target: https://anaconda.org/conda-forge/{{ cookiecutter.conda_pypi_package_dist_name }}

.. |PR| image:: https://img.shields.io/badge/PR-Welcome-29ab47ff

.. |PyPi| image:: https://img.shields.io/pypi/v/{{ cookiecutter.package_dist_name }}
:target: https://pypi.org/project/{{ cookiecutter.package_dist_name }}/
.. |PyPi| image:: https://img.shields.io/pypi/v/{{ cookiecutter.conda_pypi_package_dist_name }}
:target: https://pypi.org/project/{{ cookiecutter.conda_pypi_package_dist_name }}/

.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/{{ cookiecutter.package_dist_name }}
:target: https://pypi.org/project/{{ cookiecutter.package_dist_name }}/
.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/{{ cookiecutter.conda_pypi_package_dist_name }}
:target: https://pypi.org/project/{{ cookiecutter.conda_pypi_package_dist_name }}/

.. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue
:target: https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/issues
:target: https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/issues

{{ cookiecutter.project_short_description }}

* LONGER DESCRIPTION HERE

For more information about the {{ cookiecutter.package_dist_name }} library, please consult our `online documentation <https://{{ cookiecutter.github_org }}.github.io/{{ cookiecutter.repo_name }}>`_.
For more information about the {{ cookiecutter.conda_pypi_package_dist_name }} library, please consult our `online documentation <https://{{ cookiecutter.github_org }}.github.io/{{ cookiecutter.github_repo_name }}>`_.

Citation
--------

If you use {{ cookiecutter.package_dist_name }} in a scientific publication, we would like you to cite this package as
If you use {{ cookiecutter.conda_pypi_package_dist_name }} in a scientific publication, we would like you to cite this package as

{{ cookiecutter.package_dist_name }} Package, https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}
{{ cookiecutter.conda_pypi_package_dist_name }} Package, https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}

Installation
------------
Expand All @@ -60,10 +60,10 @@ To add "conda-forge" to the conda channels, run the following in a terminal. ::
conda config --add channels conda-forge

We want to install our packages in a suitable conda environment.
The following creates and activates a new environment named ``{{ cookiecutter.package_dist_name }}_env`` ::
The following creates and activates a new environment named ``{{ cookiecutter.conda_pypi_package_dist_name }}_env`` ::

conda create -n {{ cookiecutter.package_dist_name }}_env {{ cookiecutter.package_dist_name }}
conda activate {{ cookiecutter.package_dist_name }}_env
conda create -n {{ cookiecutter.conda_pypi_package_dist_name }}_env {{ cookiecutter.conda_pypi_package_dist_name }}
conda activate {{ cookiecutter.conda_pypi_package_dist_name }}_env

To confirm that the installation was successful, type ::

Expand All @@ -73,29 +73,29 @@ The output should print the latest version displayed on the badges above.

If the above does not work, you can use ``pip`` to download and install the latest release from
`Python Package Index <https://pypi.python.org>`_.
To install using ``pip`` into your ``{{ cookiecutter.package_dist_name }}_env`` environment, type ::
To install using ``pip`` into your ``{{ cookiecutter.conda_pypi_package_dist_name }}_env`` environment, type ::

pip install {{ cookiecutter.package_dist_name }}
pip install {{ cookiecutter.conda_pypi_package_dist_name }}

If you prefer to install from sources, after installing the dependencies, obtain the source archive from
`GitHub <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/>`_. Once installed, ``cd`` into your ``{{ cookiecutter.repo_name }}`` directory
`GitHub <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/>`_. Once installed, ``cd`` into your ``{{ cookiecutter.github_repo_name }}`` directory
and run the following ::

pip install .

Getting Started
---------------

You may consult our `online documentation <https://{{ cookiecutter.github_org }}.github.io/{{ cookiecutter.repo_name }}>`_ for tutorials and API references.
You may consult our `online documentation <https://{{ cookiecutter.github_org }}.github.io/{{ cookiecutter.github_repo_name }}>`_ for tutorials and API references.

Support and Contribute
----------------------

`Diffpy user group <https://groups.google.com/g/diffpy-users>`_ is the discussion forum for general questions and discussions about the use of {{ cookiecutter.package_dist_name }}. Please join the {{ cookiecutter.package_dist_name }} users community by joining the Google group. The {{ cookiecutter.package_dist_name }} project welcomes your expertise and enthusiasm!
`Diffpy user group <https://groups.google.com/g/diffpy-users>`_ is the discussion forum for general questions and discussions about the use of {{ cookiecutter.conda_pypi_package_dist_name }}. Please join the {{ cookiecutter.conda_pypi_package_dist_name }} users community by joining the Google group. The {{ cookiecutter.conda_pypi_package_dist_name }} project welcomes your expertise and enthusiasm!

If you see a bug or want to request a feature, please `report it as an issue <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/issues>`_ and/or `submit a fix as a PR <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/pulls>`_. You can also post it to the `Diffpy user group <https://groups.google.com/g/diffpy-users>`_.
If you see a bug or want to request a feature, please `report it as an issue <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/issues>`_ and/or `submit a fix as a PR <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/pulls>`_. You can also post it to the `Diffpy user group <https://groups.google.com/g/diffpy-users>`_.

Feel free to fork the project and contribute. To install {{ cookiecutter.package_dist_name }}
Feel free to fork the project and contribute. To install {{ cookiecutter.conda_pypi_package_dist_name }}
in a development mode, with its sources being directly used by Python
rather than copied to a package directory, use the following in the root
directory ::
Expand All @@ -116,9 +116,9 @@ trying to commit again.

Improvements and fixes are always appreciated.

Before contributing, please read our `Code of Conduct <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/blob/main/CODE_OF_CONDUCT.rst>`_.
Before contributing, please read our `Code of Conduct <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/blob/main/CODE_OF_CONDUCT.rst>`_.

Contact
-------

For more information on {{ cookiecutter.package_dist_name }} please visit the project `web-page <https://{{ cookiecutter.github_org }}.github.io/>`_ or email Prof. {{ cookiecutter.project_owner_name }} at {{ cookiecutter.project_owner_email }}.
For more information on {{ cookiecutter.conda_pypi_package_dist_name }} please visit the project `web-page <https://{{ cookiecutter.github_org }}.github.io/>`_ or email Prof. {{ cookiecutter.project_owner_name }} at {{ cookiecutter.project_owner_email }}.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
latex_documents = [
(
"index",
"{{ cookiecutter.package_dist_name }}.tex",
"{{ cookiecutter.conda_pypi_package_dist_name }}.tex",
"{{ cookiecutter.project_name }} Documentation",
ab_authors,
"manual",
Expand Down Expand Up @@ -258,7 +258,7 @@
man_pages = [
(
"index",
"{{ cookiecutter.package_dist_name }}",
"{{ cookiecutter.conda_pypi_package_dist_name }}",
"{{ cookiecutter.project_name }} Documentation",
ab_authors,
1,
Expand All @@ -277,7 +277,7 @@
texinfo_documents = [
(
"index",
"{{ cookiecutter.package_dist_name }}",
"{{ cookiecutter.conda_pypi_package_dist_name }}",
"{{ cookiecutter.project_name }} Documentation",
ab_authors,
"{{ cookiecutter.project_name }}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Authors
and its community contributors.

For a detailed list of contributors see
https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/graphs/contributors.
https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/graphs/contributors.

============
Installation
============

See the `README <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}#installation>`_
See the `README <https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}#installation>`_
file included with the distribution.

=================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: {{ cookiecutter.package_dist_name }}
name: {{ cookiecutter.conda_pypi_package_dist_name }}
channels:
- conda-forge
dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=62.0", "setuptools-git-versioning>=2.0"]
build-backend = "setuptools.build_meta"

[project]
name = "{{ cookiecutter.package_dist_name }}"
name = "{{ cookiecutter.conda_pypi_package_dist_name }}"
dynamic=['version', 'dependencies']
authors = [
{ name="{{ cookiecutter.project_owner_name }}", email="{{ cookiecutter.project_owner_email }}" },
Expand Down Expand Up @@ -40,8 +40,8 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/"
Issues = "https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/issues/"
Homepage = "https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/"
Issues = "https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.github_repo_name }}/issues/"

[tool.setuptools-git-versioning]
enabled = true
Expand Down
Loading

0 comments on commit b978513

Please sign in to comment.