Changeset View
Standalone View
Mk/Uses/python.mk
Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | .if !defined(_PYTHON_BUILD_DEP) && !defined(_PYTHON_RUN_DEP) && \ | ||||
!defined(PYTHON_NO_DEPENDS) | !defined(PYTHON_NO_DEPENDS) | ||||
_PYTHON_BUILD_DEP= yes | _PYTHON_BUILD_DEP= yes | ||||
_PYTHON_RUN_DEP= yes | _PYTHON_RUN_DEP= yes | ||||
.endif | .endif | ||||
# Determine version number of Python to use | # Determine version number of Python to use | ||||
.include "${PORTSDIR}/Mk/bsd.default-versions.mk" | .include "${PORTSDIR}/Mk/bsd.default-versions.mk" | ||||
# Load cached information about installed python if it is available | |||||
.if exists (${LOCALBASE}/share/python/vitals.mk) | |||||
.include "${LOCALBASE}/share/python/vitals.mk" | |||||
.endif | |||||
.if defined(PYTHON_DEFAULT_VERSION) | .if defined(PYTHON_DEFAULT_VERSION) | ||||
WARNING+= "PYTHON_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python=${PYTHON_DEFAULT_VERSION:S/^python//} instead" | WARNING+= "PYTHON_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python=${PYTHON_DEFAULT_VERSION:S/^python//} instead" | ||||
.endif | .endif | ||||
.if defined(PYTHON2_DEFAULT_VERSION) | .if defined(PYTHON2_DEFAULT_VERSION) | ||||
WARNING+= "PYTHON2_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python2=${PYTHON2_DEFAULT_VERSION:S/^python//} instead" | WARNING+= "PYTHON2_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python2=${PYTHON2_DEFAULT_VERSION:S/^python//} instead" | ||||
.endif | .endif | ||||
.if defined(PYTHON3_DEFAULT_VERSION) | .if defined(PYTHON3_DEFAULT_VERSION) | ||||
WARNING+= "PYTHON3_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python3=${PYTHON3_DEFAULT_VERSION:S/^python//} instead" | WARNING+= "PYTHON3_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python3=${PYTHON3_DEFAULT_VERSION:S/^python//} instead" | ||||
.endif | .endif | ||||
.if defined(METAPY_INSTALLED_VERSION) | |||||
_PYTHON_DEFAULT_VERSION= ${METAPY_INSTALLED_VERSION} | |||||
dbn: Would it not be possible to export METAPY_INSTALLED_VERSION as _PYTHON_DEFAULT_VERSION… | |||||
Not Done Inline ActionsI am working on an update to address several of the comments. I think it does not make sense to override _PYTHON_DEFAULT_VERSION when METAPY_INSTALLED_VERSION is installed though. All the data from vitals.mk have to stick together as a unit. marino: I am working on an update to address several of the comments. I think it does not make sense… | |||||
.else | |||||
.if exists(${LOCALBASE}/bin/python) | . if exists(${LOCALBASE}/bin/python) | ||||
Not Done Inline ActionsThis changes existing behaviour: if the user (or a tool) defined _PYTHON_DEFAULT_VERSION then it would get overridden in your patch with the version from python whereas the existing behaviour does not override it. dbn: This changes existing behaviour: if the user (or a tool) defined _PYTHON_DEFAULT_VERSION then… | |||||
Not Done Inline ActionsYou are right that behavior is changed. I didn't know why this was here until Bryan talked about ports_env.sh. On the other hand, this is an internal variable and no tool should be modifying it, right? Regarding ports_env.sh, is support for _PYTHON_DEFAULT_VERSION still required? It is there for performance reasons which we are addressing with this change. Or I am missing something? Is the behavior change a bad thing? marino: You are right that behavior is changed. I didn't know why this was here until Bryan talked… | |||||
.if !defined(_PYTHON_DEFAULT_VERSION) | . if !defined(_PYTHON_DEFAULT_VERSION) | ||||
_PYTHON_DEFAULT_VERSION!= (${LOCALBASE}/bin/python -c \ | _PYTHON_DEFAULT_VERSION!= (${LOCALBASE}/bin/python -c \ | ||||
'import sys; print("%d.%d" % sys.version_info[:2])' 2> /dev/null \ | 'import sys; print("%d.%d" % sys.version_info[:2])' 2> /dev/null \ | ||||
|| ${ECHO_CMD} ${_PYTHON_PORTBRANCH}) | ${TAIL} -1 | || ${ECHO_CMD} ${_PYTHON_PORTBRANCH}) | ${TAIL} -1 | ||||
.endif | . endif | ||||
. else | |||||
.undef _PYTHON_DEFAULT_VERSION | |||||
PYTHON_DEFAULT_VERSION= python${PYTHON_DEFAULT} | |||||
. endif | |||||
.endif | |||||
.if defined(_PYTHON_DEFAULT_VERSION) # python is already installed | |||||
_EXPORTED_VARS+= _PYTHON_DEFAULT_VERSION | _EXPORTED_VARS+= _PYTHON_DEFAULT_VERSION | ||||
PYTHON_DEFAULT_VERSION= python${_PYTHON_DEFAULT_VERSION} | |||||
.if defined(PYTHON_DEFAULT) && (${PYTHON_DEFAULT} != ${_PYTHON_DEFAULT_VERSION}) | .if defined(PYTHON_DEFAULT) && (${PYTHON_DEFAULT} != ${_PYTHON_DEFAULT_VERSION}) | ||||
WARNING+= "Your requested default python version ${PYTHON_DEFAULT} is different from the installed default python interpreter version ${_PYTHON_DEFAULT_VERSION}" | WARNING+= "Your requested default python version ${PYTHON_DEFAULT} is different from the installed default python interpreter version ${_PYTHON_DEFAULT_VERSION}" | ||||
.endif | .endif | ||||
PYTHON_DEFAULT_VERSION= python${_PYTHON_DEFAULT_VERSION} | .endif | ||||
.else | |||||
PYTHON_DEFAULT_VERSION= python${PYTHON_DEFAULT} | |||||
.endif # exists(${LOCALBASE}/bin/python) | |||||
# Is only a meta-port version defined? | # Is only a meta-port version defined? | ||||
.if ${PYTHON_DEFAULT_VERSION} == "python2" | .if ${PYTHON_DEFAULT_VERSION} == "python2" | ||||
PYTHON2_DEFAULT_VERSION?= python${PYTHON2_DEFAULT} | PYTHON2_DEFAULT_VERSION?= python${PYTHON2_DEFAULT} | ||||
.elif ${PYTHON_DEFAULT_VERSION:R} == "python2" | .elif ${PYTHON_DEFAULT_VERSION:R} == "python2" | ||||
PYTHON2_DEFAULT_VERSION= ${PYTHON_DEFAULT_VERSION} | PYTHON2_DEFAULT_VERSION= ${PYTHON_DEFAULT_VERSION} | ||||
.else | .else | ||||
PYTHON2_DEFAULT_VERSION?= python${PYTHON2_DEFAULT} | PYTHON2_DEFAULT_VERSION?= python${PYTHON2_DEFAULT} | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | |||||
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(). | ||||
.if !defined(_PORTS_ENV_CHECK) || exists(${PYTHON_PORTSDIR}) | .if !defined(_PORTS_ENV_CHECK) || exists(${PYTHON_PORTSDIR}) | ||||
.if !defined(PYTHON_PORTVERSION) | .if !defined(PYTHON_PORTVERSION) | ||||
PYTHON_PORTVERSION!= ${MAKE} -V PORTVERSION -C ${PYTHON_PORTSDIR} | .include "${PYTHON_PORTSDIR}/Makefile.version"; | ||||
.endif | .endif | ||||
_EXPORTED_VARS+= PYTHON_PORTVERSION | _EXPORTED_VARS+= PYTHON_PORTVERSION | ||||
.endif | .endif | ||||
# Create a 4 integer version string, prefixing 0 to the last token if | # Create a 4 integer version string, prefixing 0 to the last token if | ||||
# it's a single character. Only use the the first 3 tokens of | # it's a single character. Only use the the first 3 tokens of | ||||
# PORTVERSION to support pre-release versions (rc3, alpha4, etc) of | # PORTVERSION to support pre-release versions (rc3, alpha4, etc) of | ||||
# any Python port (lang/pythonXY) | # any Python port (lang/pythonXY) | ||||
PYTHON_REL= ${PYTHON_PORTVERSION:C/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/:C/\.([0-9]+)$/.0\1/:C/\.0?([0-9][0-9])$/.\1/:S/.//g} | PYTHON_REL= ${PYTHON_PORTVERSION:C/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/:C/\.([0-9]+)$/.0\1/:C/\.0?([0-9][0-9])$/.\1/:S/.//g} | ||||
# Might be overridden by calling ports | # Might be overridden by calling ports | ||||
PYTHON_CMD?= ${_PYTHON_BASECMD}${_PYTHON_VERSION} | PYTHON_CMD?= ${_PYTHON_BASECMD}${_PYTHON_VERSION} | ||||
.if defined(METAPY_ABIVER) | |||||
PYTHON_ABIVER= ${METAPY_ABIVER} | |||||
.else | |||||
.if exists(${PYTHON_CMD}-config) && ${PYTHON_VER} != 2.7 | .if exists(${PYTHON_CMD}-config) && ${PYTHON_VER} != 2.7 | ||||
Not Done Inline ActionsIf you are going to change the METAPY variables per the previous comment then maybe change this line to: (and change the exported METAPY_ABIVER to PYTHON_ABIVER). dbn: If you are going to change the METAPY variables per the previous comment then maybe change this… | |||||
Not Done Inline ActionsI'm not following this one. If by previous comment you are talking about Antoines, there was no functionality change (thus no need to change this) ... assuming I'm not missing something. I don't understand what the issue is about PYTHON_ABIVER. It looks functional as it is to me. Maybe somebody can illustrate a problem with an example to help me understand? marino: I'm not following this one. If by previous comment you are talking about Antoines, there was… | |||||
PYTHON_ABIVER!= ${PYTHON_CMD}-config --abiflags | PYTHON_ABIVER!= ${PYTHON_CMD}-config --abiflags | ||||
.endif | .endif | ||||
.endif | |||||
.if !defined(PYTHONBASE) | .if !defined(PYTHONBASE) | ||||
.if defined(METAPY_BASE) | |||||
PYTHONBASE= ${METAPY_BASE} | |||||
.else | |||||
. if defined(_PYTHON_DEFAULT_VERSION) # python is definitely installed | |||||
PYTHONBASE!= (${PYTHON_CMD} -c 'import sys; print(sys.prefix)' \ | PYTHONBASE!= (${PYTHON_CMD} -c 'import sys; print(sys.prefix)' \ | ||||
2> /dev/null || ${ECHO_CMD} ${LOCALBASE}) | ${TAIL} -1 | 2> /dev/null || ${ECHO_CMD} ${LOCALBASE}) | ${TAIL} -1 | ||||
. else | |||||
PYTHONBASE= ${LOCALBASE} | |||||
. endif | |||||
.endif | |||||
.endif | .endif | ||||
_EXPORTED_VARS+= PYTHONBASE | _EXPORTED_VARS+= PYTHONBASE | ||||
PYTHON_INCLUDEDIR= ${PYTHONBASE}/include/python${_PYTHON_VERSION}${PYTHON_ABIVER} | PYTHON_INCLUDEDIR= ${PYTHONBASE}/include/python${_PYTHON_VERSION}${PYTHON_ABIVER} | ||||
PYTHON_LIBDIR= ${PYTHONBASE}/lib/python${_PYTHON_VERSION} | PYTHON_LIBDIR= ${PYTHONBASE}/lib/python${_PYTHON_VERSION} | ||||
PYTHON_PLATFORM= ${OPSYS:tl}${OSREL:C/\.[0-9.]*//} | PYTHON_PLATFORM= ${OPSYS:tl}${OSREL:C/\.[0-9.]*//} | ||||
PYTHON_SITELIBDIR= ${PYTHON_LIBDIR}/site-packages | PYTHON_SITELIBDIR= ${PYTHON_LIBDIR}/site-packages | ||||
PYTHON_PKGNAMEPREFIX= py${PYTHON_SUFFIX}- | PYTHON_PKGNAMEPREFIX= py${PYTHON_SUFFIX}- | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |
Would it not be possible to export METAPY_INSTALLED_VERSION as _PYTHON_DEFAULT_VERSION (perhaps conditionally: ?=) and get the same behaviour without needing to patch this section? The same goes, I think, for PYTHON_BASE?