二月#

setup.py, setup.cfg 和 pyproject.toml#

URL:

Understanding setup.py, setup.cfg and pyproject.toml in Python

历史包袱:

The subject of Python packaging, installation and publication is a bit complicated for mainly historic reasons – the original distutils module was created over 20 years ago.

An example python project: ⛺ IanHopkinson/mypackage, another one: ⛺ pyscaffold/pyscaffold-demo (from pyscaffold).

  • setup.py: required by 📦 setuptool, to help with the packaging process

  • setup.cfg: let us not need to be executed (setup.py) to be read packaging configuration

  • pyproject.toml: intorduced in PEP 518, provides a way of separating configuration of the build system from a specific, optional library (setuptools) and also enabling setuptools to install itself without already being installed (bootstrap)

  • src/: a fxied source directory ensures that you must install a package to test it, so as your users would do. Also it prevents tools like pytest incidently importing it.

评论

如果你有任何意见,请在此评论。 如果你留下了电子邮箱,我可能会通过 回复你。