Skip to content

Commit 88071e3

Browse files
committed
Merge branch 'main' into fix-minor-issues
2 parents 8630fd3 + 16e1429 commit 88071e3

File tree

14 files changed

+136
-27
lines changed

14 files changed

+136
-27
lines changed

.github/workflows/commit-ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- README.md
99
- CHANGELOG.md
1010
- LICENSE
11+
- AUTHORS.md
1112
- CONTRIBUTING.md
1213
- docs/**
1314
- mkdocs.yml

.github/workflows/pr-ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- README.md
99
- CHANGELOG.md
1010
- LICENSE
11+
- AUTHORS.md
1112
- CONTRIBUTING.md
1213
- docs/**
1314
- mkdocs.yml

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repos:
1414
- id: ruff
1515
args: [ --fix, --exit-non-zero-on-fix, --config, pyproject.toml ]
1616
- id: ruff-format
17+
args: [ --config, pyproject.toml ]
1718

1819
ci: # https://pre-commit.ci/
1920
autofix_prs: false

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ This is now captured by a pre-commit hook.
3838

3939
### Changed
4040

41+
- Reference to authors in license files/sections.
42+
- `AUTHORS.md` defaults to _not_ being created when baking a project.
4143
- `upload_pypi_package` -> `upload_pip_package`.
4244
- Recommend `conda` instead of `mamba` for project creation and package installation (#53).
4345
- Docs CI run on PR to main or on main, with different jobs run in each case (#33).
@@ -47,6 +49,10 @@ This is now captured by a pre-commit hook.
4749
- Cookiecutter config set to have no license for the repository (i.e. internal IP) by default.
4850
- Make upload and build of Docker image on AWS optional (#42).
4951

52+
### Removed
53+
54+
- Reference to authors removed from `src/<module-name>/__init__.py`. Authors now limited to `pyproject.toml` and - optionally - `AUTHORS.md`.
55+
5056
## [v0.2.0] - 09-01-2024
5157

5258
### Fixed

cookiecutter.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"n"
3232
],
3333
"create_author_file": [
34-
"y",
35-
"n"
34+
"n",
35+
"y"
3636
],
3737
"create_jupyter_notebook_directory": [
3838
"y",

hooks/post_gen_project.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def remove_dir(dirpath: Path | str):
2929
file_to_delete.unlink()
3030

3131
if "{{ cookiecutter.create_author_file|lower }}" == "n":
32-
remove_file("AUTHORS")
32+
remove_file("AUTHORS.md")
3333

3434
if "{{ cookiecutter.command_line_interface|lower }}" == "n":
3535
for file in [

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ skip-magic-trailing-comma = true
1717
quote-style = "double"
1818
indent-style = "space"
1919
line-ending = "auto"
20+
exclude = ["\\{\\{cookiecutter.repository_name\\}}\\}}"]
2021

2122
[tool.ruff.lint]
2223
select = [

schema.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ properties:
127127
description: If "y", create an authors file.
128128
uniqueItems: true
129129
minItems: 1
130-
items: *y_n_items
130+
items: *n_y_items
131131

132132
create_docker_file:
133133
type: array

tests/test_bake_project.py

+90-4
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,98 @@ def test_bake_explicit_repository_name(cookies, install_baked):
8181
install_baked(result.project_path)
8282

8383

84-
def test_bake_without_author_file(cookies):
85-
result = cookies.bake(extra_context={"create_author_file": "n"})
84+
@pytest.mark.parametrize(("create_author_file", "expected"), [("y", True), ("n", False)])
85+
def test_bake_with_or_without_author_file(cookies, create_author_file, expected):
86+
result = cookies.bake(extra_context={"create_author_file": create_author_file})
8687

8788
found_toplevel_files = [i.name for i in result.project_path.iterdir()]
88-
assert "AUTHORS" not in found_toplevel_files
89+
assert ("AUTHORS.md" in found_toplevel_files) is expected
90+
assert (
91+
"When you contribute for the first time, ensure you add your name to the contributors list in `AUTHORS.md`!"
92+
in (result.project_path / "CONTRIBUTING.md").read_text()
93+
) is expected
94+
95+
96+
@pytest.mark.parametrize(
97+
"license_name",
98+
[
99+
"MIT license",
100+
"BSD license",
101+
"ISC license",
102+
"Apache Software License 2.0",
103+
"GNU General Public License v3",
104+
],
105+
)
106+
@pytest.mark.parametrize(
107+
["org_name", "copyright_name"], [("arup-group", "Arup"), ("foobar", "Ove Arup")]
108+
)
109+
def test_bake_license_without_author_file(cookies, license_name, org_name, copyright_name):
110+
result = cookies.bake(
111+
extra_context={
112+
"create_author_file": "n",
113+
"open_source_license": license_name,
114+
"repository_owner": org_name,
115+
}
116+
)
117+
118+
for file in ["LICENSE", "README.md", "CONTRIBUTING.md"]:
119+
assert (
120+
f"Copyright (c) {datetime.datetime.now().year} {copyright_name}."
121+
in (result.project_path / file).read_text()
122+
)
123+
124+
125+
@pytest.mark.parametrize(
126+
"license_name",
127+
[
128+
"MIT license",
129+
"BSD license",
130+
"ISC license",
131+
"Apache Software License 2.0",
132+
"GNU General Public License v3",
133+
],
134+
)
135+
@pytest.mark.parametrize("create_author_file", ["y", "n"]) # should make no difference
136+
def test_bake_license_with_author_file_and_arup_org(cookies, license_name, create_author_file):
137+
result = cookies.bake(
138+
extra_context={
139+
"create_author_file": create_author_file,
140+
"open_source_license": license_name,
141+
"repository_owner": "arup-group",
142+
}
143+
)
144+
145+
for file in ["LICENSE", "README.md", "CONTRIBUTING.md"]:
146+
assert (
147+
f"Copyright (c) {datetime.datetime.now().year} Arup."
148+
in (result.project_path / file).read_text()
149+
)
150+
151+
152+
@pytest.mark.parametrize(
153+
"license_name",
154+
[
155+
"MIT license",
156+
"BSD license",
157+
"ISC license",
158+
"Apache Software License 2.0",
159+
"GNU General Public License v3",
160+
],
161+
)
162+
def test_bake_license_with_author_file(cookies, license_name):
163+
result = cookies.bake(
164+
extra_context={
165+
"create_author_file": "y",
166+
"open_source_license": license_name,
167+
"repository_owner": "foobar",
168+
}
169+
)
170+
171+
for file in ["LICENSE", "README.md", "CONTRIBUTING.md"]:
172+
assert (
173+
f"Copyright (c) {datetime.datetime.now().year} python_boilerplate developers & contributors listed in AUTHORS."
174+
in (result.project_path / file).read_text()
175+
)
89176

90177

91178
def test_bake_without_docker_file(cookies):
@@ -265,7 +352,6 @@ def test_bake_not_open_source(cookies):
265352
found_toplevel_files = [i.name for i in result.project_path.iterdir()]
266353
assert "pyproject.toml" in found_toplevel_files
267354
assert "LICENSE" not in found_toplevel_files
268-
assert "License" not in (result.project_path / "README.md").read_text()
269355

270356

271357
def test_bake_with_no_console_script(cookies):
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
=======
2-
Credits
3-
=======
1+
# Credits
42

5-
Development Lead
6-
----------------
3+
## Development Lead
74

85
* {{ cookiecutter.full_name }} <{{ cookiecutter.email }}>
96

10-
Contributors
11-
------------
7+
## Contributors
128

139
None yet. Why not be the first?

{{cookiecutter.repository_name}}/CONTRIBUTING.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Some of the resources to look at if you're interested in contributing:
99

1010
## Licensing
1111

12-
{% if cookiecutter.open_source_license == "Not open source" -%}
12+
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% elif cookiecutter.create_author_file == "y" %}{{ cookiecutter.package_name }} developers & contributors listed in AUTHORS.md{% else %}{{ cookiecutter.full_name }}{% endif %}.
13+
{%- if cookiecutter.open_source_license == "Not open source" %}
1314
This repository is not open source.
1415
You will need explicit permission from the repository owner to redistribute or make any modifications to this code.
1516
{%- else %}
@@ -46,6 +47,10 @@ To contribute changes:
4647
1. Push the branch to GitHub (`git push origin new-fix-or-feature`).
4748
1. On GitHub, create a new [pull request](https://github.com/{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}/pull/new/main) from the feature branch.
4849

50+
{%- if cookiecutter.create_author_file == "y" %}
51+
When you contribute for the first time, ensure you add your name to the contributors list in `AUTHORS.md`!
52+
53+
{%- endif %}
4954
### Pull requests
5055

5156
Before submitting a pull request, check whether you have:

{{cookiecutter.repository_name}}/LICENSE

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% if cookiecutter.open_source_license == 'MIT license' -%}
22
MIT License
33

4-
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% else %}{{ cookiecutter.full_name }}{% endif %}
4+
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% elif cookiecutter.create_author_file == "y" %}{{ cookiecutter.package_name }} developers & contributors listed in AUTHORS.md{% else %}{{ cookiecutter.full_name }}{% endif %}.
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal
@@ -20,11 +20,11 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
23-
{% elif cookiecutter.open_source_license == 'BSD license' %}
2423

24+
{%- elif cookiecutter.open_source_license == 'BSD license' -%}
2525
BSD License
2626

27-
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% else %}{{ cookiecutter.full_name }}{% endif %}
27+
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% elif cookiecutter.create_author_file == "y" %}{{ cookiecutter.package_name }} developers & contributors listed in AUTHORS.md{% else %}{{ cookiecutter.full_name }}{% endif %}.
2828
All rights reserved.
2929

3030
Redistribution and use in source and binary forms, with or without modification,
@@ -51,18 +51,20 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
5151
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
5252
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
5353
OF THE POSSIBILITY OF SUCH DAMAGE.
54-
{% elif cookiecutter.open_source_license == 'ISC license' -%}
54+
55+
{%- elif cookiecutter.open_source_license == 'ISC license' -%}
5556
ISC License
5657

57-
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% else %}{{ cookiecutter.full_name }}{% endif %}
58+
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% elif cookiecutter.create_author_file == "y" %}{{ cookiecutter.package_name }} developers & contributors listed in AUTHORS.md{% else %}{{ cookiecutter.full_name }}{% endif %}.
5859

5960
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6061

6162
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
62-
{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%}
63+
64+
{%- elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%}
6365
Apache Software License 2.0
6466

65-
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% else %}{{ cookiecutter.full_name }}{% endif %}
67+
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% elif cookiecutter.create_author_file == "y" %}{{ cookiecutter.package_name }} developers & contributors listed in AUTHORS.md{% else %}{{ cookiecutter.full_name }}{% endif %}.
6668

6769
Licensed under the Apache License, Version 2.0 (the "License");
6870
you may not use this file except in compliance with the License.
@@ -75,12 +77,13 @@ distributed under the License is distributed on an "AS IS" BASIS,
7577
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7678
See the License for the specific language governing permissions and
7779
limitations under the License.
78-
{% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%}
80+
81+
{%- elif cookiecutter.open_source_license == 'GNU General Public License v3' -%}
7982
GNU GENERAL PUBLIC LICENSE
8083
Version 3, 29 June 2007
8184

8285
{{ cookiecutter.project_short_description }}
83-
Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.full_name }}
86+
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% elif cookiecutter.create_author_file == "y" %}{{ cookiecutter.package_name }} developers & contributors listed in AUTHORS.md{% else %}{{ cookiecutter.full_name }}{% endif %}.
8487

8588
This program is free software: you can redistribute it and/or modify
8689
it under the terms of the GNU General Public License as published by

{{cookiecutter.repository_name}}/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ mkdocs serve
9797
9898
Then you can view the documentation in a browser at <http://localhost:8000/>.
9999
100+
## License
101+
102+
Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% elif cookiecutter.create_author_file == "y" %}{{ cookiecutter.package_name }} developers & contributors listed in AUTHORS.md{% else %}{{ cookiecutter.full_name }}{% endif %}.
103+
104+
{%- if cookiecutter.open_source_license == "Not open source" %}
105+
This repository is not open source.
106+
You will need explicit permission from the repository owner to redistribute or make any modifications to this code.
107+
{%- else %}
108+
Licensed under the {{ cookiecutter.open_source_license }}.
109+
{%- endif %}
110+
100111
## Credits
101112
102113
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [arup-group/cookiecutter-pypackage](https://github.com/arup-group/cookiecutter-pypackage) project template.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
"""Top-level module for {{ cookiecutter.module_name }}."""
22

3-
__author__ = """{{ cookiecutter.full_name }}""" # triple quotes in case the name has quotes in it.
4-
__email__ = "{{ cookiecutter.email }}"
53
__version__ = "0.1.0.dev0"

0 commit comments

Comments
 (0)