diff --git a/cookiecutter.json b/cookiecutter.json index d91d4b7..d064492 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -4,12 +4,14 @@ "project_description": "", "author": "Jane Doe", "author_email": "jane_doe@imperial.ac.uk", + "use_bsd3_licence": false, "_copy_without_render": [".github"], "__prompts__": { "project_name": "Enter a human-readable name for the project", "project_slug": "Enter a name for the Python package", "project_description": "Enter a brief description of the project", "author": "Enter your full name", - "author_email": "Enter your email address" + "author_email": "Enter your email address", + "use_bsd3_licence": "Whether to use Imperial's default open-source licence (BSD 3-clause)" } } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py new file mode 100644 index 0000000..08b16f5 --- /dev/null +++ b/hooks/post_gen_project.py @@ -0,0 +1,10 @@ +import os + +REMOVE_PATHS = [ + "{% if not cookiecutter.use_bsd3_licence %}LICENSE{% endif %}" +] + +for path in REMOVE_PATHS: + path = path.strip() + if path and os.path.exists(path): + os.unlink(path) if os.path.isfile(path) else os.rmdir(path) diff --git a/{{ cookiecutter.project_slug }}/LICENSE b/{{ cookiecutter.project_slug }}/LICENSE new file mode 100644 index 0000000..0dd76a6 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2024, Alex Dewar + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, 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.