Skip to content

Commit ad9c75c

Browse files
committed
License Picking and Private Repos
This addresses issues #17, #18 and #19. - Added MIT license metadata to cookiecutter.json - Added No License metadatta to cookiecutter.json - Added make_github_repo_private to cookiecutter.json - Updated template pyproject to conditionally include license metadata. Given how the license files are named in the template root, they are all removed during the templating phase since none of them will match "no-license". Updated the hook post_gen_project.uv with Jinja conditionals to pick the "--public" flag by default or "--private" if cookiecutter.make_github_repo_private is true.
1 parent f3802f8 commit ad9c75c

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

cookiecutter.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"repository": "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.package_name }}",
1616
"readme_badges": true,
1717
"create_github_repo": true,
18-
"license": ["apache-2.0","agpl-3.0","bsd-2-clause","bsd-3-clause","bsl-1.0","cc0-1.0","epl-2.0","gpl-2.0","gpl-3.0","lgpl-2.1"],
18+
"make_github_repo_private": false,
19+
"license": ["apache-2.0", "mit", "agpl-3.0", "bsd-2-clause", "bsd-3-clause", "bsl-1.0", "cc0-1.0", "epl-2.0", "gpl-2.0", "gpl-3.0", "lgpl-2.1", "no-license"],
1920
"use_pydantic_settings": true,
2021
"log_to_file": true,
2122
"python_testing_matrix": [
@@ -48,10 +49,12 @@
4849
"python_version_dev": "Python version to use in development",
4950
"repository": "GitHub project URL",
5051
"readme_badges": "Include badges in project README.md",
51-
"create_github_repo": "Create GitHub repository and sync",
52+
"create_github_repo": "Create public GitHub repository and sync",
53+
"make_github_repo_private": "Make the GitHub repository private",
5254
"license": {
5355
"__prompt__":"Pick a license for this project",
5456
"apache-2.0": "Apache License 2.0",
57+
"mit": "MIT License",
5558
"agpl-3.0": "GNU Affero General Public License v3.0",
5659
"bsd-2-clause": "BSD 2-Clause 'Simplified' License",
5760
"bsd-3-clause": "BSD 3-Clause 'New' or 'Revised' License",
@@ -60,7 +63,8 @@
6063
"epl-2.0": "Eclipse Public License 2.0",
6164
"gpl-2.0": "GNU General Public License v2.0",
6265
"gpl-3.0": "GNU General Public License v3.0",
63-
"lgpl-2.1": "GNU Lesser General Public License v2.1"
66+
"lgpl-2.1": "GNU Lesser General Public License v2.1",
67+
"no-license": "No License"
6468
},
6569
"os_testing_matrix": {
6670
"__prompt__": "Pick Operating Systems for testing",

hooks/post_gen_project.uv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ def post_gen_project() -> int:
7474
False,
7575
sh.gh.repo.create.bake(
7676
"{{ cookiecutter.package_name }}",
77+
# {% if cookiecutter.make_github_repo_private %}
78+
"--private",
79+
# {% else %}
7780
"--public",
81+
# {% endif %}
7882
"--push",
7983
"--source=.",
8084
"--remote=upstream",

{{ cookiecutter.package_name }}/pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ name = "{{cookiecutter.package_name}}"
33
version = "{{cookiecutter.project_version}}"
44
description = "{{cookiecutter.project_short_description}}"
55
readme = "README.md"
6+
{% if cookiecutter.license != 'no-license' -%}
67
license = "{{ cookiecutter.license }}"
8+
{%- endif %}
79
authors = [{name = "{{ cookiecutter.github_username }}", email = "{{ cookiecutter.email }}"}]
810
repository = "{{ cookiecutter.repository }}"
911
requires-python = ">={{ cookiecutter.python_version_min }},<{{ cookiecutter.python_version_max }}"
@@ -136,7 +138,10 @@ tree.help = "List project files in tree format."
136138
[tool.ruff]
137139
fix = true
138140
lint.select = [ "I", "ALL" ]
139-
lint.ignore = [ "COM812", "D203", "D211", "D212", "D213", "FBT001", "FBT003", "D400", "BLE001", "S101" ]
141+
lint.ignore = [ "COM812", "D203", "D211", "D212", "D213", "FBT001", "FBT003", "D400", "BLE001" ]
142+
143+
[tool.ruff.lint.per-file-ignores]
144+
"tests/*" = ["S101", "S603"]
140145

141146
[tool.ty]
142147

0 commit comments

Comments
 (0)