I have recently released some projects on GitHub and its catching people's attention(I had released earlier too but they were just for learning and didn't carry much weight).

But I think I made a big mistake. I was of the impression that just including the raw copy of LICENSE template that GitHub provides would be enough(?).
But somebody told me that my source files were unlicensed. This was strange to know. So I started reading up and I think I may have to include the License on top of all of my source code.
But that just seems like such a waste. I mean the GNU GPLv3 license is 100s of lines long.

My project is Python based. It has the usual source files(scripts and __init__.py), setup.py, MANIFEST.in, LICENSE, README.md, TODO.md, CONTRIBUTION.md.
In what files do I include the licence?
Do I have to include the whole of the LICENSE or only a part of it?
If possible could you please demonstrate it with an example perhaps specific to GNU GPLv3?

  • "somebody told me that my source files were unlicensed." - Did this person see your LICENSE notice? – Brandin Dec 5 at 12:53
  • @Brandin I don't know. And honestly I had just added GitHub's template blindly. I didn't even bother to go to the end and add my name, and other copyright details. So I guess its all my fault. – jar Dec 5 at 12:56
up vote 6 down vote accepted

No example is required, as the GPL itself tells you how to do it, down at the bottom in the section entitled "How to Apply These Terms to Your New Programs".

In short, they recommend you include your copyright notice and three short paragraphs at the beginning of each source file, and a copy of the entire GPL somewhere in the source tree.

  • Thanks for the info. The thing that is troubling me is do I have to include those paragraphs at the beginning of every file in the project even though it may contain only a single line of code for example files like MANIFEST.in, init.py ? Now MANIFEST.in isn't exactly a source file, but init.py definitely goes under source folder but then usually contains nothing thats why I am having this doubt. – jar Dec 5 at 12:26
  • 1
    Anything too small or simple to copyright, you certainly needn't bother. Remember also that the GPL's advice is just advice. As long as you have a copyright notice, and the first of the three paragraphs saying what the licence is, then you've left people in no doubt. – MadHatter Dec 5 at 12:45
  • One last thing, when you say "first of the three paragraphs" you mean <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> or 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 the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ? – jar Dec 5 at 12:48
  • @raj Read How To Apply These Terms to Your Program and read where it says "attach the following notices to the program." All of the following paragraphs are what they recommend you attach. I.e. the copyright notice and a brief notice of the GPL license. If you are licenseing it only under a particular GPL version (e.g. version 2 or version 3 only), then you should also omit the "at your option any later version" bit. – Brandin Dec 5 at 13:08
  • 3
    @raj See above the comment "this advice is just advice". There is no hard and fast rule about how you should notify people. For example you could decide to place only a single notice somewhere "It's all GPL folks", but some people may not notice it or may read it and wonder if they really understood it properly. If you put it in your README and clearly state the license, that's fine, but suppose someone copies one of your source files and forgets to copy the README? Then anyone else who sees your source file won't know that it's GPLed. That's why they recommend adding something to every file. – Brandin Dec 5 at 13:36

From a legal perspective:

You should attach licensing information to a file in such a way that you cannot successfully deny that you intended to license the file under those terms. Suppose, at some point in the future, you attempt to claim in a court of law that you did not license some particular file under a particular license. The valid methods of attaching licensing information to a file include the set of all methods that would render such a future denial untenable in court, based on the decision of a judge or jury. This is ultimately a subjective determination, but it's the only determination that matters, legally speaking.

From a community perspective:

You should aim for clarity, and try to maximize survival of licensing information through multiple generations of reuse. For this reason, the FSF recommends including licensing information on a per-file basis. If a file is transplanted from your project into another project, you want licensing information to travel with it easily. A notice within the file is the most surefire way to reduce accidental confusion of licensing terms. Per-file notices also help when a project uses different licenses for different files, making it immediately obvious how any particular file is licensed.

Another GPL FAQ item talks about what is legally optimal versus legally necessary:

Is it enough just to put a copy of the GNU GPL in my repository?

Just putting a copy of the GNU GPL in a file in your repository does not explicitly state that the code in the same repository may be used under the GNU GPL. Without such a statement, it's not entirely clear that the permissions in the license really apply to any particular source file. An explicit statement saying that eliminates all doubt.

A file containing just a license, without a statement that certain other files are covered by that license, resembles a file containing just a subroutine which is never called from anywhere else. The resemblance is not perfect: lawyers and courts might apply common sense and conclude that you must have put the copy of the GNU GPL there because you wanted to license the code that way. Or they might not. Why leave an uncertainty?

This statement should be in each source file. A clear statement in the program's README file is legally sufficient as long as that accompanies the code, but it is easy for them to get separated. Why take a risk of uncertainty about your code's license?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.