Skip to content

Commit

Permalink
Merge branch 'refs/heads/upstream-master' into upstream
Browse files Browse the repository at this point in the history
# Conflicts:
#	cookiecutter.json
#	hooks/post_gen_project.py
#	hooks/pre_gen_project.py
#	requirements_dev.txt
#	setup.py
#	tests/test_bake_project.py
#	tox.ini
#	{{cookiecutter.project_slug}}/CONTRIBUTING.rst
#	{{cookiecutter.project_slug}}/Makefile
#	{{cookiecutter.project_slug}}/pyproject.toml
#	{{cookiecutter.project_slug}}/requirements_dev.txt
#	{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py
#	{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cli.py
  • Loading branch information
Zeitsperre committed May 6, 2024
2 parents 5789eda + 301ecea commit 16c0220
Show file tree
Hide file tree
Showing 21 changed files with 242 additions and 57 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# GitHub CI build pipeline
name: Cookiecutter PyPackage CI build

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v3
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; else pip install .; fi
- name: Run Tests
run: |
pytest tests/
- name: Run package creation
run: |
python -m pip install --user --upgrade build
python -m build
- name: Archive package
uses: actions/upload-artifact@v2
with:
name: cookie-cutter
path: src/dist
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Ready to contribute? Here's how to set up `cookiecutter-pypackage` for local dev

.. code-block:: bash
$ pip install -rrequirements_dev.txt
$ pip install -r requirements_dev.txt
$ pytest ./tests
If you get any errors while installing cryptography package (something like `#include <openssl/aes.h>`). Please update your pip version and try again:
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
BAKE_OPTIONS=--no-input

help:
@echo "bake generate project using defaults"
@echo "watch generate project using defaults and watch for changes"
@echo "replay replay last cookiecutter run and watch for changes"
@echo "bake Generate project using defaults"
@echo "help Show this help"
@echo "test Run the tests"
@echo "replay Replay last cookiecutter run and watch for changes"
@echo "watch Generate project using defaults and watch for changes"


bake:
bake: # Generate project using defaults
cookiecutter $(BAKE_OPTIONS) . --overwrite-if-exists

watch: bake
Expand All @@ -14,3 +17,6 @@ watch: bake
replay: BAKE_OPTIONS=--replay
replay: watch
;

test:
pytest
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Cookiecutter_ template for a Python package.
* GitHub repo (fork): https://github.com/Ouranosinc/cookiecutter-pypackage/
* Documentation (upstream): https://cookiecutter-pypackage.readthedocs.io/
* Free software: BSD license
* Discord: https://discord.gg/PWXJr3upUE

Features
--------
Expand Down
5 changes: 3 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"add_pyup_badge": "n",
"make_docs": "y",
"add_translations": "y",
"command_line_interface": ["Click", "Argparse", "No command-line interface"],
"command_line_interface": ["Typer", "Click", "Argparse", "No command-line interface"],
"create_author_file": "y",
"open_source_license": [
"MIT license",
Expand All @@ -23,5 +23,6 @@
"GNU General Public License v3",
"Not open source"
],
"generated_with_cruft": "y"
"generated_with_cruft": "y",
"__gh_slug": "{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}"
}
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import shlex
# import sys
# import os
# import shlex

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
13 changes: 5 additions & 8 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ On Windows, activate it like this. You may find that using a Command Prompt wind
> \path\to\env\Scripts\activate
.. note::

If you create your virtual environment folder in a different location within your project folder, be sure to add that path to your .gitignore file.

Install cookiecutter:

Expand All @@ -55,17 +58,15 @@ Use cookiecutter, pointing it at the cookiecutter-pypackage repo:
cookiecutter https://github.com/audreyfeldroy/cookiecutter-pypackage.git
You'll be asked to enter a bunch of values to set the package up.
If you don't know what to enter, stick with the defaults.
You'll be asked to enter various values to set the package up.
If you don't know what to enter, press Enter to stick with the defaults.


Step 3: Create a GitHub Repo
----------------------------

Go to your GitHub account and create a new repo named ``mypackage``, where ``mypackage`` matches the ``[project_slug]`` from your answers to running cookiecutter. This is so that Travis CI and pyup.io can find it when we get to Step 5.

``If your virtualenv folder is within your project folder, be sure to add the virtualenv folder name to your .gitignore file.``

You will find one folder named after the ``[project_slug]``. Move into this folder, and then setup git to use your GitHub repo and upload the code:

.. code-block:: bash
Expand All @@ -77,10 +78,6 @@ You will find one folder named after the ``[project_slug]``. Move into this fold
git remote add origin git@github.com:myusername/mypackage.git
git push -u origin main
.. note::
GitHub has changed the default branch name from 'master' to 'main'. If you are using another Git repository hosting service that uses the Git branch naming defaults, you might need to use 'master' instead of 'main'.
Where ``myusername`` and ``mypackage`` are adjusted for your username and package name.

You'll need a ssh key to push the repo. You can `Generate`_ a key or `Add`_ an existing one.
Expand Down
1 change: 0 additions & 1 deletion hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@

# Exit to cancel project
sys.exit(1)
1
21 changes: 10 additions & 11 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
alabaster
build
cookiecutter
coverage
flit
pre-commit
pytest-cookies
pytest
tox>=4.0
twine
watchdog>=0.9.0
alabaster>=0.7.16
build>=1.2.1
cookiecutter>=2.6.0
coverage>=7.5.1
flit>=3.9.0
pre-commit>=3.7.0
pytest-cookies>=0.7.0
pytest>=8.2.0
tox>=4.15.0
watchdog>=4.0.0
3 changes: 3 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exclude = [
"*cookiecutter.project_slug*"
]
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
packages=[],
version='0.1.0',
description='Cookiecutter template for a Python package',
author='Audrey Roy Greenfeld',
author='Audrey M. Roy Greenfeld',
license='BSD',
author_email='aroy@alum.mit.edu',
url='https://github.com/audreyr/cookiecutter-pypackage',
author_email='audrey@feldroy.com',
url='https://github.com/audreyfeldroy/cookiecutter-pypackage',
keywords=['cookiecutter', 'template', 'package', ],
python_requires='>=3.8',
python_requires='>=3.9',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
Expand All @@ -20,10 +20,11 @@
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development',
Expand Down
5 changes: 4 additions & 1 deletion tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def test_year_compute_in_license_file(cookies):

def project_info(result):
"""Get toplevel dir, project_slug, and project dir from baked cookies"""
project_path = str(result.project_path)
assert result.exception is None
assert result.project.isdir()

project_path = str(result.project)
project_slug = os.path.split(project_path)[-1]
project_dir = os.path.join(project_path, project_slug)
return project_path, project_slug, project_dir
Expand Down
4 changes: 4 additions & 0 deletions {{cookiecutter.project_slug}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# Dask worker cache
dask-worker-space/

# pyenv
.python-version

Expand Down Expand Up @@ -108,3 +111,4 @@ ENV/
# IDE settings
.vscode/
.idea/

84 changes: 84 additions & 0 deletions {{cookiecutter.project_slug}}/CODE_OF_CONDUCT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
====================================
Contributor Covenant Code of Conduct
====================================

Our Pledge
----------

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

Our Standards
-------------

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

Our Responsibilities
--------------------

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

Scope
-----

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

Enforcement
-----------

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

Attribution
-----------

This Code of Conduct is adapted from the `Contributor Covenant`_, version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

.. _`Contributor Covenant`: https://www.contributor-covenant.org
27 changes: 19 additions & 8 deletions {{cookiecutter.project_slug}}/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ Ready to contribute? Here's how to set up ``{{ cookiecutter.project_slug }}`` fo

#. When you're done making changes, we **strongly** suggest running the tests in your environment or with the help of ``tox``::

$ python -m pytest
# Or, to run multiple build tests
$ tox
$ make lint
$ make test
Or
$ make test-all
Or
$ python -m tox

#. Commit your changes and push your branch to GitHub::

Expand All @@ -139,7 +142,7 @@ Ready to contribute? Here's how to set up ``{{ cookiecutter.project_slug }}`` fo
$ make autodoc
$ make -C docs html
# To simply test that the docs pass build checks
$ tox -e docs
$ python -m tox -e docs

#. Once your Pull Request has been accepted and merged to the ``main`` branch, several automated workflows will be triggered:

Expand All @@ -158,7 +161,7 @@ Before you submit a pull request, check that it meets these guidelines:

#. If the pull request adds functionality, the docs should also be updated. Put your new functionality into a function with a docstring, and add the feature to the list in ``README.rst``.

#. The pull request should work for Python 3.8, 3.9, 3.10, 3.11, and 3.12. Check that the tests pass for all supported Python versions.
#. The pull request should work for Python 3.8, 3.9, 3.10, 3.11, 3.12 and PyPy. Check that the tests pass for all supported Python versions.

Tips
----
Expand All @@ -167,7 +170,7 @@ To run a subset of tests::

{% if cookiecutter.use_pytest == 'y' -%}
$ pytest tests.test_{{ cookiecutter.project_slug }}
{%- else -%}
{% else %}
$ python -m unittest tests.test_{{ cookiecutter.project_slug }}
{%- endif %}

Expand All @@ -181,8 +184,8 @@ To run specific code style checks::

To get ``black``, ``isort``, ``blackdoc``, ``ruff``, and ``flake8`` (with plugins ``flake8-alphabetize`` and ``flake8-rst-docstrings``) simply install them with `pip` {% if cookiecutter.use_conda == 'y' %}(or `conda`) {% endif %}into your environment.

Versioning/Tagging
------------------
Deployment
----------

A reminder for the **maintainers** on how to deploy. This section is only relevant when producing a new point release for the package.

Expand Down Expand Up @@ -285,3 +288,11 @@ This will then place two files in `{{ cookiecutter.project_slug }}/dist/` ("{{ c
We can now leave our docker container (`$ exit`) and continue with uploading the files to PyPI::

$ twine upload dist/*

Code of Conduct
---------------

Please note that this project is released with a `Contributor Code of Conduct`_.
By participating in this project you agree to abide by its terms.

.. _`Contributor Code of Conduct`: CODE_OF_CONDUCT.rst
Loading

0 comments on commit 16c0220

Please sign in to comment.