Next: Perl模块, Previous: Emacs Packages, Up: 打包指导 [Contents][Index]
我们目前为Python 2和Python 3打包,如版本号的规则所述,它们的Scheme变量名分别是python-2
和python
。为了避免和其他编程语言的冲突,Python模块的软件包名字最好含有python
。
Some modules are compatible with only one version of Python, others with
both. If the package Foo is compiled with Python 3, we name it
python-foo
. If it is compiled with Python 2, we name it
python2-foo
. Packages should be added when they are necessary; we
don’t add Python 2 variants of the package unless we are going to use them.
如果一个项目的名字已经含有python
这个单词,我们把它丢掉;例如,python-dateutil模块打包后的名字是python-dateutil
和python2-dateutil
。如果项目的名字以py
开头(如
pytz
),我们把它保留,并且添加上面所述的前缀。
注: Currently there are two different build systems for Python packages in Guix: python-build-system and pyproject-build-system. For the longest time, Python packages were built from an informally specified setup.py file. That worked amazingly well, considering Python’s success, but was difficult to build tooling around. As a result, a host of alternative build systems emerged and the community eventually settled on a formal standard for specifying build requirements. pyproject-build-system is Guix’s implementation of this standard. It is considered “experimental” in that it does not yet support all the various PEP-517 build backends, but you are encouraged to try it for new Python packages and report any problems. It will eventually be deprecated and merged into python-build-system.
Dependency information for Python packages is usually available in the package source tree, with varying degrees of accuracy: in the pyproject.toml file, the setup.py file, in requirements.txt, or in tox.ini (the latter mostly for test dependencies).
你在写软件包配方时的任务是把这些依赖转换成相应的“输入”(see inputs)。尽管pypi
导入工具通常可以做得很好(see Invoking guix import
),你可能想检查下面这个清单,以决定每个依赖放在哪儿。
setuptools
and pip
installed
per default. This is about to change, and users are encouraged to use
python-toolchain
if they want a build environment for Python.
guix lint
will warn if setuptools
or pip
are added
as native-inputs because they are generally not necessary.
propagated-inputs
。它们通常由setup.py文件里的install_requires
关键字或requirements.txt文件定义。
build-system.requires
in pyproject.toml or with the
setup_requires
keyword in setup.py—or dependencies only for
testing—e.g., those in tests_require
or tox.ini—go into
native-inputs
. The rationale is that (1) they do not need to be
propagated because they are not needed at run time, and (2) in a
cross-compilation context, it’s the “native” input that we’d want.
例如pytest
,mock
,nose
测试框架。当然,如果在运行时需要这里的任何一个包,它需要被加进propagated-inputs
。
inputs
,如,构建含有C语言扩展的Python包所需的程序和C语言库。
extras_require
),由你根据它们的性价比(用处/负担)决定是否添加它们(see guix size
)。
Next: Perl模块, Previous: Emacs Packages, Up: 打包指导 [Contents][Index]