Skip to content

Commit

Permalink
Update authors & license references (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
brynpickering authored Jan 30, 2025
1 parent b95117b commit 16e1429
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/workflows/commit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- README.md
- CHANGELOG.md
- LICENSE
- AUTHORS.md
- CONTRIBUTING.md
- docs/**
- mkdocs.yml
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- README.md
- CHANGELOG.md
- LICENSE
- AUTHORS.md
- CONTRIBUTING.md
- docs/**
- mkdocs.yml
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repos:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix, --config, pyproject.toml ]
- id: ruff-format
args: [ --config, pyproject.toml ]

ci: # https://pre-commit.ci/
autofix_prs: false
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ This is now captured by a pre-commit hook.

### Changed

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

### Removed

- Reference to authors removed from `src/<module-name>/__init__.py`. Authors now limited to `pyproject.toml` and - optionally - `AUTHORS.md`.

## [v0.2.0] - 09-01-2024

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"n"
],
"create_author_file": [
"y",
"n"
"n",
"y"
],
"create_jupyter_notebook_directory": [
"y",
Expand Down
2 changes: 1 addition & 1 deletion hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def remove_dir(dirpath: Path | str):
file_to_delete.unlink()

if "{{ cookiecutter.create_author_file|lower }}" == "n":
remove_file("AUTHORS")
remove_file("AUTHORS.md")

if "{{ cookiecutter.command_line_interface|lower }}" == "n":
for file in [
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ skip-magic-trailing-comma = true
quote-style = "double"
indent-style = "space"
line-ending = "auto"
exclude = ["\\{\\{cookiecutter.repository_name\\}}\\}}"]

[tool.ruff.lint]
select = [
Expand Down
2 changes: 1 addition & 1 deletion schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ properties:
description: If "y", create an authors file.
uniqueItems: true
minItems: 1
items: *y_n_items
items: *n_y_items

create_docker_file:
type: array
Expand Down
94 changes: 90 additions & 4 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,98 @@ def test_bake_explicit_repository_name(cookies, install_baked):
install_baked(result.project_path)


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

found_toplevel_files = [i.name for i in result.project_path.iterdir()]
assert "AUTHORS" not in found_toplevel_files
assert ("AUTHORS.md" in found_toplevel_files) is expected
assert (
"When you contribute for the first time, ensure you add your name to the contributors list in `AUTHORS.md`!"
in (result.project_path / "CONTRIBUTING.md").read_text()
) is expected


@pytest.mark.parametrize(
"license_name",
[
"MIT license",
"BSD license",
"ISC license",
"Apache Software License 2.0",
"GNU General Public License v3",
],
)
@pytest.mark.parametrize(
["org_name", "copyright_name"], [("arup-group", "Arup"), ("foobar", "Ove Arup")]
)
def test_bake_license_without_author_file(cookies, license_name, org_name, copyright_name):
result = cookies.bake(
extra_context={
"create_author_file": "n",
"open_source_license": license_name,
"repository_owner": org_name,
}
)

for file in ["LICENSE", "README.md", "CONTRIBUTING.md"]:
assert (
f"Copyright (c) {datetime.datetime.now().year} {copyright_name}."
in (result.project_path / file).read_text()
)


@pytest.mark.parametrize(
"license_name",
[
"MIT license",
"BSD license",
"ISC license",
"Apache Software License 2.0",
"GNU General Public License v3",
],
)
@pytest.mark.parametrize("create_author_file", ["y", "n"]) # should make no difference
def test_bake_license_with_author_file_and_arup_org(cookies, license_name, create_author_file):
result = cookies.bake(
extra_context={
"create_author_file": create_author_file,
"open_source_license": license_name,
"repository_owner": "arup-group",
}
)

for file in ["LICENSE", "README.md", "CONTRIBUTING.md"]:
assert (
f"Copyright (c) {datetime.datetime.now().year} Arup."
in (result.project_path / file).read_text()
)


@pytest.mark.parametrize(
"license_name",
[
"MIT license",
"BSD license",
"ISC license",
"Apache Software License 2.0",
"GNU General Public License v3",
],
)
def test_bake_license_with_author_file(cookies, license_name):
result = cookies.bake(
extra_context={
"create_author_file": "y",
"open_source_license": license_name,
"repository_owner": "foobar",
}
)

for file in ["LICENSE", "README.md", "CONTRIBUTING.md"]:
assert (
f"Copyright (c) {datetime.datetime.now().year} python_boilerplate developers & contributors listed in AUTHORS."
in (result.project_path / file).read_text()
)


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


def test_bake_with_no_console_script(cookies):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
=======
Credits
=======
# Credits

Development Lead
----------------
## Development Lead

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

Contributors
------------
## Contributors

None yet. Why not be the first?
5 changes: 5 additions & 0 deletions {{cookiecutter.repository_name}}/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Some of the resources to look at if you're interested in contributing:

## Licensing

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 %}.
{%- if cookiecutter.open_source_license == "Not open source" %}
This repository is not open source.
You will need explicit permission from the repository owner to redistribute or make any modifications to this code.
Expand Down Expand Up @@ -46,6 +47,10 @@ To contribute changes:
1. Push the branch to GitHub (`git push origin new-fix-or-feature`).
1. On GitHub, create a new [pull request](https://github.com/{{ cookiecutter.repository_owner }}/{{ cookiecutter.repository_name }}/pull/new/main) from the feature branch.

{%- if cookiecutter.create_author_file == "y" %}
When you contribute for the first time, ensure you add your name to the contributors list in `AUTHORS.md`!

{%- endif %}
### Pull requests

Before submitting a pull request, check whether you have:
Expand Down
21 changes: 12 additions & 9 deletions {{cookiecutter.repository_name}}/LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% if cookiecutter.open_source_license == 'MIT license' -%}
MIT License

Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% else %}{{ cookiecutter.full_name }}{% endif %}
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 %}.

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

{%- elif cookiecutter.open_source_license == 'BSD license' -%}
BSD License

Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% else %}{{ cookiecutter.full_name }}{% endif %}
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 %}.
All rights reserved.

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

{%- elif cookiecutter.open_source_license == 'ISC license' -%}
ISC License

Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% else %}{{ cookiecutter.full_name }}{% endif %}
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 %}.

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.

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.
{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%}

{%- elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%}
Apache Software License 2.0

Copyright (c) {% now 'local', '%Y' %} {% if cookiecutter.repository_owner == "arup-group" %}Arup{% else %}{{ cookiecutter.full_name }}{% endif %}
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 %}.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -75,12 +77,13 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
{% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%}

{%- elif cookiecutter.open_source_license == 'GNU General Public License v3' -%}
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

{{ cookiecutter.project_short_description }}
Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.full_name }}
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 %}.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
11 changes: 11 additions & 0 deletions {{cookiecutter.repository_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ mkdocs serve
Then you can view the documentation in a browser at <http://localhost:8000/>.
## License
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 %}.
{%- if cookiecutter.open_source_license == "Not open source" %}
This repository is not open source.
You will need explicit permission from the repository owner to redistribute or make any modifications to this code.
{%- else %}
Licensed under the {{ cookiecutter.open_source_license }}.
{%- endif %}
## Credits
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 number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""Top-level module for {{ cookiecutter.module_name }}."""

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

0 comments on commit 16e1429

Please sign in to comment.