Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/python.mk
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
# ${PREFIX}/bin | # ${PREFIX}/bin | ||||
# ${PREFIX}/sbin | # ${PREFIX}/sbin | ||||
# ${PREFIX}/libexec | # ${PREFIX}/libexec | ||||
# | # | ||||
# are linked from the prefixed version to the | # are linked from the prefixed version to the | ||||
# prefix-less original name, e.g. | # prefix-less original name, e.g. | ||||
# bin/foo-2.7 --> bin/foo. | # bin/foo-2.7 --> bin/foo. | ||||
# | # | ||||
# cython - Depend on lang/cython at build-time. | |||||
# | |||||
# cython_run - Depend on lang/cython at run-time. | |||||
# | |||||
# flavors - Force creation of flavors for python2 and python3, if | |||||
# applicable. | |||||
# | |||||
# noflavors - Disable automatic creation of flavors if they would | |||||
# otherwise be created and they are not wanted. | |||||
# | |||||
# optsuffix - Set PKGNAMESUFFIX to PYTHON_PKGNAMESUFFIX if not the | |||||
# default python version. | |||||
# | |||||
# distutils - Use distutils as do-configure, do-build and | # distutils - Use distutils as do-configure, do-build and | ||||
# do-install targets. | # do-install targets. implies flavors. | ||||
# | # | ||||
# autoplist - Automatically generates the packaging list for a | # autoplist - Automatically generates the packaging list for a | ||||
# port that uses distutils when defined. | # port that uses distutils when defined. | ||||
# requires: distutils | # requires: distutils | ||||
# | # | ||||
# py3kplist - Automatically generates Python 3.x compatible | # py3kplist - Automatically generates Python 3.x compatible | ||||
# __pycache__ entries from a Python 2.x packaging list | # __pycache__ entries from a Python 2.x packaging list | ||||
# when defined. Use this for ports that do *not* use | # when defined. Use this for ports that do *not* use | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | |||||
_PYTHON_BASECMD= ${LOCALBASE}/bin/python | _PYTHON_BASECMD= ${LOCALBASE}/bin/python | ||||
_PYTHON_RELPORTDIR= lang/python | _PYTHON_RELPORTDIR= lang/python | ||||
# Make each individual feature available as _PYTHON_FEATURE_<FEATURENAME> | # Make each individual feature available as _PYTHON_FEATURE_<FEATURENAME> | ||||
.for var in ${USE_PYTHON} | .for var in ${USE_PYTHON} | ||||
_PYTHON_FEATURE_${var:tu}= yes | _PYTHON_FEATURE_${var:tu}= yes | ||||
.endfor | .endfor | ||||
# distutils automatically generates flavors depending on the supported | |||||
# versions. | |||||
.if defined(_PYTHON_FEATURE_DISTUTILS) | |||||
_PYTHON_FEATURE_FLAVORS= yes | |||||
.endif | |||||
.if defined(_PYTHON_FEATURE_NOFLAVORS) | |||||
.undef _PYTHON_FEATURE_FLAVORS | |||||
.endif | |||||
# Make sure that no dependency or some other environment variable | # Make sure that no dependency or some other environment variable | ||||
# pollutes the build/run dependency detection | # pollutes the build/run dependency detection | ||||
.undef _PYTHON_BUILD_DEP | .undef _PYTHON_BUILD_DEP | ||||
.undef _PYTHON_RUN_DEP | .undef _PYTHON_RUN_DEP | ||||
.undef _PYTHON_TEST_DEP | .undef _PYTHON_TEST_DEP | ||||
_PYTHON_ARGS= ${python_ARGS:S/,/ /g} | _PYTHON_ARGS= ${python_ARGS:S/,/ /g} | ||||
.if ${_PYTHON_ARGS:Mbuild} | .if ${_PYTHON_ARGS:Mbuild} | ||||
_PYTHON_BUILD_DEP= yes | _PYTHON_BUILD_DEP= yes | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
.if ${PYTHON_DEFAULT_VERSION} == "python3" | .if ${PYTHON_DEFAULT_VERSION} == "python3" | ||||
PYTHON3_DEFAULT_VERSION?= python${PYTHON3_DEFAULT} | PYTHON3_DEFAULT_VERSION?= python${PYTHON3_DEFAULT} | ||||
.elif ${PYTHON_DEFAULT_VERSION:R} == "python3" | .elif ${PYTHON_DEFAULT_VERSION:R} == "python3" | ||||
PYTHON3_DEFAULT_VERSION= ${PYTHON_DEFAULT_VERSION} | PYTHON3_DEFAULT_VERSION= ${PYTHON_DEFAULT_VERSION} | ||||
.else | .else | ||||
PYTHON3_DEFAULT_VERSION?= python${PYTHON3_DEFAULT} | PYTHON3_DEFAULT_VERSION?= python${PYTHON3_DEFAULT} | ||||
.endif | .endif | ||||
# Keep this before the FLAVOR selection to get the meta port dependency. | |||||
.if ${_PYTHON_ARGS} == "2" | .if ${_PYTHON_ARGS} == "2" | ||||
_PYTHON_ARGS= ${PYTHON2_DEFAULT_VERSION:S/^python//} | _PYTHON_ARGS= ${PYTHON2_DEFAULT_VERSION:S/^python//} | ||||
_WANTS_META_PORT= 2 | _WANTS_META_PORT= 2 | ||||
.elif ${_PYTHON_ARGS} == "3" | .elif ${_PYTHON_ARGS} == "3" | ||||
_PYTHON_ARGS= ${PYTHON3_DEFAULT_VERSION:S/^python//} | _PYTHON_ARGS= ${PYTHON3_DEFAULT_VERSION:S/^python//} | ||||
_WANTS_META_PORT= 3 | _WANTS_META_PORT= 3 | ||||
.endif # ${_PYTHON_ARGS} == "2" | .endif # ${_PYTHON_ARGS} == "2" | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
_PYTHON_VERSION= ${ver} | _PYTHON_VERSION= ${ver} | ||||
.endif | .endif | ||||
.endfor | .endfor | ||||
.if !defined(_PYTHON_VERSION) | .if !defined(_PYTHON_VERSION) | ||||
IGNORE= needs an unsupported version of Python | IGNORE= needs an unsupported version of Python | ||||
.endif | .endif | ||||
.endif # defined(_PYTHON_VERSION_NONSUPPORTED) | .endif # defined(_PYTHON_VERSION_NONSUPPORTED) | ||||
# Automatically generates FLAVORS if empty | |||||
.if empty(FLAVORS) && defined(_PYTHON_FEATURE_FLAVORS) | |||||
. undef _VALID_PYTHON_VERSIONS | |||||
. for ver in ${PYTHON2_DEFAULT} ${PYTHON3_DEFAULT} ${_PYTHON_VERSIONS} | |||||
__VER= ${ver} | |||||
. if !(!empty(_PYTHON_VERSION_MINIMUM) && ( \ | |||||
${__VER} < ${_PYTHON_VERSION_MINIMUM})) && \ | |||||
!(!empty(_PYTHON_VERSION_MAXIMUM) && ( \ | |||||
${__VER} > ${_PYTHON_VERSION_MAXIMUM})) | |||||
_VALID_PYTHON_VERSIONS+= ${ver} | |||||
. endif | |||||
. endfor | |||||
. if defined(_VALID_PYTHON_VERSIONS) | |||||
. for _v in 2 3 | |||||
. if ${_VALID_PYTHON_VERSIONS:M${PYTHON${_v}_DEFAULT}} | |||||
FLAVORS+= python${_v} | |||||
. endif | |||||
. endfor | |||||
. else | |||||
FLAVORS= python2 python3 | |||||
. endif | |||||
. if !empty(FLAVORS) && empty(FLAVOR) | |||||
FLAVOR= ${FLAVORS:[1]} | |||||
# XXX: I do not think we need to force the python version here, as the default | |||||
# set earlier is there same as the flavor here. | |||||
. endif | |||||
.endif | |||||
.if ${FLAVOR} == python2 && ${FLAVORS:Mpython2} | |||||
_PYTHON_VERSION= ${PYTHON2_DEFAULT} | |||||
.elif ${FLAVOR} == python3 && ${FLAVORS:Mpython3} | |||||
_PYTHON_VERSION= ${PYTHON3_DEFAULT} | |||||
.endif | |||||
.if !empty(FLAVOR) && ${_PYTHON_VERSION} != ${PYTHON_DEFAULT} | |||||
.if defined(_PYTHON_FEATURE_OPTSUFFIX) | |||||
PKGNAMESUFFIX= ${PYTHON_PKGNAMESUFFIX} | |||||
.endif | |||||
.endif | |||||
# To avoid having dependencies with @ and empty flavor: | |||||
.if empty(FLAVOR) | |||||
DEPEND_FLAVOR= @${PYTHON_VERSION:R} | |||||
.else | |||||
DEPEND_FLAVOR= @${FLAVOR} | |||||
.endif | |||||
# Pass PYTHON_VERSION down the dependency chain. This ensures that | # Pass PYTHON_VERSION down the dependency chain. This ensures that | ||||
# port A -> B -> C all will use the same python version and do not | # port A -> B -> C all will use the same python version and do not | ||||
# try to find a different one, if the passed version fits into | # try to find a different one, if the passed version fits into | ||||
# the supported version range. | # the supported version range. | ||||
PYTHON_VERSION?= python${_PYTHON_VERSION} | PYTHON_VERSION?= python${_PYTHON_VERSION} | ||||
.if !defined(PYTHON_NO_DEPENDS) && \ | .if !defined(PYTHON_NO_DEPENDS) && \ | ||||
${PYTHON_VERSION} != ${PYTHON_DEFAULT_VERSION} | ${PYTHON_VERSION} != ${PYTHON_DEFAULT_VERSION} | ||||
DEPENDS_ARGS+= PYTHON_VERSION=${PYTHON_VERSION} | DEPENDS_ARGS+= PYTHON_VERSION=${PYTHON_VERSION} | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
# name (for staging-aware ports). | # name (for staging-aware ports). | ||||
# | # | ||||
# What makes a port 'bound' to a certain python version? | # What makes a port 'bound' to a certain python version? | ||||
# - it installs data into PYTHON_SITELIBDIR, PYTHON_INCLUDEDIR, ... | # - it installs data into PYTHON_SITELIBDIR, PYTHON_INCLUDEDIR, ... | ||||
# - it links against libpython*.so | # - it links against libpython*.so | ||||
# - it uses USE_PYTHON=distutils | # - it uses USE_PYTHON=distutils | ||||
# | # | ||||
.if defined(_PYTHON_FEATURE_CYTHON) | |||||
BUILD_DEPENDS+= cython-${PYTHON_VER}:lang/cython${DEPEND_FLAVOR} | |||||
.endif | |||||
.if defined(_PYTHON_FEATURE_CYTHON_RUN) | |||||
RUN_DEPENDS+= cython-${PYTHON_VER}:lang/cython${DEPEND_FLAVOR} | |||||
.endif | |||||
.if defined(_PYTHON_FEATURE_CONCURRENT) | .if defined(_PYTHON_FEATURE_CONCURRENT) | ||||
_USES_POST+= uniquefiles:dirs | _USES_POST+= uniquefiles:dirs | ||||
.if ${PYTHON_VERSION} == ${PYTHON_DEFAULT_VERSION} | .if ${PYTHON_VERSION} == ${PYTHON_DEFAULT_VERSION} | ||||
UNIQUE_DEFAULT_LINKS= yes | UNIQUE_DEFAULT_LINKS= yes | ||||
.else | .else | ||||
UNIQUE_DEFAULT_LINKS= no | UNIQUE_DEFAULT_LINKS= no | ||||
.endif | .endif | ||||
UNIQUE_PREFIX= ${PYTHON_PKGNAMEPREFIX} | UNIQUE_PREFIX= ${PYTHON_PKGNAMEPREFIX} | ||||
UNIQUE_SUFFIX= -${PYTHON_VER} | UNIQUE_SUFFIX= -${PYTHON_VER} | ||||
.if defined(_PYTHON_FEATURE_AUTOPLIST) | .if defined(_PYTHON_FEATURE_AUTOPLIST) | ||||
UNIQUE_FIND_SUFFIX_FILES= \ | UNIQUE_FIND_SUFFIX_FILES= \ | ||||
${SED} -e 's|^${PREFIX}/||' ${_PYTHONPKGLIST} ${TMPPLIST} | \ | ${SED} -e 's|^${PREFIX}/||' ${_PYTHONPKGLIST} ${TMPPLIST} | \ | ||||
${EGREP} -e '^bin/.*$$|^sbin/.*$$|^libexec/.*$$' | ${EGREP} -e '^bin/.*$$|^sbin/.*$$|^libexec/.*$$' | ||||
.else | .else | ||||
UNIQUE_FIND_SUFFIX_FILES= \ | UNIQUE_FIND_SUFFIX_FILES= \ | ||||
${EGREP} -he '^bin/.*$$|^sbin/.*$$|^libexec/.*$$' ${TMPPLIST} 2>/dev/null | ${EGREP} -he '^bin/.*$$|^sbin/.*$$|^libexec/.*$$' ${TMPPLIST} 2>/dev/null | ||||
.endif | .endif | ||||
.endif # defined(_PYTHON_FEATURE_CONCURRENT) | .endif # defined(_PYTHON_FEATURE_CONCURRENT) | ||||
_CURRENTPORT:= ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX} | _CURRENTPORT:= ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX} | ||||
.if defined(_PYTHON_FEATURE_DISTUTILS) && \ | .if defined(_PYTHON_FEATURE_DISTUTILS) && \ | ||||
${_CURRENTPORT} != ${PYTHON_PKGNAMEPREFIX}setuptools | ${_CURRENTPORT} != ${PYTHON_PKGNAMEPREFIX}setuptools | ||||
BUILD_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/${PYTHON_PKGNAMEPREFIX}setuptools | BUILD_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py-setuptools${DEPEND_FLAVOR} | ||||
RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/${PYTHON_PKGNAMEPREFIX}setuptools | RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py-setuptools${DEPEND_FLAVOR} | ||||
.endif | .endif | ||||
# distutils support | # distutils support | ||||
PYSETUP?= setup.py | PYSETUP?= setup.py | ||||
PYDISTUTILS_SETUP?= -c \ | PYDISTUTILS_SETUP?= -c \ | ||||
"import sys; import setuptools; \ | "import sys; import setuptools; \ | ||||
__file__='${PYSETUP}'; sys.argv[0]='${PYSETUP}'; \ | __file__='${PYSETUP}'; sys.argv[0]='${PYSETUP}'; \ | ||||
exec(compile(open(__file__, 'rb').read().replace(b'\\r\\n', b'\\n'), __file__, 'exec'))" | exec(compile(open(__file__, 'rb').read().replace(b'\\r\\n', b'\\n'), __file__, 'exec'))" | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
# Fix for programs that build python from a GNU auto* environment | # Fix for programs that build python from a GNU auto* environment | ||||
CONFIGURE_ENV+= PYTHON="${PYTHON_CMD}" | CONFIGURE_ENV+= PYTHON="${PYTHON_CMD}" | ||||
# By default CMake picks up the highest available version of Python package. | # By default CMake picks up the highest available version of Python package. | ||||
# Enforce the version required by the port or the default. | # Enforce the version required by the port or the default. | ||||
CMAKE_ARGS+= -DPython_ADDITIONAL_VERSIONS=${PYTHON_VER} | CMAKE_ARGS+= -DPython_ADDITIONAL_VERSIONS=${PYTHON_VER} | ||||
# Python 3rd-party modules | # Python 3rd-party modules | ||||
PYGAME= ${PYTHON_PKGNAMEPREFIX}game>0:devel/py-game | PYGAME= ${PYTHON_PKGNAMEPREFIX}game>0:devel/py-game${DEPEND_FLAVOR} | ||||
PYNUMERIC= ${PYTHON_SITELIBDIR}/Numeric/Numeric.py:math/py-numeric | PYNUMERIC= ${PYTHON_SITELIBDIR}/Numeric/Numeric.py:math/py-numeric${DEPEND_FLAVOR} | ||||
PYNUMPY= ${PYTHON_SITELIBDIR}/numpy/core/numeric.py:math/py-numpy | PYNUMPY= ${PYTHON_SITELIBDIR}/numpy/core/numeric.py:math/py-numpy${DEPEND_FLAVOR} | ||||
# Common Python modules that can be needed but only for some versions of Python. | |||||
.if ${PYTHON_REL} < 3400 | |||||
PY_ENUM34= ${PYTHON_PKGNAMEPREFIX}enum34>0:devel/py-enum34${DEPEND_FLAVOR} | |||||
PY_ENUM_COMPAT= ${PYTHON_PKGNAMEPREFIX}enum-compat>0:devel/py-enum-compat${DEPEND_FLAVOR} | |||||
PY_PATHLIB= ${PYTHON_PKGNAMEPREFIX}pathlib>0:devel/py-pathlib${DEPEND_FLAVOR} | |||||
.else | |||||
PY_ENUM34= | |||||
PY_ENUM_COMPAT= | |||||
PY_PATHLIB= | |||||
.endif | |||||
.if ${PYTHON_REL} < 3300 | |||||
PY_IPADDRESS= ${PYTHON_PKGNAMEPREFIX}ipaddress>0:net/py-ipaddress${DEPEND_FLAVOR} | |||||
.else | |||||
PY_IPADDRESS= | |||||
.endif | |||||
.if ${PYTHON_REL} < 3200 | |||||
PY_FUTURES= ${PYTHON_PKGNAMEPREFIX}futures>0:devel/py-futures${DEPEND_FLAVOR} | |||||
.else | |||||
PY_FUTURES= | |||||
.endif | |||||
# dependencies | # dependencies | ||||
.if defined(_PYTHON_BUILD_DEP) | .if defined(_PYTHON_BUILD_DEP) | ||||
BUILD_DEPENDS+= ${PYTHON_CMD}:${PYTHON_PORTSDIR} | BUILD_DEPENDS+= ${PYTHON_CMD}:${PYTHON_PORTSDIR} | ||||
.if defined(_WANTS_META_PORT) | .if defined(_WANTS_META_PORT) | ||||
BUILD_DEPENDS+= python${_WANTS_META_PORT}:${_PYTHON_RELPORTDIR}${_WANTS_META_PORT} | BUILD_DEPENDS+= python${_WANTS_META_PORT}:${_PYTHON_RELPORTDIR}${_WANTS_META_PORT} | ||||
.endif | .endif | ||||
.endif | .endif | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |