Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/python.mk
| Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | |||||
| # packages for different Python versions. | # packages for different Python versions. | ||||
| # default: py${PYTHON_SUFFIX}- | # default: py${PYTHON_SUFFIX}- | ||||
| # | # | ||||
| # Using USES=python.mk also will add some useful entries to PLIST_SUB: | # Using USES=python.mk also will add some useful entries to PLIST_SUB: | ||||
| # | # | ||||
| # PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;} | # PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;} | ||||
| # PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;} | # PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;} | ||||
| # PYTHON_PLATFORM=${PYTHON_PLATFORM} | # PYTHON_PLATFORM=${PYTHON_PLATFORM} | ||||
| # PYTHON_PYOEXTENSION=${PYTHON_PYOEXTENSION} | |||||
| # PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} | # PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} | ||||
| # PYTHON_SUFFIX=${PYTHON_SUFFIX} | |||||
| # PYTHON_VER=${PYTHON_VER} | # PYTHON_VER=${PYTHON_VER} | ||||
| # PYTHON_VERSION=${PYTHON_VERSION} | # PYTHON_VERSION=${PYTHON_VERSION} | ||||
| # | # | ||||
| # and PYTHON2 and PYTHON3 will be set according to the Python version: | |||||
| # | # | ||||
| # PYTHON2="" PYTHON3="@comment " for Python 2.x | |||||
| # PYTHON2="@comment " PYTHON3="" for Python 3.x | |||||
| # | |||||
| # Deprecated variables, which exist for compatibility and will be removed | # Deprecated variables, which exist for compatibility and will be removed | ||||
| # soon: | # soon: | ||||
| # | # | ||||
| # PYTHON_DEFAULT_VERSION | # PYTHON_DEFAULT_VERSION | ||||
| # PYTHON2_DEFAULT_VERSION | # PYTHON2_DEFAULT_VERSION | ||||
| # PYTHON3_DEFAULT_VERSION | # PYTHON3_DEFAULT_VERSION | ||||
| # - Deprecated, use PYTHON[2,3]_DEFAULT instead, | # - Deprecated, use PYTHON[2,3]_DEFAULT instead, | ||||
| # see bsd.default-versions.mk | # see bsd.default-versions.mk | ||||
| ▲ Show 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | |||||
| PYTHONPREFIX_INCLUDEDIR= ${PYTHON_INCLUDEDIR:S;${PYTHONBASE};${PREFIX};} | PYTHONPREFIX_INCLUDEDIR= ${PYTHON_INCLUDEDIR:S;${PYTHONBASE};${PREFIX};} | ||||
| PYTHONPREFIX_LIBDIR= ${PYTHON_LIBDIR:S;${PYTHONBASE};${PREFIX};} | PYTHONPREFIX_LIBDIR= ${PYTHON_LIBDIR:S;${PYTHONBASE};${PREFIX};} | ||||
| PYTHONPREFIX_SITELIBDIR= ${PYTHON_SITELIBDIR:S;${PYTHONBASE};${PREFIX};} | PYTHONPREFIX_SITELIBDIR= ${PYTHON_SITELIBDIR:S;${PYTHONBASE};${PREFIX};} | ||||
| # Used for recording the installed files. | # Used for recording the installed files. | ||||
| _PYTHONPKGLIST= ${WRKDIR}/.PLIST.pymodtmp | _PYTHONPKGLIST= ${WRKDIR}/.PLIST.pymodtmp | ||||
| # PEP 0488 (https://www.python.org/dev/peps/pep-0488/) | |||||
| .if ${PYTHON_REL} < 3500 | |||||
| PYTHON_PYOEXTENSION= pyo | |||||
| .else | |||||
| PYTHON_PYOEXTENSION= opt-1.pyc | |||||
| .endif | |||||
| # Ports bound to a certain python version SHOULD | # Ports bound to a certain python version SHOULD | ||||
| # - use the PYTHON_PKGNAMEPREFIX | # - use the PYTHON_PKGNAMEPREFIX | ||||
| # - use directories using the PYTHON_PKGNAMEPREFIX | # - use directories using the PYTHON_PKGNAMEPREFIX | ||||
| # - install binaries using the required PYTHON_VER, with | # - install binaries using the required PYTHON_VER, with | ||||
| # the default python version creating a symlink to the original binary | # the default python version creating a symlink to the original binary | ||||
| # 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? | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | @${SED} -e 's|^${STAGEDIR}${PREFIX}/||' \ | ||||
| ${_PYTHONPKGLIST} | ${SORT} >> ${TMPPLIST} | ${_PYTHONPKGLIST} | ${SORT} >> ${TMPPLIST} | ||||
| .else | .else | ||||
| .if ${PYTHON_REL} >= 3200 && defined(_PYTHON_FEATURE_PY3KPLIST) | .if ${PYTHON_REL} >= 3200 && defined(_PYTHON_FEATURE_PY3KPLIST) | ||||
| # When Python version is 3.2+ we rewrite all the filenames | # When Python version is 3.2+ we rewrite all the filenames | ||||
| # of TMPPLIST that end with .py[co], so that they conform | # of TMPPLIST that end with .py[co], so that they conform | ||||
| # to PEP 3147 (see http://www.python.org/dev/peps/pep-3147/) | # to PEP 3147 (see http://www.python.org/dev/peps/pep-3147/) | ||||
| PYMAGICTAG= ${PYTHON_CMD} -c 'import imp; print(imp.get_tag())' | PYMAGICTAG= ${PYTHON_CMD} -c 'import imp; print(imp.get_tag())' | ||||
| .if ${PYTHON_REL} < 3500 | |||||
| PYOEXTENSION= pyo | |||||
| .else | |||||
| PYOEXTENSION= opt-1.pyc | |||||
| .endif | |||||
| add-plist-post: | add-plist-post: | ||||
| @${AWK} '\ | @${AWK} '\ | ||||
| /\.py[co]$$/ && !($$0 ~ "/" pc "/") {id = match($$0, /\/[^\/]+\.py[co]$$/); if (id != 0) {d = substr($$0, 1, RSTART - 1); dirs[d] = 1}; sub(/\.pyc$$/, "." mt "&"); sub(/\.pyo$$/, "." mt "." pyo); sub(/[^\/]+\.py[co]$$/, pc "/&"); print; next} \ | /\.py[co]$$/ && !($$0 ~ "/" pc "/") {id = match($$0, /\/[^\/]+\.py[co]$$/); if (id != 0) {d = substr($$0, 1, RSTART - 1); dirs[d] = 1}; sub(/\.pyc$$/, "." mt "&"); sub(/\.pyo$$/, "." mt "." pyo); sub(/[^\/]+\.py[co]$$/, pc "/&"); print; next} \ | ||||
| /^@dirrm / {d = substr($$0, 8); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \ | /^@dirrm / {d = substr($$0, 8); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \ | ||||
| /^@dirrmtry / {d = substr($$0, 11); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \ | /^@dirrmtry / {d = substr($$0, 11); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \ | ||||
| {print} \ | {print} \ | ||||
| ' \ | ' \ | ||||
| pc="__pycache__" mt="$$(${PYMAGICTAG})" pyo="${PYOEXTENSION}" \ | pc="__pycache__" mt="$$(${PYMAGICTAG})" pyo="${PYTHON_PYOEXTENSION}" \ | ||||
| ${TMPPLIST} > ${TMPPLIST}.pyc_tmp | ${TMPPLIST} > ${TMPPLIST}.pyc_tmp | ||||
| @${MV} ${TMPPLIST}.pyc_tmp ${TMPPLIST} | @${MV} ${TMPPLIST}.pyc_tmp ${TMPPLIST} | ||||
| .endif # ${PYTHON_REL} >= 3200 && defined(_PYTHON_FEATURE_PY3KPLIST) | .endif # ${PYTHON_REL} >= 3200 && defined(_PYTHON_FEATURE_PY3KPLIST) | ||||
| .endif # defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS) | .endif # defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS) | ||||
| # 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}" | ||||
| Show All 32 Lines | |||||
| .endif | .endif | ||||
| # Substitutions for pkg-plist | # Substitutions for pkg-plist | ||||
| # Use a short form of the PYTHONPREFIX_*DIR variables; we don't need the | # Use a short form of the PYTHONPREFIX_*DIR variables; we don't need the | ||||
| # base directory in the plist file. | # base directory in the plist file. | ||||
| PLIST_SUB+= PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;} \ | PLIST_SUB+= PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;} \ | ||||
| PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;} \ | PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;} \ | ||||
| PYTHON_PLATFORM=${PYTHON_PLATFORM} \ | PYTHON_PLATFORM=${PYTHON_PLATFORM} \ | ||||
| PYTHON_PYOEXTENSION=${PYTHON_PYOEXTENSION} \ | |||||
| PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} \ | PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} \ | ||||
| PYTHON_SUFFIX=${PYTHON_SUFFIX} \ | |||||
| PYTHON_VER=${PYTHON_VER} \ | PYTHON_VER=${PYTHON_VER} \ | ||||
| PYTHON_VERSION=python${_PYTHON_VERSION} | PYTHON_VERSION=${PYTHON_VERSION} | ||||
| .if ${PYTHON_REL} < 3000 | |||||
| PLIST_SUB+= PYTHON2="" PYTHON3="@comment " | |||||
| .else | |||||
| PLIST_SUB+= PYTHON2="@comment " PYTHON3="" | |||||
| .endif | |||||
| _USES_POST+= python | _USES_POST+= python | ||||
| .endif # _INCLUDE_USES_PYTHON_MK | .endif # _INCLUDE_USES_PYTHON_MK | ||||
| .if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_PYTHON_POST_MK) | .if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_PYTHON_POST_MK) | ||||
| _INCLUDE_USES_PYTHON_POST_MK= yes | _INCLUDE_USES_PYTHON_POST_MK= yes | ||||
| # py-distutils support | # py-distutils support | ||||
| Show All 26 Lines | |||||