How do I properly adhere to licenses when copying code from CPython?

I’ve read here that contributions get relicensed under the PSF license rather than the initial license. Therefore, do I only need to worry about the PSF license, or are there any narrower licenses I need to also follow? For example, the unittest module has this copyright notice. Does “so long as this copyright message and disclaimer are retained in their original form” imply that the message and disclaimer need to be copied over to partial derivative works too (e.g. copying a couple functions)?

This is a @VanL question.

IANAL, but in general the PSF license applies to everything. But as you noticed, select files seem to have targeted licensing. Everything is as permissible as the PSF license (i.e. not copyleft), but if you want to be safe I would just copy the extra license details over with whatever code you’re grabbing.

Hi Mark,

much of the CPython code, but not all, has been contributed under
a contribution agreement:


The original authors retain the copyright in the code, but give
the PSF the permission to relicense the code under an open source
license.

As long as you retain the copyright notices, you can use the CPython
source code subject to the PSF license.

Note that if you make changes or extract code, you have to include
a brief summary of your changes in your distribution.

For the specific example, it is not clear whether such an agreement
was signed (the important line “Licensed to PSF under a Contributor
Agreement.” is missing), so you will probably need to assume that
both the PSF and Steve Purcell’s license apply to stay on the safe
side.

Cheers,

Thanks for the answers. I’ll have to keep an eye out for these other license then.

As long as you retain the copyright notices, you can use the CPython source code subject to the PSF license.

Do I also have to retain copyright notices from contributors that clearly signed the agreement?

Under the PSF, what are generally the exact copyright notices I need to retain? Is it what’s in the license, “Copyright © 2001-2020 Python Software Foundation; All Rights Reserved”, all of what’s here, or something else?

[mark] Mark https://discuss.python.org/u/mark
September 24

Thanks for the answers. I’ll have to keep an eye out for these other license then.

As long as you retain the copyright notices, you can use the CPython source
code subject to the PSF license.

Do I also have to retain copyright notices from contributors that clearly signed
the agreement?

Yes, because the licenses with which the contributor licensed the code
to the PSF (AFL or Apache) have this as a precondition, just like the
PSF license does.

Under the PSF, what are generally the exact copyright notices I need to retain?
Is it what’s in the license, “Copyright © 2001-2020 Python Software Foundation;
All Rights Reserved”, all of what’s here
https://docs.python.org/3/copyright.html?highlight=copyright, or something else?

In general: all that’s applicable.

The page lists the Python license
stack, which applies to all CPython code written by the contributors,
and it includes separate licenses for code which was incorporated into
the CPython code from other sources (those are not covered by the contrib
agreements and thus cannot be relicensed). Not all of the latter will
apply in your case.

Note that the section on incorporated code is not necessarily
complete. As is custom, we always leave the copyright notices
of incorporated code with the code, so it is possible to determine
the source and the license on that code. The unittest files you
want to use are an example of 3rd party licenses missing from the
section.

I think by now, you probably understand the mess CPython is when it
comes to licenses :slight_smile: It’s a fairly old project and has a very long
history of contributors, with the contributor agreements only
starting to have a simplifying effect early in the 2000s.

In your case, you should copy the Python LICENSE file
(cpython/LICENSE at main · python/cpython · GitHub) to e.g. LICENSE.Python,
leave the unittext copyright notice in the code and add an explanation
of where the code you extracted originates to your README or LICENSE file.

Cheers,

Yeah, licensing can be confusing and a mess sometimes. Thanks for walking me through it.