Skip to content

Commit 9f5d407

Browse files
Added all open source licenses (Fixes cookiecutter#2941)
* Uses open source licenses (including the Jekyll format) from https://github.com/github/choosealicense.com/tree/gh-pages/_licenses * Added license section in README.rst because some licenses want it to be explicit * cookiecutter.json shows all licenses (including "Not open source") in lexicographical order except for "Not open source"
1 parent e0566e5 commit 9f5d407

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+9069
-27
lines changed

Diff for: cookiecutter.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@
66
"domain_name": "example.com",
77
"email": "{{ cookiecutter.author_name.lower()|replace(' ', '-') }}@example.com",
88
"version": "0.1.0",
9-
"open_source_license": [
10-
"MIT",
11-
"BSD",
12-
"GPLv3",
13-
"Apache Software License 2.0",
14-
"Not open source"
15-
],
9+
"open_source_license": ["Not open source", "\"Do What The F*ck You Want To Public License\"", "Academic Free License v3.0", "Apache License 2.0", "Artistic License 2.0", "BSD 2-Clause \"Simplified\" License", "BSD 3-Clause \"New\" or \"Revised\" License", "BSD 3-Clause Clear License", "BSD 4-Clause \"Original\" or \"Old\" License", "BSD Zero Clause License", "Boost Software License 1.0", "CeCILL Free Software License Agreement v2.1", "Creative Commons Attribution 4.0 International", "Creative Commons Attribution Share Alike 4.0 International", "Creative Commons Zero v1.0 Universal", "Eclipse Public License 1.0", "Eclipse Public License 2.0", "Educational Community License v2.0", "European Union Public License 1.1", "European Union Public License 1.2", "GNU Affero General Public License v3.0", "GNU General Public License v2.0", "GNU General Public License v3.0", "GNU Lesser General Public License v2.1", "GNU Lesser General Public License v3.0", "ISC License", "LaTeX Project Public License v1.3c", "MIT License", "Microsoft Public License", "Microsoft Reciprocal License", "Mozilla Public License 2.0", "ODC Open Database License v1.0", "Open Software License 3.0", "PostgreSQL License", "SIL Open Font License 1.1", "The Unlicense", "Universal Permissive License v1.0", "University of Illinois/NCSA Open Source License", "Vim License", "zlib License"],
1610
"timezone": "UTC",
1711
"windows": "n",
1812
"use_pycharm": "n",

Diff for: hooks/post_gen_project.py

+28-16
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@
3131
DEBUG_VALUE = "debug"
3232

3333

34-
def remove_open_source_files():
35-
file_names = ["CONTRIBUTORS.txt", "LICENSE"]
36-
for file_name in file_names:
37-
os.remove(file_name)
38-
39-
40-
def remove_gplv3_files():
41-
file_names = ["COPYING"]
42-
for file_name in file_names:
43-
os.remove(file_name)
44-
45-
4634
def remove_pycharm_files():
4735
idea_dir_path = ".idea"
4836
if os.path.exists(idea_dir_path):
@@ -324,6 +312,33 @@ def remove_storages_module():
324312
os.remove(os.path.join("{{cookiecutter.project_slug}}", "utils", "storages.py"))
325313

326314

315+
def handle_licenses():
316+
dir_path = os.path.join("{{cookiecutter.project_slug}}", "licenses")
317+
special_license_files = {
318+
"European Union Public License 1.1": "COPYING",
319+
"GNU General Public License v3.0": "COPYING",
320+
"GNU Lesser General Public License v3.0": "COPYING.LESSER",
321+
"The Unlicense": "UNLICENSE",
322+
}
323+
for filename in os.listdir(dir_path):
324+
# You'll always see: '---\n' marking beginning + end of Jekyll format
325+
with open(os.path.join(dir_path, filename)) as f:
326+
contents = f.readlines()
327+
title = contents[1].replace("title: ", "").replace("\n", "")
328+
if title != "{{ cookiecutter.open_source_license }}":
329+
continue
330+
new_file = os.path.join(
331+
"{{cookiecutter.project_slug}}", special_license_files.get(title, "LICENSE")
332+
)
333+
with open(new_file, "w") as f:
334+
# +2 to get rid of the --- and and an extra new line
335+
f.writelines(contents[contents.index("---\n", 1) + 2 :])
336+
break
337+
if "{{ cookiecutter.open_source_license }}" == "Not open source":
338+
os.remove("CONTRIBUTORS.txt")
339+
os.rmdir(dir_path)
340+
341+
327342
def main():
328343
debug = "{{ cookiecutter.debug }}".lower() == "y"
329344

@@ -334,10 +349,7 @@ def main():
334349
)
335350
set_flags_in_settings_files()
336351

