A cookiecutter for Billinge-group packages.
The purpose of cookiecutting is to standardize each repository on GitHub Actions, folder structures, documentation, syntax linting, and running unit tests with Pytest.
This should be done only when the above steps are finished.
- Make sure tests are all passing.
- Make sure news is up to date so the changelog will reflect all changes. For the
cookierelease
activity make a<branchname>.rst
file by copyingTEMPLATE.rst
in the news folder and under "fixed" putRepo structure modified to the new diffpy standard
- Check the
README
and make sure that all parts have been filled in and all links resolve correctly. - Run through the documentation online and do the same, fix any last typos and make all the links work. To do this the documentation must have been correctly built on a merge to main and enabled on the github.io website. Instructions are here.
- When you are are happy to sign off on the release send a Slack message to Simon saying something like "
OK to release diffpy.<package-name>
" - Make sure that the codecov secret is set in the GH actions repository secrets. Probably Simon will have to do this here)
We are using diffpy.utils as a template for building the cookie cutter. To make sure the cookie cutter is giving output that is consistent with diffpy utils please use the following workflow:
- have all your code off a dir called
dev
or sthg like that - within
dev
create a scratch area calledscratch
- clone
diffpy.utils
in the scratch area of my hard-drive - cd to this directory.
- create an env that has
cookiecutter
andpexpect
in it.
- cd to
scratch/diffpy.utils
- run
python /path/to/your/local/cookiecutter_project/test_utils.py
which for me waspython ../../cookiecutter/test_utils.py
- This creates a new empty
diffpy.utils
under the old one using the current version of the cookie cutter (watch out, cookie cutter sometimes caches so if you make a change and it is not reflected, clear the cache). - cd to the directory that contains the file you are working on (for me it is
cd .
) - copy the file I am working on that was created by the cookiecutter to the current directory (for me it was
cp diffpy.utils/.pre-commit-config.yaml .
). It will overwrite the version that is already there. - run git diff
This shows all the things you have to change in the cookiecutter to get it to create the file the same way as it is in
diffpy.utils
. - When it passes this "test" and the only things left are things we want, push a PR to
cookiecutter
- Paste screenshot of your terminal session showing the result of the copy and git diff.
Billinge and Bob have agreed to include tests and the associated data files necessary for running these tests in the PyPI source distribution file. This decision is primarily aimed at enabling continuous integration (CI) on the Conda-Forge feedstock, which uses the PyPI release. You can monitor the CI progress by clicking on any of the PRs here: Conda-Forge diffpy.utils feedstock.
Conversely, we have opted not to include the documentation in the release package, as it is already accessible from the GitHub repository and does not serve a practical purpose in the distribution package itself.
Late update: Sep 10, 2024
If you use graft
and add the folder path, you will include all files in the source distribution when executing python -m build
.
graft src
graft tests
You can also specifically include files in the sdist:
include AUTHORS.txt LICENSE*.txt README.rst
Additionally, you can globally exclude static files:
global-exclude *.py[cod] # Exclude all .pyc, .pyo, and .pyd files.
global-exclude .DS_Store # Exclude Mac filesystem artifacts.
global-exclude __pycache__ # Exclude Python cache directories.
global-exclude .git* # Exclude git files and directories.
Reference:
In the current CI setup checking for news
, we use pull_request_target
instead of pull_request
.
name: Check News Item
on:
pull_request_target:
branches:
- main
pull_request
: This event configures the GITHUB_TOKEN with read-only permissions by default, especially when triggered by forks.pull_request_target
: This event grants the GITHUB_TOKEN write permissions, enabling it to perform actions that modify the repository, such as posting comments, updating pull request statuses, or merging code.
Another key difference is that when using the pull_request_target
event in GitHub Actions, the workflow configuration must already be present in the base branch at the time the pull request is opened or updated (diffpy.snmf example PR)
Reference:
Adapted from the NSLS-II scientific cookiecutter, thanks guys!: https://github.com/nsls-ii/scientific-python-cookiecutter
Here are more in-depth docs for using this from NSLS-II, adapted for this repr: