Changeset 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. | |||||
FreeBSD_ShaneWare.Biz: cython_run should also be here. | |||||
# | |||||
# cython_run - Depend on lang/cython at run-time. | |||||
# | |||||
# flavors - Force creation of flavors for Python 2 and 3 default | |||||
# versions, where applicable. | |||||
# | |||||
# noflavors - Disable automatic creation of flavors if they would | |||||
# otherwise be created and they are not wanted. | |||||
# | |||||
# allflavors - Generate flavors for all possible versions and not | |||||
# simply the default ones. | |||||
# | |||||
# 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 146 Lines • ▼ Show 20 Lines | |||||
# Mk/bsd.default-versions.mk in sync. | # Mk/bsd.default-versions.mk in sync. | ||||
_PYTHON_VERSIONS= 2.7 3.6 3.5 3.4 # preferred first | _PYTHON_VERSIONS= 2.7 3.6 3.5 3.4 # preferred first | ||||
_PYTHON_PORTBRANCH= 2.7 # ${_PYTHON_VERSIONS:[1]} | _PYTHON_PORTBRANCH= 2.7 # ${_PYTHON_VERSIONS:[1]} | ||||
_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:C/=.*$//:tu}= ${var:C/.*=//:S/,/ /g} | ||||
.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 ${PYTHON_DEFAULT} ${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})) | |||||
. if empty(_VALID_PYTHON_VERSIONS:M${ver}) | |||||
_VALID_PYTHON_VERSIONS+= ${ver} | |||||
. endif | |||||
. endif | |||||
. endfor | |||||
# Get all possible flavors depending on version requirements | |||||
. if defined(_VALID_PYTHON_VERSIONS) | |||||
_ALL_PYTHON_FLAVORS= ${_VALID_PYTHON_VERSIONS:S/.//:S/^/py/} | |||||
. else | |||||
_ALL_PYTHON_FLAVORS= ${_PYTHON_VERSIONS:S/.//:S/^/py/} | |||||
. endif | |||||
Done Inline ActionsSo I think we need FLAVORS to be py27 py34 py35 py36, etc. Right now I only see 'python3' when there's really 3 flavors of python3. This brings the most benefit of flavors by providing all possible python packages. bdrewery: So I think we need FLAVORS to be py27 py34 py35 py36, etc. Right now I only see 'python3' when… | |||||
Done Inline ActionsI disagree. If someone wants to have a non default python 3, then one can change DEFAULT_VERSIONS+=python3=3.4. I really do not see what this adds. Except about 10k packages to (re)build. Changing like you say makes it impossible for a port to say "I am using python3, I don't care which flavor, and I do not want to be poluted with flavors." mat: I disagree. If someone wants to have a non default python 3, then one can change… | |||||
Done Inline ActionsI thune i don't want 4 versions of python ports, there is already default_versions += python3= antoine: I thune i don't want 4 versions of python ports, there is already default_versions += python3= | |||||
# Decide how many flavors we want. By default, only generate the default | |||||
# versions. | |||||
. if defined(BUILD_ALL_PYTHON_FLAVORS) || defined(_PYTHON_FEATURE_ALLFLAVORS) | |||||
FLAVORS= ${_ALL_PYTHON_FLAVORS} | |||||
. else | |||||
. for _v in ${PYTHON3_DEFAULT} ${PYTHON2_DEFAULT} ${PYTHON_DEFAULT} | |||||
_f= py${_v:S/.//} | |||||
. if ${_ALL_PYTHON_FLAVORS:M${_f}} && !${FLAVORS:M${_f}} | |||||
FLAVORS:= ${_f} ${FLAVORS} | |||||
. endif | |||||
. endfor | |||||
. endif | |||||
. if !empty(FLAVORS) && empty(FLAVOR) | |||||
FLAVOR= ${FLAVORS:[1]} | |||||
Not Done Inline ActionsEXTRA_PYTHON_FLAVORS feels funky. Can't we just append to FLAVORS if it already has a value? bdrewery: EXTRA_PYTHON_FLAVORS feels funky. Can't we just append to FLAVORS if it already has a value?
At… | |||||
Not Done Inline ActionsWell, no, you can't really append to flavors, the "automatic" FLAVORS generation is only done if FLAVORS is empty, as to not clobber something more interesting done by the porter. Maybe it could be part of USE_PYTHON, say: USE_PYTHON= extraflavor=py34,py35 mat: Well, no, you can't really append to flavors, the "automatic" FLAVORS generation is only done… | |||||
Not Done Inline ActionsThinking about it, I could simply add a: USE_PYTHON= allflavors to get all the possible versions, it would make things a bit easier. mat: Thinking about it, I could simply add a:
USE_PYTHON= allflavors
to get all the possible… | |||||
. endif | |||||
.endif | |||||
.if ${FLAVOR:Mpy[23]*} | |||||
_PYTHON_VERSION= ${FLAVOR:S/py//:C/(.)/\1./} | |||||
.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) | |||||
PY_FLAVOR= ${PYTHON_VERSION:S/^python/py/:S/.//} | |||||
.else | |||||
PY_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@${PY_FLAVOR} | |||||
.endif | |||||
.if defined(_PYTHON_FEATURE_CYTHON_RUN) | |||||
RUN_DEPENDS+= cython-${PYTHON_VER}:lang/cython@${PY_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@${PY_FLAVOR} | ||||
RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/${PYTHON_PKGNAMEPREFIX}setuptools | RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py-setuptools@${PY_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@${PY_FLAVOR} | ||||
PYNUMERIC= ${PYTHON_SITELIBDIR}/Numeric/Numeric.py:math/py-numeric | PYNUMERIC= ${PYTHON_SITELIBDIR}/Numeric/Numeric.py:math/py-numeric@${PY_FLAVOR} | ||||
PYNUMPY= ${PYTHON_SITELIBDIR}/numpy/core/numeric.py:math/py-numpy | PYNUMPY= ${PYTHON_SITELIBDIR}/numpy/core/numeric.py:math/py-numpy@${PY_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@${PY_FLAVOR} | |||||
PY_ENUM_COMPAT= ${PYTHON_PKGNAMEPREFIX}enum-compat>0:devel/py-enum-compat@${PY_FLAVOR} | |||||
PY_PATHLIB= ${PYTHON_PKGNAMEPREFIX}pathlib>0:devel/py-pathlib@${PY_FLAVOR} | |||||
.else | |||||
PY_ENUM34= | |||||
PY_ENUM_COMPAT= | |||||
PY_PATHLIB= | |||||
.endif | |||||
.if ${PYTHON_REL} < 3300 | |||||
PY_IPADDRESS= ${PYTHON_PKGNAMEPREFIX}ipaddress>0:net/py-ipaddress@${PY_FLAVOR} | |||||
.else | |||||
PY_IPADDRESS= | |||||
.endif | |||||
.if ${PYTHON_REL} < 3200 | |||||
PY_FUTURES= ${PYTHON_PKGNAMEPREFIX}futures>0:devel/py-futures@${PY_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 |
cython_run should also be here.