Python のコードを取り込むときの注意点 (Python のライセンスについて)

hg-diff-highlight を実装するにあたって、difflib.Differ クラスの実装を一部コピーしました。

Python のライブラリをコピーして自分のプロダクトに取り込むので、
どのように扱えばいいのかライセンス上問題ないか聞いて & 調べてみました。

PythonPSF LICENSE AGREEMENT という独自のライセンスを採用しています。
このライセンスは

  • BSD 系っぽい気がする。ゆるい。
  • 制限少なめ。自由多め。

という印象を受けます。

GPL のように派生物のライセンスに関する規定は特にないようなので、自分の好きなライセンスにしてもよいようです。
ノートにははっきりと、GPL とは違うよ、あなたの変更をオープンソースに(GPLに)する必要はないよ、という説明があります。

Note GPL-compatible doesn’t mean that we’re distributing Python under the GPL. All Python licenses, unlike the GPL, let you distribute a modified version without making your changes open source. The GPL-compatible licenses make it possible to combine Python with other software that is released under the GPL; the others don’t.

また、Copyright 表記については第二項にちょっとした記述があります。
PSF License Agreement と copyright を派生物にも残しておくように、という風に書いてあるようです。

... however, that PSF’s License Agreement and PSF’s notice of copyright, i.e., “Copyright © 2001-2013 Python Software Foundation; All Rights Reserved” are retained in Python 2.7.6 alone or in any derivative version prepared by Licensee.

それと、第三項にはこんな記述があります。

then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python 2.7.6.

変更点を書いておいてね、ということですね。

まとめ

僕が python から difflib の一部を取り込むときにあたっては、以下の点に注意しました。

  • difflib 由来のコードは別のファイルに分割した
  • そのファイルには PSF License Agreement を記載した
  • そのファイルには copyright 表記を残しておいた
    • ついでに自分の copyright を加筆しておいた

解釈が間違っているようであれば指摘してもらえると助かります。

おまけ

上で紹介したのは python の大部分に対するライセンスですが、コードによっては別の条項が適用されるケースが有ります。
どのモジュールなのかは Licenses and Acknowledgements for Incorporated Software のセクションを読んでみてください。