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. | ||||
# | # | ||||
# flavors - Force creation of flavors for python2 and python3, if | |||||
FreeBSD_ShaneWare.Biz: cython_run should also be here. | |||||
# applicable. | |||||
# | |||||
# 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 | |||||
# 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" | ||||
.if ${FLAVOR} == python2 | |||||
_PYTHON_ARGS= ${PYTHON2_DEFAULT} | |||||
.elif ${FLAVOR} == python3 | |||||
_PYTHON_ARGS= ${PYTHON3_DEFAULT} | |||||
.endif | |||||
.if defined(PYTHON_VERSION) | .if defined(PYTHON_VERSION) | ||||
# A port/user requests a specific python version for its dependencies via | # A port/user requests a specific python version for its dependencies via | ||||
# DEPENDS_ARGS, since it requires the specific python version itself. | # DEPENDS_ARGS, since it requires the specific python version itself. | ||||
# Several things can happen now: | # Several things can happen now: | ||||
# a) the dependency supports the requested version -> everything's fine | # a) the dependency supports the requested version -> everything's fine | ||||
# b) the dependency does not support the requested version | # b) the dependency does not support the requested version | ||||
# 1) the dependency works in a way that the different python | # 1) the dependency works in a way that the different python | ||||
# versions do not matter -> everything's fine | # versions do not matter -> everything's fine | ||||
▲ Show 20 Lines • Show All 41 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 | |||||
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= | |||||
. 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 | |||||
# To avoid having dependencies with @ and empty flavor: | |||||
DEPEND_FLAVOR= ${FLAVOR:C/(.+)/@\1/} | |||||
# 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 | ||||
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… | |||||
# 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} | ||||
.endif | .endif | ||||
# NOTE: | # NOTE: | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
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/py27-setuptools${DEPEND_FLAVOR} | ||||
RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/${PYTHON_PKGNAMEPREFIX}setuptools | RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py27-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} | ||||
# 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.