fatiando / maintenance

NOTICE: This repository is archived. Content and functionality has been moved to https://github.com/fatiando/community
Creative Commons Attribution 4.0 International
1 stars 0 forks source link

Add license and copyright notice to all source files #10

Closed leouieda closed 3 years ago

leouieda commented 4 years ago

Description

We need to add a copyright notice and license information (name and terms) to every .py file. This can be found in the LICENSE files of each repository. The notice should be put in a comment at the top of the files:

# Copyright (c) YEAR The PROJECT Developers.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
#
# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
#

This is how MetPy does it.

I never thought that this was a big deal but I have since changed my mind. A couple of months ago I came across this repository: https://github.com/igp-gravity/geoist. Shockingly, it includes most files from fatiando/fatiando and fatiando/verde without any mention or attribution. Some files even go so far as to claim authorship for the code (for example, the old code for coordinate generation). I have opened igp-gravity/geoist#7 to raise the issue of violation of our license terms and got a reply but so far nothing has happened. I don't particularly mind them reusing the fatiando/fatiando code since we're not updating it anymore but I was really bothered by the lack of attribution and copying Verde.

The package seems to include a whole bunch of code from other people just blatantly copied, some with the copyright and attribution intact (at least they didn't remove existing notices). This is what prompted this maintenance task. If we had the notice on our files, some of the bad feelings this generated might have been avoided. Though copying code instead of linking (importing) from active projects like Verde is generally frowned upon, it's prohibited by open-source licenses.

Apply changes to

Libraries:

Other repositories:

Further instructions

In order to solve this issue we need to start opening Pull Requests on each repository listed above. Optionally, we can open Issues on each repository if further discussion specific to that repository is needed.

Remember to mention this Issue on every Issue or Pull Request opened on each repository for keeping a record by adding something like:

Related to fatiando/maintenance#XX

A quick checklist:

  1. Open an Issue on each repository listed above (optional). Mention this Issue on them.
  2. Open a Pull Request on the same repository to tackle the Issue. Mention this Issue on them.
  3. Check-off the repository on the list above once the Pull Request is merged.
  4. Close this issue when all items are checked-off.

We want your help

We know that maintenance tasks are very demanding, so we don't expect a single person to tackle this issue by themselves. Any help is very welcomed, so please comment below that you want to take care of the changes on any repository and we will assign it to you.

santisoler commented 4 years ago

We can always automate the process with bash.

  1. cd into the cloned repository
  2. Create a notice file containing the copyright notice:
    # Copyright (c) YEAR The PROJECT Developers.
    # Distributed under the terms of the BSD 3-Clause License.
    # SPDX-License-Identifier: BSD-3-Clause
  3. Run the following bash commands:
    for i in $(find . -name "*.py" | grep -v "./doc/"); do cat notice $i > temp && mv temp $i; done
  4. Remove the notice file and you are ready to push all the changes.
leouieda commented 4 years ago

Or with Python 😉 :

from pathlib import Path

notice = """
# Copyright (c) YEAR The PROJECT Developers.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
""".strip()

python_files = [
    path for path in Path(".").glob("**/*.py") if not str(path).startswith(".")
]
print("Adding notice to:")
for pyfile in python_files:
    print(f"  {pyfile}")
    code = pyfile.read_text()
    pyfile.write_text("\n".join([notice, code]))
leouieda commented 4 years ago

Actually, here is a better version that doesn't write the message twice by mistake:

from pathlib import Path

notice = """
# Copyright (c) YEAR The PROJECT Developers.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
""".strip()

python_files = [
    path for path in Path(".").glob("**/*.py") if not str(path).startswith(".")
]
print("Added notice to:")
for pyfile in python_files:
    code = pyfile.read_text()
    if not code.startswith(notice):
        pyfile.write_text("\n".join([notice, code]))
        print(f"  {pyfile}")

cc @santisoler

leouieda commented 4 years ago

How about adding # This code is part of the Fatiando a Terra project (https://www.fatiando.org) to the end of the notice?

santisoler commented 4 years ago

Sure! So the script should look like this then:

from pathlib import Path

notice = """
# Copyright (c) YEAR The PROJECT Developers.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
#
# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
#
""".strip()

python_files = [
    path for path in Path(".").glob("**/*.py") if not str(path).startswith(".")
]
print("Added notice to:")
for pyfile in python_files:
    code = pyfile.read_text()
    if not code.startswith(notice):
        pyfile.write_text("\n".join([notice, code]))
        print(f"  {pyfile}")
prisae commented 4 years ago

Citing here for context also https://www.gnu.org/licenses/gpl-faq.en.html#NoticeInSourceFile

Why should I put a license notice in each source file? (#NoticeInSourceFile)

You should put a notice at the start of each source file, stating what license it carries, in order to avoid risk of the code's getting disconnected from its license. If your repository's README says that source file is under the GNU GPL, what happens if someone copies that file to another program? That other context may not show what the file's license is. It may appear to have some other license, or no license at all (which would make the code nonfree).

Adding a copyright notice and a license notice at the start of each source file is easy and makes such confusion unlikely.

This has nothing to do with the specifics of the GNU GPL. It is true for any free license.

This :arrow_up: was the reason why I included it in every file of empymod and emg3d.

leouieda commented 3 years ago

Pretty much done. Again, rockhound needs a rewrite so we'll sort this as part of that.