Suppose there is a Python library called
g which is licensed under GPL v2.0 (or v3.0). Suppose further that the library is sufficiently complex that it contains some C/C++ component(s) that are similarly licensed under GPL v2.0.
Now, I'd like to write a program that uses this library:
import g g.foo()
import statement here links to the library
g, both by loading and compiling
g's Python source code, and by dynamically linking to the
g's .dll/.so component. According to GPL FAQ, my program has to be licensed under the terms of GPL 2.0 whenever it is propagated:
If a library is released under the GPL (not the LGPL), does that mean that any software which uses it has to be under the GPL or a GPL-compatible license?
Yes, because the program actually links to the library. As such, the terms of the GPL apply to the entire combination. The software modules that link with the library may be under various GPL compatible licenses, but the work as a whole must be licensed under the GPL.
Obviously, publishing a program on Stack Exchange is a form of propagation under GPL's terms, so the question is: can I post this code snippet on SE as a question or answer? After all, the SE Terms of Service require that I provided that code snippet under CC BY-SA license, which is not compatible with GPL:
CC BY-SA 4.0 is one-way compatible with the GNU GPL version 3: this means you may license your modified versions of CC BY-SA 4.0 materials under GNU GPL version 3, but you may not relicense GPL 3 licensed works under CC BY-SA 4.0.