For the complete documentation index, see llms.txt. This page is also available as Markdown.

7.4.USES=python 和 Flavors

当使用 python 并设置了 USE_PYTHON=distutils 时,Port 会自动填充 FLAVORS,其中包含它所支持的 Python 版本。

示例 7. 简单的 USES=python

假设当前支持的 Python 版本是 2.7、3.4、3.5 和 3.6,且默认的 Python 2 和 Python 3 版本分别是 2.7 和 3.6,那么以下写法:

USES=	python
USE_PYTHON=	distutils

将获得这些 flavor:py27 和 py36。

USES=	python
USE_PYTHON=	distutils allflavors

将获得这些 flavor:py27、py34、py35 和 py36。

示例 8:带版本要求的 USES=python

假设当前支持的 Python 版本是 2.7、3.4、3.5 和 3.6,且默认的 Python 2 和 Python 3 版本分别是 2.7 和 3.6,那么以下写法:

USES=	python:-3.5
USE_PYTHON=	distutils

将获得这个 flavor:py27。

USES=	python:-3.5
USE_PYTHON=	distutils allflavors

将获得这些 flavor:py27、py34 和 py35。

USES=	python:3.4+
USE_PYTHON=	distutils

将获得这个 flavor:py36。

将获得这些 flavor:py34、py35 和 py36。

可以使用 PY_FLAVOR 来依赖正确版本的 Python 模块。所有对支持 flavor 的 Python Port 的依赖都应使用 PY_FLAVOR,而不是直接使用 FLAVOR。

示例 9. 适用于未使用 distutils 的 Port

如果默认的 Python 3 版本是 3.6,以下写法将把 PY_FLAVOR 设置为 py36:

最后更新于

这有帮助吗?