I am writing a document in LaTeX that contains large sections of Python code and output. Typically, I like to license my writing under CC BY-SA 4.0 and my code under GPLv3. I have already placed a CC BY-SA 4.0 notice at the end of my (as of yet unpublished) document, but this notice was generated using a LaTeX package and therefore does not appear verbatim in the LaTeX source. The source file for the document will be hosted on GitHub.

Is it a good idea to GPL my Python code while using CC BY-SA for the rest of the content? Or would it be better (i.e. less of a headache for others) to use CC BY-SA for the entire work? Also, how do I address licensing both in the output PDF and the source?

  • Just stick to the one license. Despite CC saying not to use their licenses for code, there's no real reason not to, if you're happy with the terms. – curiousdannii Oct 29 at 0:41
up vote 5 down vote accepted

Stick with CC-BY-SA 4 and get the best of both worlds. CC-BY-SA 4.0 s3b requires that:

In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.

The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.

The CC's list of compatible licences says that one such licence is GPLv3.

So as long as some potential user wishes to treat your work as a whole (eg to produce a more up-to-date edition, correct errata, or translate it) they can continue with the simplicity of a single, free licence on the source and PDF. If someone wants to take only the Python code from your work and use it as code rather than as part of a literary work, and if this would be easier for them under GPL, then they can simply opt to take the code under GPLv3.

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.