Python モジュールの配布¶
人気のあるオープンソース開発プロジェクトがそうであるように、Python には貢献者たちとユーザたちの活発なサポートコミュニティがあり、またこれらはほかの Python 開発者たちに、彼らのソフトウェアのオープンソースライセンスのもとでの利用も可能にしてくれています。
これはほかの人が既に挙げた共通の(あるいは時折極めて稀有な!)問題や、彼ら自身の解法による潜在的な貢献が共通の場所に蓄えられることによる恩恵によって、Python ユーザに共有と協調を効果的に行なうことの助けとなっています。
このガイドはこれらプロセスのうち、配布についてをカバーします。ほかの Python プロジェクトをインストールするためのガイドについては installation guide を参照してください。
注釈
あなたが企業や組織のユーザであれば、多くの組織がオープンソースソフトウェアの利用と貢献に関する彼ら独自のポリシーを持っていることに気をつけてください。Python によって提供される配布とインストールのツールを利用する際には、そのようなポリシーを考慮に入れてください。
重要用語集¶
the Python Package Index is a public repository of open source licensed packages made available for use by other Python users
the Python Packaging Authority are the group of developers and documentation authors responsible for the maintenance and evolution of the standard packaging tools and the associated metadata and file format standards. They maintain a variety of tools, documentation and issue trackers on both GitHub and Bitbucket.
distutils
is the original build and distribution system first added to the Python standard library in 1998. While direct use ofdistutils
is being phased out, it still laid the foundation for the current packaging and distribution infrastructure, and it not only remains part of the standard library, but its name lives on in other ways (such as the name of the mailing list used to coordinate Python packaging standards development).setuptools is a (largely) drop-in replacement for
distutils
first published in 2004. Its most notable addition over the unmodifieddistutils
tools was the ability to declare dependencies on other packages. It is currently recommended as a more regularly updated alternative todistutils
that offers consistent support for more recent packaging standards across a wide range of Python versions.wheel (in this context) is a project that adds the
bdist_wheel
command todistutils
/setuptools. This produces a cross platform binary packaging format (called "wheels" or "wheel files" and defined in PEP 427) that allows Python libraries, even those including binary extensions, to be installed on a system without needing to be built locally.
オープンソースライセンス化とコラボレーション¶
世界のほとんどの国では、ソフトウェアは自動的に著作権保護の対象となります。これが意味するのは、ほかの開発者はそのソフトウェアに関する複製、使用、修正と配布に対して、明示的な許諾を必要とする、ということです。
オープンソースライセンス化は、比較的矛盾のなく明示的にそのような権限を許可する方法です。さまざまな問題に対する共通の解法をいつでも利用可能にすることで、開発者に共有と協調を効率的に行うことを可能にしています。これは多くの開発者に、彼ら固有の状況での比較的特異な問題により多くの時間をかけて集中することを可能にしてくれています。
Python によって提供される配布ツールは、開発者にとってそれなりに単純で理解しやすいようにデザインされているため、開発者がそう望む場合、自身の貢献をソフトウェアのその共通の蓄積場所に還元できます。
それがオープンソースとして公開されているかどうかによらず、同じ配布ツールを組織内のソフトウェア配布に使うことも出来ます。
ツールのインストール¶
コア開発チームは、古いバージョンの Python に対してでさえも一貫して動作する標準ツールを持つことが重要だということを理解したため、標準ライブラリには、モダンな Python パッケージング標準をサポートするビルドツールは含まれていません。
現在のところのビルド・配布の推奨ツールは pip
モジュールをコマンドラインから呼び出すことでインストール出来ます:
python -m pip install setuptools wheel twine
注釈
For POSIX users (including macOS and Linux users), these instructions assume the use of a virtual environment.
Windows ユーザ向けには、このガイド内の指示は、Python インストール時にシステムの PATH 環境変数が調整されていることを前提にしています。
Python Packaging User Guide にはさらに詳しい情報 currently recommended tools があります。
Python Packaging User Guide を読む¶
Python Packaging User Guide は、プロジェクトの作成と配布に関わる様々な鍵となるステップと要素をカバーしています。
どうすればいいの...?¶
以下はよくある課題への簡単な回答もしくは回答へのリンクです。
... 私のプロジェクトの名前はどう選べばいいですか?¶
簡単なトピックではありませんが、いくつか助言をしておきます:
check the Python Package Index to see if the name is already in use
GitHub, Bitbucket などのような人気のあるホスティングサイトにその名前が既にいないかチェックする
検討している名前の WEB 検索の結果をチェックする
とりわけ一般的な語、特に多くの意味を持ち、ユーザにあなたのソフトウェアを検索するのを難しくさせるような語を避ける
... バイナリの拡張を作って配布したいのですが?¶
これは大変複雑なトピックで、あなたが何を達成したいのかに完全に依存する、数多くの選択肢があります。Python Packaging User Guide にはもっと詳しい情報と提案がありますので、ご参照ください。