337-
if "{{ cookiecutter.open_source_license }}" == "Not open source":
338-
remove_open_source_files()
339-
if "{{ cookiecutter.open_source_license}}" != "GPLv3":
340-
remove_gplv3_files()
352+
handle_licenses()
341353

342354
if "{{ cookiecutter.use_pycharm }}".lower() == "n":
343355
remove_pycharm_files()

Diff for: tests/test_cookiecutter_generation.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ def context():
2525
}
2626

2727

28+
def generate_license_file_titles():
29+
directory = os.path.join("{{cookiecutter.project_slug}}", "licenses")
30+
titles = []
31+
for file in os.listdir(directory):
32+
with open(os.path.join(directory, file)) as f:
33+
titles.append(f.readlines()[1].replace("title: ", "").replace("\n", ""))
34+
return titles
35+
36+
2837
SUPPORTED_COMBINATIONS = [
29-
{"open_source_license": "MIT"},
30-
{"open_source_license": "BSD"},
31-
{"open_source_license": "GPLv3"},
32-
{"open_source_license": "Apache Software License 2.0"},
38+
*[{"open_source_license": x} for x in generate_license_file_titles()],
3339
{"open_source_license": "Not open source"},
3440
{"windows": "y"},
3541
{"windows": "n"},

Diff for: {{cookiecutter.project_slug}}/README.rst

+7
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,10 @@ Bootstrap's javascript as well as its dependencies is concatenated into a single
171171
.. _Bootstrap docs: https://getbootstrap.com/docs/4.1/getting-started/theming/
172172

173173
{% endif %}
174+
175+
{% if cookiecutter.license != "Not open source" %}
176+
License
177+
^^^^^^
178+
179+
Licensed under the {{cookiecutter.open_source_license}}
180+
{% endif %}

Diff for: {{cookiecutter.project_slug}}/licenses/0bsd.txt

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: BSD Zero Clause License
3+
spdx-id: 0BSD
4+
5+
description: The BSD Zero Clause license goes further than the BSD 2-Clause license to allow you unlimited freedom with the software without requirements to include the copyright notice, license text, or disclaimer in either source or binary forms.
6+
7+
how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders. You may take the additional step of removing the copyright notice.
8+
9+
using:
10+
PickMeUp: https://github.com/nazar-pc/PickMeUp/blob/master/copying.md
11+
smoltcp: https://github.com/m-labs/smoltcp/blob/master/LICENSE-0BSD.txt
12+
Toybox: https://github.com/landley/toybox/blob/master/LICENSE
13+
14+
permissions:
15+
- commercial-use
16+
- distribution
17+
- modifications
18+
- private-use
19+
20+
conditions: []
21+
22+
limitations:
23+
- liability
24+
- warranty
25+
26+
---
27+
28+
Copyright (c) {% now 'utc', '%Y' %} {{ cookiecutter.author_name }}
29+
30+
Permission to use, copy, modify, and/or distribute this software for any
31+
purpose with or without fee is hereby granted.
32+
33+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
34+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
35+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
36+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
37+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
38+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39+
PERFORMANCE OF THIS SOFTWARE.

Diff for: {{cookiecutter.project_slug}}/licenses/afl-3.0.txt

+200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
---
2+
title: Academic Free License v3.0
3+
spdx-id: AFL-3.0
4+
5+
description: The Academic Free License is a variant of the Open Software License that does not require that the source code of derivative works be disclosed. It contains explicit copyright and patent grants and reserves trademark rights in the author.
6+
7+
how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Files licensed under AFL 3.0 must also include the notice "Licensed under the Academic Free License version 3.0" adjacent to the copyright notice.
8+
9+
using:
10+
11+
permissions:
12+
- commercial-use
13+
- modifications
14+
- distribution
15+
- private-use
16+
- patent-use
17+
18+
conditions:
19+
- include-copyright
20+
- document-changes
21+
22+
limitations:
23+
- trademark-use
24+
- liability
25+
- warranty
26+
27+
---
28+
29+
Academic Free License ("AFL") v. 3.0
30+
31+
This Academic Free License (the "License") applies to any original work of
32+
authorship (the "Original Work") whose owner (the "Licensor") has placed the
33+
following licensing notice adjacent to the copyright notice for the Original
34+
Work:
35+
36+
Licensed under the Academic Free License version 3.0
37+
38+
1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free,
39+
non-exclusive, sublicensable license, for the duration of the copyright, to do
40+
the following:
41+
42+
a) to reproduce the Original Work in copies, either alone or as part of a
43+
collective work;
44+
45+
b) to translate, adapt, alter, transform, modify, or arrange the Original
46+
Work, thereby creating derivative works ("Derivative Works") based upon
47+
the Original Work;
48+
49+
c) to distribute or communicate copies of the Original Work and
50+
Derivative Works to the public, under any license of your choice that
51+
does not contradict the terms and conditions, including Licensor's
52+
reserved rights and remedies, in this Academic Free License;
53+
54+
d) to perform the Original Work publicly; and
55+
56+
e) to display the Original Work publicly.
57+
58+
2) Grant of Patent License. Licensor grants You a worldwide, royalty-free,
59+
non-exclusive, sublicensable license, under patent claims owned or controlled
60+
by the Licensor that are embodied in the Original Work as furnished by the
61+
Licensor, for the duration of the patents, to make, use, sell, offer for sale,
62+
have made, and import the Original Work and Derivative Works.
63+
64+
3) Grant of Source Code License. The term "Source Code" means the preferred
65+
form of the Original Work for making modifications to it and all available
66+
documentation describing how to modify the Original Work. Licensor agrees to
67+
provide a machine-readable copy of the Source Code of the Original Work along
68+
with each copy of the Original Work that Licensor distributes. Licensor
69+
reserves the right to satisfy this obligation by placing a machine-readable
70+
copy of the Source Code in an information repository reasonably calculated to
71+
permit inexpensive and convenient access by You for as long as Licensor
72+
continues to distribute the Original Work.
73+
74+
4) Exclusions From License Grant. Neither the names of Licensor, nor the names
75+
of any contributors to the Original Work, nor any of their trademarks or
76+
service marks, may be used to endorse or promote products derived from this
77+
Original Work without express prior permission of the Licensor. Except as
78+
expressly stated herein, nothing in this License grants any license to
79+
Licensor's trademarks, copyrights, patents, trade secrets or any other
80+
intellectual property. No patent license is granted to make, use, sell, offer
81+
for sale, have made, or import embodiments of any patent claims other than the
82+
licensed claims defined in Section 2. No license is granted to the trademarks
83+
of Licensor even if such marks are included in the Original Work. Nothing in
84+
this License shall be interpreted to prohibit Licensor from licensing under
85+
terms different from this License any Original Work that Licensor otherwise
86+
would have a right to license.
87+
88+
5) External Deployment. The term "External Deployment" means the use,
89+
distribution, or communication of the Original Work or Derivative Works in any
90+
way such that the Original Work or Derivative Works may be used by anyone
91+
other than You, whether those works are distributed or communicated to those
92+
persons or made available as an application intended for use over a network.
93+
As an express condition for the grants of license hereunder, You must treat
94+
any External Deployment by You of the Original Work or a Derivative Work as a
95+
distribution under section 1(c).
96+
97+
6) Attribution Rights. You must retain, in the Source Code of any Derivative
98+
Works that You create, all copyright, patent, or trademark notices from the
99+
Source Code of the Original Work, as well as any notices of licensing and any
100+
descriptive text identified therein as an "Attribution Notice." You must cause
101+
the Source Code for any Derivative Works that You create to carry a prominent
102+
Attribution Notice reasonably calculated to inform recipients that You have
103+
modified the Original Work.
104+
105+
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that
106+
the copyright in and to the Original Work and the patent rights granted herein
107+
by Licensor are owned by the Licensor or are sublicensed to You under the
108+
terms of this License with the permission of the contributor(s) of those
109+
copyrights and patent rights. Except as expressly stated in the immediately
110+
preceding sentence, the Original Work is provided under this License on an "AS
111+
IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without
112+
limitation, the warranties of non-infringement, merchantability or fitness for
113+
a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK
114+
IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this
115+
License. No license to the Original Work is granted by this License except
116+
under this disclaimer.
117+
118+
8) Limitation of Liability. Under no circumstances and under no legal theory,
119+
whether in tort (including negligence), contract, or otherwise, shall the
120+
Licensor be liable to anyone for any indirect, special, incidental, or
121+
consequential damages of any character arising as a result of this License or
122+
the use of the Original Work including, without limitation, damages for loss
123+
of goodwill, work stoppage, computer failure or malfunction, or any and all
124+
other commercial damages or losses. This limitation of liability shall not
125+
apply to the extent applicable law prohibits such limitation.
126+
127+
9) Acceptance and Termination. If, at any time, You expressly assented to this
128+
License, that assent indicates your clear and irrevocable acceptance of this
129+
License and all of its terms and conditions. If You distribute or communicate
130+
copies of the Original Work or a Derivative Work, You must make a reasonable
131+
effort under the circumstances to obtain the express assent of recipients to
132+
the terms of this License. This License conditions your rights to undertake
133+
the activities listed in Section 1, including your right to create Derivative
134+
Works based upon the Original Work, and doing so without honoring these terms
135+
and conditions is prohibited by copyright law and international treaty.
136+
Nothing in this License is intended to affect copyright exceptions and
137+
limitations (including "fair use" or "fair dealing"). This License shall
138+
terminate immediately and You may no longer exercise any of the rights granted
139+
to You by this License upon your failure to honor the conditions in Section
140+
1(c).
141+
142+
10) Termination for Patent Action. This License shall terminate automatically
143+
and You may no longer exercise any of the rights granted to You by this
144+
License as of the date You commence an action, including a cross-claim or
145+
counterclaim, against Licensor or any licensee alleging that the Original Work
146+
infringes a patent. This termination provision shall not apply for an action
147+
alleging patent infringement by combinations of the Original Work with other
148+
software or hardware.
149+
150+
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this
151+
License may be brought only in the courts of a jurisdiction wherein the
152+
Licensor resides or in which Licensor conducts its primary business, and under
153+
the laws of that jurisdiction excluding its conflict-of-law provisions. The
154+
application of the United Nations Convention on Contracts for the
155+
International Sale of Goods is expressly excluded. Any use of the Original
156+
Work outside the scope of this License or after its termination shall be
157+
subject to the requirements and penalties of copyright or patent law in the
158+
appropriate jurisdiction. This section shall survive the termination of this
159+
License.
160+
161+
12) Attorneys' Fees. In any action to enforce the terms of this License or
162+
seeking damages relating thereto, the prevailing party shall be entitled to
163+
recover its costs and expenses, including, without limitation, reasonable
164+
attorneys' fees and costs incurred in connection with such action, including
165+
any appeal of such action. This section shall survive the termination of this
166+
License.
167+
168+
13) Miscellaneous. If any provision of this License is held to be
169+
unenforceable, such provision shall be reformed only to the extent necessary
170+
to make it enforceable.
171+
172+
14) Definition of "You" in This License. "You" throughout this License,
173+
whether in upper or lower case, means an individual or a legal entity
174+
exercising rights under, and complying with all of the terms of, this License.
175+
For legal entities, "You" includes any entity that controls, is controlled by,
176+
or is under common control with you. For purposes of this definition,
177+
"control" means (i) the power, direct or indirect, to cause the direction or
178+
management of such entity, whether by contract or otherwise, or (ii) ownership
179+
of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
180+
ownership of such entity.
181+
182+
15) Right to Use. You may use the Original Work in all ways not otherwise
183+
restricted or conditioned by this License or by law, and Licensor promises not
184+
to interfere with or be responsible for such uses by You.
185+
186+
16) Modification of This License. This License is Copyright © 2005 Lawrence
187+
Rosen. Permission is granted to copy, distribute, or communicate this License
188+
without modification. Nothing in this License permits You to modify this
189+
License as applied to the Original Work or to Derivative Works. However, You
190+
may modify the text of this License and copy, distribute or communicate your
191+
modified version (the "Modified License") and apply it to other original works
192+
of authorship subject to the following conditions: (i) You may not indicate in
193+
any way that your Modified License is the "Academic Free License" or "AFL" and
194+
you may not use those names in the name of your Modified License; (ii) You
195+
must replace the notice specified in the first paragraph above with the notice
196+
"Licensed under <insert your license name here>" or with a notice of your own
197+
that is not confusingly similar to the notice in this License; and (iii) You
198+
may not claim that your original works are open source software unless your
199+
Modified License has been approved by Open Source Initiative (OSI) and You
200+
comply with its license review and certification process.

0 commit comments

Comments
 (0)