Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8941824
Have deploy_license support multiple file refs
boltronics Nov 26, 2024
ade1ec9
List licenses by SPDX identifier
boltronics Nov 26, 2024
f368121
Update GPLv2 license (removes FSF postal address)
boltronics Nov 26, 2024
f05eecc
Remove EXPAT license
boltronics Nov 26, 2024
44295d7
Move mypi.ini contents to pyproject.toml
boltronics Nov 26, 2024
8c4f4a2
Switch from setuptools to Hatch
boltronics Nov 26, 2024
1c242d3
Update README.rst to reflect template changes
boltronics Nov 26, 2024
a9bcaee
Update GitHub Actions Workflow configuration
boltronics Nov 26, 2024
9a540b9
Limit Python support to 3.11+
boltronics Nov 26, 2024
5f7d4ae
Prevent a bug due to unlinking a missing file
boltronics Nov 29, 2024
6023879
Remove requirements.txt and requirements.dev.txt
boltronics Nov 29, 2024
ba9c5aa
Fix pyproject.toml syntax errors
boltronics Nov 29, 2024
0cd9714
Improve pyproject.toml license handling
boltronics Nov 29, 2024
c31ad16
Update Makefile to use pyproject.toml and hatch
boltronics Nov 29, 2024
25f0a7d
Improve Makefile whitespace formatting
boltronics Nov 29, 2024
a19f1a9
Correct path of file containing package version
boltronics Nov 29, 2024
120abd7
Add hatch to dev optional dependencies
boltronics Nov 29, 2024
113c0eb
Check git is available before calling in Makefile
boltronics Nov 29, 2024
a8b6d38
Makefile indentation fix
boltronics Nov 29, 2024
c15d250
Update GitHub Actions root project cache key
boltronics Nov 29, 2024
dcf959a
Make GitHub Actions run `make venv` instead of pip
boltronics Nov 29, 2024
c172299
Have GitHub Actions load the venv before checks
boltronics Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand All @@ -29,7 +29,7 @@ jobs:
with:
path: ~/.cache/pip # This path is specific to Ubuntu
# Check for a cache hit for the corresponding dev requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.dev.txt') }}-${{ hashFiles('requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
Expand All @@ -39,8 +39,8 @@ jobs:
- name: Check example project
run: |
cd example
pip install -r requirements.dev.txt
pip install .
make venv
. venv/bin/activate
make help
make style
make check-style
Expand Down
52 changes: 27 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ the following items:
developer documentation.
- An empty ``CHANGELOG.rst`` file. This file gets included in the user
documentation.
- A ``LICENSE`` file (or ``COPYING`` for GNU licenses) that defaults
to the Apache License version 2.0.
- An option ``LICENSE`` file (or ``COPYING`` for GNU licenses).
- An ``examples`` directory with a minimal quickstart example script. This
script imports the package and prints the package version. It is also
called by the unit test suite to ensure it always works.
Expand Down Expand Up @@ -77,9 +76,9 @@ cookiecutter using ``pip``. The example below shows how to do this.

.. code-block:: console

$ python -m venv ccvenv --prompt cc
$ python -m venv --prompt cc ccvenv
$ source ccvenv/bin/activate
(cc) $ pip install pip -U # update pip to avoid any warnings
(cc) $ pip install -U pip # update pip to avoid any warnings
(cc) $ pip install cookiecutter

You are now ready to create a new Python project from the Cookiecutter
Expand Down Expand Up @@ -132,11 +131,12 @@ using the new project.
ReadTheDocs then remove any links to those sites. Affected files are:

- README.rst
- setup.py
- docs/source/index.rst
- pyproject.toml

- Update any additional useful classifiers in ``setup.py``. The list of
available classifiers can be found `here <https://pypi.python.org/pypi?:action=list_classifiers>`_.
- Update any additional useful classifiers in ``pyproject.toml``. The
list of available classifiers can be found `here
<https://pypi.python.org/pypi?:action=list_classifiers>`_.


Example
Expand All @@ -162,24 +162,26 @@ Python package name.
.. code-block:: console

(cc) $ cookiecutter ../cookiecutter-python-project/
package_display_name [Package-Name]: abc 123
package_name [abc_123]:
package_short_description [A description of the package]: This is my abc 123 package.
version [0.0.1]:
full_name [Your Name]: First Last
email []:
github_user_name [GithubUserName]: flast
github_repo_name [abc_123]:
Select license:
1 - Apache License, Version 2.0
2 - Expat License
3 - GNU GPL version 2
4 - GNU GPL version 3
5 - GNU AGPL version 3
6 - Modified BSD license (3-clause)
7 - Not licensed for distribution (no license)
Choose from 1, 2, 3, 4, 5, 6, 7 [1]:
year [2023]:
[1/10] package_display_name (Package-Name): abc 123
[2/10] package_name (abc_123):
[3/10] package_short_description (A description of the package): This is my abc 123 package.
[4/10] version (0.0.1):
[5/10] full_name (Your Name): First Last
[6/10] email ():
[7/10] github_user_name (GithubUserName): flast
[8/10] github_repo_name (abc_123):
[9/10] Select license
1 - Not licensed for distribution (no license)
2 - AGPL-3.0-only
3 - AGPL-3.0-or-later
4 - Apache-2.0
5 - BSD-3-Clause
6 - GPL-2.0-only
7 - GPL-2.0-or-later
8 - GPL-3.0-only
9 - GPL-3.0-or-later
Choose from [1/2/3/4/5/6/7/8/9] (1):
[10/10] year (2024):

The project has been created in the ``abc_123`` directory.

Expand Down
16 changes: 9 additions & 7 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
"github_user_name": "GithubUserName",
"github_repo_name": "{{cookiecutter.package_name}}",
"license": [
"Apache License, Version 2.0",
"Expat License",
"GNU GPL version 2",
"GNU GPL version 3",
"GNU AGPL version 3",
"Modified BSD license (3-clause)",
"Not licensed for distribution (no license)"
"Not licensed for distribution (no license)",
"AGPL-3.0-only",
"AGPL-3.0-or-later",
"Apache-2.0",
"BSD-3-Clause",
"GPL-2.0-only",
"GPL-2.0-or-later",
"GPL-3.0-only",
"GPL-3.0-or-later"
],
"year": "{% now 'utc', '%Y' %}"
}
18 changes: 12 additions & 6 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@
LICENSE_SELECTED = "{{ cookiecutter.license }}"


def deploy_license():
def deploy_license() -> None:
"""Move the selected license file into the project root

Licenses not selected for the project are removed.
"""
sources: set[Path] = set()
selected_source = None
with LICENSE_CONFIG.open(mode="r", encoding="utf-8") as config_file:
config = json.load(config_file)
for license_option, license_data in config.items():
source_path = LICENSE_DIR.joinpath(license_data["source"])
if license_option == LICENSE_SELECTED:
LICENSE_DIR.joinpath(license_data["source"]).rename(
PROJECT_DIR.joinpath(license_data["destination"])
)
else:
LICENSE_DIR.joinpath(license_data["source"]).unlink()
selected_source = source_path
destination_path = PROJECT_DIR.joinpath(license_data["destination"])
source_path.rename(destination_path)
sources.discard(source_path)
elif license_data["source"] != selected_source:
sources.add(source_path)
for source in sources:
source.unlink()
LICENSE_CONFIG.unlink()
LICENSE_DIR.rmdir()

