Licenses
-
I've been thinking about licensing my code. Which licenses do you guys usually use on your code, and why?
-
I normally use the MIT license (aka the X.Org license if you're the FSF) which basically says "you can do whatever you want as long as you retain this license text". This is of course a very liberal license, especially regarding commercial usage, though I'm not very concerned about that (not as if anyone would want to use my code commercially in the first place) since the license text containing my copyright line must be kept no matter what.
If you do not want your code to be used commercially in any way, ever, then use the GPL, but sometimes that can be a real shame. Imagine if you wrote some awesome Python library that omz would like to ship with Pythonista, but he couldn't because the GPL prohibits that. In a more realistic case, it also means that if you want to use any GPL code in your project (include and redistribute as part of your source code -
import
ing a non-bundled GPL library is fine), it must also be licensed under the GPL (or possibly another license that is "similar enough") which isn't always what you want.(Usual disclaimer - I'm no lawyer or expert on the subject. If you find anything incorrect in my post, please say so.)
-
@dgelessus Sounds good. I had read something about GPL requiring you to use GPL if you include GPL-licensed code, but wondered if that included imports of code I don't include. Thanks for clearing that up, MIT sounds good.
-
Exactly, the license only applies if you redistribute the code. If you import a module but do not bundle it with your project, then it's up to the user to obtain the module and deal with whatever license it may be under. (In the case of open-source software the end user almost never needs to worry about what the license says. With closed-source and/or commercial software that is a different story.)
This kind of "let the user install the extra software so we don't need to worry about licensing" is a valid strategy. For example Python has support for the GNU readline library, but cannot include it because of the GPL. But if you have readline installed properly, Python will happily use it to give you input history features and such in the interactive prompt.
Oracle does something similar for VirtualBox - there is the main VirtualBox package, and there's an official "extension pack" with some extra features. There is no reason to not have the extension pack installed, the only reason they are separate (as far as I can tell) is because the code is under different, incompatible licenses.
-
@dgelessus One more question, if I go back and add a license to my GitHub repos that didn't have one previously, is only the new code affected? Or are the earlier versions that were committed without a license also covered by the license added later?
-
I use Apache v2.0 instead of MIT because Apache provides an express grant of patent rights from contributors to users. See the front page of http://choosealicense.com