Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/python.mk
Show First 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | |||||
.endif | .endif | ||||
.if ${_PYTHON_ARGS} == "2" | .if ${_PYTHON_ARGS} == "2" | ||||
DEV_ERROR+= "USES=python:2 is no longer supported, use USES=python:2.7" | DEV_ERROR+= "USES=python:2 is no longer supported, use USES=python:2.7" | ||||
.elif ${_PYTHON_ARGS} == "3" | .elif ${_PYTHON_ARGS} == "3" | ||||
DEV_ERROR+= "USES=python:3 is no longer supported, use USES=python:3.5+ or an appropriate version range" | DEV_ERROR+= "USES=python:3 is no longer supported, use USES=python:3.5+ or an appropriate version range" | ||||
.endif # ${_PYTHON_ARGS} == "2" | .endif # ${_PYTHON_ARGS} == "2" | ||||
.if defined(PYTHON_VERSION) | |||||
# A port/user requests a specific python version for its dependencies via | |||||
# DEPENDS_ARGS, since it requires the specific python version itself. | |||||
# Several things can happen now: | |||||
# a) the dependency supports the requested version -> everything's fine | |||||
# b) the dependency does not support the requested version | |||||
# 1) the dependency works in a way that the different python | |||||
# versions do not matter -> everything's fine | |||||
# 2) the dependency is likely to break due to the conflict | |||||
# nothing's fine | |||||
# | |||||
# b.2) needs to be resolved. Due to the complexity of how different pieces of | |||||
# software are built, we can't solve this automatically. Instead, let's assume | |||||
# that maintainers know what they are doing and assume PYTHON_VERSION to be a | |||||
# hint. Just warn maintainers, if the versions do not match | |||||
# (_PYTHON_VERSION_NONSUPPORTED). | |||||
_PYTHON_VERSION:= ${PYTHON_VERSION:S/^python//} | |||||
.else | |||||
_PYTHON_VERSION:= ${PYTHON_DEFAULT} | _PYTHON_VERSION:= ${PYTHON_DEFAULT} | ||||
.endif # defined(PYTHON_VERSION) | |||||
# Validate Python version whether it meets the version restriction. | # Validate Python version whether it meets the version restriction. | ||||
_PYTHON_VERSION_CHECK:= ${_PYTHON_ARGS:C/^([1-9]\.[0-9])$/\1-\1/} | _PYTHON_VERSION_CHECK:= ${_PYTHON_ARGS:C/^([1-9]\.[0-9])$/\1-\1/} | ||||
_PYTHON_VERSION_MINIMUM_TMP:= ${_PYTHON_VERSION_CHECK:C/([1-9]\.[0-9])[-+].*/\1/} | _PYTHON_VERSION_MINIMUM_TMP:= ${_PYTHON_VERSION_CHECK:C/([1-9]\.[0-9])[-+].*/\1/} | ||||
_PYTHON_VERSION_MINIMUM:= ${_PYTHON_VERSION_MINIMUM_TMP:M[1-9].[0-9]} | _PYTHON_VERSION_MINIMUM:= ${_PYTHON_VERSION_MINIMUM_TMP:M[1-9].[0-9]} | ||||
_PYTHON_VERSION_MAXIMUM_TMP:= ${_PYTHON_VERSION_CHECK:C/.*-([1-9]\.[0-9])/\1/} | _PYTHON_VERSION_MAXIMUM_TMP:= ${_PYTHON_VERSION_CHECK:C/.*-([1-9]\.[0-9])/\1/} | ||||
_PYTHON_VERSION_MAXIMUM:= ${_PYTHON_VERSION_MAXIMUM_TMP:M[1-9].[0-9]} | _PYTHON_VERSION_MAXIMUM:= ${_PYTHON_VERSION_MAXIMUM_TMP:M[1-9].[0-9]} | ||||
# At this point we should have no argument left in ${_PYTHON_ARGS} | # At this point we should have no argument left in ${_PYTHON_ARGS} | ||||
# except a version spec | # except a version spec | ||||
_PYTHON_ARGS:= ${_PYTHON_ARGS:N[1-9].[0-9]-[1-9].[0-9]:N[1-9].[0-9]:N[1-9].[0-9]+:N-[1-9].[0-9]} | _PYTHON_ARGS:= ${_PYTHON_ARGS:N[1-9].[0-9]-[1-9].[0-9]:N[1-9].[0-9]:N[1-9].[0-9]+:N-[1-9].[0-9]} | ||||
.if !empty(_PYTHON_ARGS) | .if !empty(_PYTHON_ARGS) | ||||
IGNORE= uses unknown USES=python arguments: ${_PYTHON_ARGS} | IGNORE= uses unknown USES=python arguments: ${_PYTHON_ARGS} | ||||
.endif | .endif | ||||
.undef _PYTHON_VERSION_NONSUPPORTED | .undef _PYTHON_VERSION_NONSUPPORTED | ||||
.if !empty(_PYTHON_VERSION_MINIMUM) && (${_PYTHON_VERSION} < ${_PYTHON_VERSION_MINIMUM}) | .if !empty(_PYTHON_VERSION_MINIMUM) && (${_PYTHON_VERSION} < ${_PYTHON_VERSION_MINIMUM}) | ||||
_PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MINIMUM} at least | _PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MINIMUM} at least | ||||
.elif !empty(_PYTHON_VERSION_MAXIMUM) && (${_PYTHON_VERSION} > ${_PYTHON_VERSION_MAXIMUM}) | .elif !empty(_PYTHON_VERSION_MAXIMUM) && (${_PYTHON_VERSION} > ${_PYTHON_VERSION_MAXIMUM}) | ||||
_PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MAXIMUM} at most | _PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MAXIMUM} at most | ||||
.endif | .endif | ||||
# If we have an unsupported version of Python, try another. | # If we have an unsupported version of Python, try another. | ||||
.if defined(_PYTHON_VERSION_NONSUPPORTED) | .if defined(_PYTHON_VERSION_NONSUPPORTED) | ||||
.if defined(PYTHON_VERSION) || defined(PYTHON_CMD) | |||||
_PV:= ${_PYTHON_VERSION} # preserve the specified python version | |||||
IGNORE= needs Python ${_PYTHON_VERSION_NONSUPPORTED}, but ${_PV} was specified | |||||
.endif # defined(PYTHON_VERSION) || defined(PYTHON_CMD) | |||||
.undef _PYTHON_VERSION | .undef _PYTHON_VERSION | ||||
.for ver in ${PYTHON2_DEFAULT} ${PYTHON3_DEFAULT} ${_PYTHON_VERSIONS} | .for ver in ${PYTHON2_DEFAULT} ${PYTHON3_DEFAULT} ${_PYTHON_VERSIONS} | ||||
__VER= ${ver} | __VER= ${ver} | ||||
.if !defined(_PYTHON_VERSION) && \ | .if !defined(_PYTHON_VERSION) && \ | ||||
!(!empty(_PYTHON_VERSION_MINIMUM) && ( \ | !(!empty(_PYTHON_VERSION_MINIMUM) && ( \ | ||||
${__VER} < ${_PYTHON_VERSION_MINIMUM})) && \ | ${__VER} < ${_PYTHON_VERSION_MINIMUM})) && \ | ||||
!(!empty(_PYTHON_VERSION_MAXIMUM) && ( \ | !(!empty(_PYTHON_VERSION_MAXIMUM) && ( \ | ||||
${__VER} > ${_PYTHON_VERSION_MAXIMUM})) | ${__VER} > ${_PYTHON_VERSION_MAXIMUM})) | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
# To avoid having dependencies with @ and empty flavor: | # To avoid having dependencies with @ and empty flavor: | ||||
# _PYTHON_VERSION is either set by (first that matches): | # _PYTHON_VERSION is either set by (first that matches): | ||||
# - If using Python flavors, from the current Python flavor | # - If using Python flavors, from the current Python flavor | ||||
# - If using a version restriction (USES=python:3.5+), from the first | # - If using a version restriction (USES=python:3.5+), from the first | ||||
# acceptable default Python version. | # acceptable default Python version. | ||||
# - From PYTHON_DEFAULT | # - From PYTHON_DEFAULT | ||||
PY_FLAVOR= py${_PYTHON_VERSION:S/.//} | PY_FLAVOR= py${_PYTHON_VERSION:S/.//} | ||||
# Pass PYTHON_VERSION down the dependency chain. This ensures that | PYTHON_VERSION= python${_PYTHON_VERSION} | ||||
# 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 | |||||
# the supported version range. | |||||
PYTHON_VERSION?= python${_PYTHON_VERSION} | |||||
.if !defined(PYTHON_NO_DEPENDS) && \ | |||||
${PYTHON_VERSION} != python${PYTHON_DEFAULT} | |||||
DEPENDS_ARGS+= PYTHON_VERSION=${PYTHON_VERSION} | |||||
.endif | |||||
# NOTE: | |||||
# | |||||
# PYTHON_VERSION will hold whatever is passed down the dependency chain. | |||||
# If a user runs `make PYTHON_VERSION=python3.5, PYTHON_VERSION will be | |||||
# set to 'python3.5'. A port however may require a different version, | |||||
# which is stored (above) in _PYTHON_VERSION. | |||||
# Every python bit below hence should use python${_PYTHON_VERSION}, since | |||||
# this is the value, the _port_ requires | |||||
# | |||||
# Got the correct python version, set some publicly accessible variables | # Got the correct python version, set some publicly accessible variables | ||||
PYTHON_VER= ${_PYTHON_VERSION} | PYTHON_VER= ${_PYTHON_VERSION} | ||||
PYTHON_SUFFIX= ${_PYTHON_VERSION:S/.//g} | PYTHON_SUFFIX= ${_PYTHON_VERSION:S/.//g} | ||||
PYTHON_MAJOR_VER= ${PYTHON_VER:R} | PYTHON_MAJOR_VER= ${PYTHON_VER:R} | ||||
PYTHON_REL= # empty | PYTHON_REL= # empty | ||||
PYTHON_ABIVER= # empty | PYTHON_ABIVER= # empty | ||||
PYTHON_PORTSDIR= ${_PYTHON_RELPORTDIR}${PYTHON_SUFFIX} | PYTHON_PORTSDIR= ${_PYTHON_RELPORTDIR}${PYTHON_SUFFIX} | ||||
# Protect partial checkouts from Mk/Scripts/functions.sh:export_ports_env(). | # Protect partial checkouts from Mk/Scripts/functions.sh:export_ports_env(). | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
.if defined(_PYTHON_FEATURE_CONCURRENT) | .if defined(_PYTHON_FEATURE_CONCURRENT) | ||||
.if !defined(_PYTHON_FEATURE_FLAVORS) && (${_PYTHON_VERSION_MINIMUM:M3*} || ${_PYTHON_VERSION_MAXIMUM:M2*}) | .if !defined(_PYTHON_FEATURE_FLAVORS) && (${_PYTHON_VERSION_MINIMUM:M3*} || ${_PYTHON_VERSION_MAXIMUM:M2*}) | ||||
DEV_WARNING+= "USE_PYTHON=concurrent when only one of Python 2 or 3 is supported AND not using flavors does not make any sense" | DEV_WARNING+= "USE_PYTHON=concurrent when only one of Python 2 or 3 is supported AND not using flavors does not make any sense" | ||||
.endif | .endif | ||||
_USES_POST+= uniquefiles:dirs | _USES_POST+= uniquefiles:dirs | ||||
.if defined(_PYTHON_FEATURE_FLAVORS) && ${FLAVOR} == ${FLAVORS:[1]} | .if defined(_PYTHON_FEATURE_FLAVORS) && ${FLAVOR} == ${FLAVORS:[1]} | ||||
UNIQUE_DEFAULT_LINKS= yes | UNIQUE_DEFAULT_LINKS= yes | ||||
.elif !defined(_PYTHON_FEATURE_FLAVORS) && ${PYTHON_VERSION} == python${PYTHON_DEFAULT} | .elif !defined(_PYTHON_FEATURE_FLAVORS) && ${_PYTHON_VERSION} == ${PYTHON_DEFAULT} | ||||
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} | ||||
UNIQUE_SUFFIX_TYPES+= SUFFIX_MAN | UNIQUE_SUFFIX_TYPES+= SUFFIX_MAN | ||||
UNIQUE_SUFFIX_MAN_WITH_EXT= .[1-9ln] | UNIQUE_SUFFIX_MAN_WITH_EXT= .[1-9ln] | ||||
▲ Show 20 Lines • Show All 193 Lines • Show Last 20 Lines |