Expand Down
11 changes: 5 additions & 6 deletions {{cookiecutter.package_name}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand All @@ -23,15 +23,14 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.dev.txt
pip install -r requirements.txt
python -m pip install -U pip
python -m pip install .[dev]
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip # This path is specific to Ubuntu
# Check for a cache hit for the corresponding dev requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.dev.txt') }}-${{ hashFiles('requirements.txt') }}
# Check for a cache hit for the corresponding pyproject.toml file
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
Expand Down
28 changes: 18 additions & 10 deletions {{cookiecutter.package_name}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
# python command links to the appropriate virtual environment Python.

MAKEFLAGS += --no-print-directory
GIT := $(shell command -v git)


define CHECK_GIT
$(if $(GIT),,$(error "git command not available."))
$(if $(wildcard .git),,$(error "Not a git repository."))
endef


# Do not remove this block. It is used by the 'help' rule when
# constructing the help output.
# help:
# help: {{cookiecutter.package_display_name}} Makefile help
# help:


# help: help - display makefile help information
.PHONY: help
help:
Expand All @@ -21,10 +30,9 @@ help:

# help: venv - create a dev virtual environment
PIP_CMDS = \
source venv/bin/activate && \
pip install pip --upgrade && \
pip install -r requirements.dev.txt && \
pip install -e .
source venv/bin/activate && \
pip install -U pip && \
pip install -e .[dev]
.PHONY: venv
venv:
@rm -Rf venv
Expand All @@ -34,17 +42,18 @@ venv:
"\n\n\t$ source venv/bin/activate\n"



# help: clean - clean all files using .gitignore rules
.PHONY: clean
clean:
@git clean -X -f -d
$(call CHECK_GIT)
@$(GIT) clean -X -f -d


# help: scrub - clean all files, even untracked files
.PHONY: scrub
scrub:
git clean -x -f -d
$(call CHECK_GIT)
@$(GIT) clean -x -f -d


# help: test - run tests
Expand Down Expand Up @@ -114,8 +123,7 @@ check-lint:
@pylint --rcfile=.pylintrc \
{{cookiecutter.package_name}} \
examples \
tests \
setup.py
tests


# help: check-static-analysis - check code style compliance
Expand Down Expand Up @@ -149,7 +157,7 @@ serve-docs:
# help: dist - create a wheel distribution package
.PHONY: dist
dist:
@python setup.py bdist_wheel
@hatch build


# help: dist-test - test a wheel distribution package
Expand Down
20 changes: 0 additions & 20 deletions {{cookiecutter.package_name}}/licenses/EXPAT

This file was deleted.

9 changes: 4 additions & 5 deletions {{cookiecutter.package_name}}/licenses/GPL2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -304,8 +304,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
with this program; if not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

Expand All @@ -329,8 +328,8 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
<signature of Moe Ghoul>, 1 April 1989
Moe Ghoul, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
Expand Down
14 changes: 8 additions & 6 deletions {{cookiecutter.package_name}}/licenses/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"Apache License, Version 2.0": {"source": "APACHE-2.0", "destination": "LICENSE"},
"Expat License": {"source": "EXPAT", "destination": "LICENSE"},
"GNU GPL version 3": {"source": "GPL3", "destination": "COPYING"},
"GNU GPL version 2": {"source": "GPL2", "destination": "COPYING"},
"GNU AGPL version 3": {"source": "AGPL3", "destination": "COPYING"},
"Modified BSD license (3-clause)": {"source": "BSD-3-CLAUSE", "destination": "LICENSE"}
"AGPL-3.0-only": {"source": "AGPL3", "destination": "COPYING"},
"AGPL-3.0-or-later": {"source": "AGPL3", "destination": "COPYING"},
"Apache-2.0": {"source": "APACHE-2.0", "destination": "LICENSE"},
"BSD-3-Clause": {"source": "BSD-3-CLAUSE", "destination": "LICENSE"},
"GPL-2.0-only": {"source": "GPL2", "destination": "COPYING"},
"GPL-2.0-or-later": {"source": "GPL2", "destination": "COPYING"},
"GPL-3.0-only": {"source": "GPL3", "destination": "COPYING"},
"GPL-3.0-or-later": {"source": "GPL3", "destination": "COPYING"}
}
7 changes: 0 additions & 7 deletions {{cookiecutter.package_name}}/mypi.ini

This file was deleted.

Loading