UPDATE: lang/python 3.11.10 -> 3.12.8

This commit is contained in:
purplerain 2025-01-11 00:51:10 +00:00
parent 15bd75493d
commit 0bd916750b
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
20 changed files with 8535 additions and 9180 deletions

View file

@ -1,54 +1,37 @@
# python.port.mk - Xavier Santolaria <xavier@santolaria.net>
# This file is in the public domain.
# python.port.mk - This file is in the public domain.
# Xavier Santolaria <xavier@santolaria.net>
# Stuart Henderson <stu@spacehopper.org>
CATEGORIES += lang/python
# define the default versions
MODPY_DEFAULT_VERSION_2 = 2.7
MODPY_DEFAULT_VERSION_3 = 3.11
MODPY_DEFAULT_VERSION_3 = 3.12
MODPY_VERSION ?= ${MODPY_DEFAULT_VERSION_3}
# If switching to a new MODPY_DEFAULT_VERSION_3, say 3.x to 3.y:
# - All ports with PLISTs that depend on the Python version number
# must be REVISION-bumped.
# - Keep xenocara/share/mk/bsd.xorg.mk PYTHON_VERSION in sync
.if !defined(MODPY_VERSION)
FLAVOR ?=
. if !defined(FLAVORS) || !${FLAVORS:Mpython3} || ${FLAVOR:Mpython3}
# for standard "python3-flavoured" ports (normal for py-* modules),
# set the default MODPY_VERSION for the usual py3 version
MODPY_VERSION ?= ${MODPY_DEFAULT_VERSION_3}
. else
# for unflavoured "py2+py3" ports (again normal for py-* modules),
# set the default MODPY_VERSION for the usual py2 version
. if defined(FLAVORS) && ${FLAVORS:Mpython3}
MODPY_VERSION ?= ${MODPY_DEFAULT_VERSION_2}
. else
# ports which don't have a python3 FLAVOR are either old py2-only py-*
# modules, or are other ports which use Python (e.g. those which are
# intended as a standalone program rather than a py-* module).
# in that case, use the usual py3 version; old py2-only modules
# will set MODPY_VERSION themselves.
. endif
. endif
.endif
# - Keep xenocara/share/mk/bsd.xorg.mk PYTHON_VERSION in sync.
# verify if MODPY_VERSION found is correct
.if ${MODPY_VERSION} == "2.7"
_MODPY_SUBDIR = 2.7
.elif ${MODPY_VERSION} == "3.11"
.elif ${MODPY_VERSION} == "3.12"
_MODPY_SUBDIR = 3
.else
ERRORS += "Fatal: unknown or unsupported MODPY_VERSION: ${MODPY_VERSION}"
.endif
MODPY_WANTLIB = python${MODPY_VERSION}
MODPY_RUN_DEPENDS = lang/python/${_MODPY_SUBDIR}
MODPY_LIB_DEPENDS = lang/python/${_MODPY_SUBDIR}
_MODPY_BUILD_DEPENDS = lang/python/${_MODPY_SUBDIR}
MODPY_TKINTER_DEPENDS = lang/python/${_MODPY_SUBDIR},-tkinter
MODPY_MAJOR_VERSION = ${MODPY_VERSION:R}
.if ${MODPY_MAJOR_VERSION} == 2
MODPY_FLAVOR =
# use MODPY_BIN_SUFFIX for binaries to avoid conflict
MODPY_BIN_SUFFIX = -2
MODPY_PY_PREFIX = py-
MODPY_PYCACHE =
MODPY_PYC_MAGIC_TAG =
@ -56,10 +39,8 @@ MODPY_COMMENT = "@comment "
MODPY_ABI3SO =
MODPY_PYOEXTENSION = pyo
.elif ${MODPY_MAJOR_VERSION} == 3
# replace py- prefix by py3-
FULLPKGNAME ?= ${PKGNAME:S/^py-/py3-/}${FLAVOR_EXT:S/-python3//}
MODPY_FLAVOR = ,python3
MODPY_BIN_SUFFIX =
# replace py- prefix with py3-
FULLPKGNAME ?= ${PKGNAME:S/^py-/py3-/}${FLAVOR_EXT}
MODPY_PY_PREFIX = py3-
MODPY_PYCACHE = __pycache__/
MODPY_MAJORMINOR = ${MODPY_VERSION:C/\.//g}
@ -83,19 +64,9 @@ MODPY_PYTEST ?= No
MODPY_PYTEST ?= Yes
.endif
MODPY_WANTLIB = python${MODPY_VERSION}
MODPY_RUN_DEPENDS = lang/python/${_MODPY_SUBDIR}
MODPY_LIB_DEPENDS = lang/python/${_MODPY_SUBDIR}
_MODPY_BUILD_DEPENDS = lang/python/${_MODPY_SUBDIR}
.if ${MODPY_PYTEST:L} == "yes"
. if ${MODPY_VERSION} == ${MODPY_DEFAULT_VERSION_2}
NO_TEST = Yes
. else
MODPY_TEST_DEPENDS = ${RUN_DEPENDS}
MODPY_TEST_DEPENDS += devel/py-test${MODPY_FLAVOR}
. endif
MODPY_TEST_DEPENDS += devel/py-test
.else
MODPY_TEST_DEPENDS = ${MODPY_RUN_DEPENDS}
.endif
@ -126,30 +97,35 @@ TEST_DEPENDS += ${MODPY_TEST_DEPENDS}
_MODPY_PRE_BUILD_STEPS = :
.if ${MODPY_PYBUILD:L} == "no"
.if ${MODPY_PYBUILD:L} == "no" && ${MODPY_MAJOR_VERSION} != 2
# not necessarily an error, but try to draw attention to it. defer printing
# the warning to fake-install where it's less likely to scroll off the screen.
_MODPY_PRE_BUILD_STEPS += ; if [ -e ${WRKSRC}/pyproject.toml ] && \
grep -q ^build-backend ${WRKSRC}/pyproject.toml && \
! grep -q ^build-backend.*setuptools ${WRKSRC}/pyproject.toml; then \
printf "\n***\n\nOpenBSD ports: should this use MODPY_PYBUILD?\n"; \
grep ^build-backend ${WRKSRC}/pyproject.toml || true; \
printf "\n***\n\n"; fi
grep -q ^build-backend ${WRKSRC}/pyproject.toml; then \
(echo; echo '*** Ports with pyproject.toml should normally use MODPY_PYBUILD'; \
grep -H ^build-backend ${WRKSRC}/pyproject.toml; echo ) >> \
${WRKDIR}/.modpy-warn; \
fi
.endif
_MODPY_USE_CARGO = No
.if ${MODPY_SETUPTOOLS:L} == "yes"
. if ${MODPY_PYBUILD:L} != "no"
ERRORS += "Fatal: don't set both MODPY_PYBUILD and MODPY_SETUPTOOLS"
ERRORS += "Fatal: both MODPY_PYBUILD and MODPY_SETUPTOOLS are set. Just use MODPY_PYBUILD."
. endif
# For Python 2, setuptools provides a package locator that
# is required at runtime for the pkg_resources stuff to work
# For Python 3, normally importlib.metadata (in Python core
# in newer versions) or importlib_metadata (external module)
# are used in preference.
# For Python 2, setuptools provides a package locator that is required at
# runtime for pkg_resources to work, so an RDEP is needed.
# For Python 3, pkg_resources is deprecated - Python core has similar
# functionality in importlib.metadata.
# If a py3 port still needs pkg_resources, expect deprecation warnings
# at runtime, and in that case an RDEP on setuptools should be added
# manually.
. if ${MODPY_MAJOR_VERSION} == 2
MODPY_SETUPUTILS_DEPEND ?= devel/py2-setuptools
MODPY_RUN_DEPENDS += ${MODPY_SETUPUTILS_DEPEND}
. else
MODPY_SETUPUTILS_DEPEND ?= devel/py-setuptools${MODPY_FLAVOR}
MODPY_SETUPUTILS_DEPEND ?= devel/py-setuptools
. endif
BUILD_DEPENDS += ${MODPY_SETUPUTILS_DEPEND}
@ -158,51 +134,66 @@ MODPY_SETUPUTILS = Yes
# The setuptools uses test target
TEST_TARGET ?= test
_MODPY_USERBASE =
_MODPY_PRE_BUILD_STEPS += ;[ -e ${WRKSRC}/${MODPY_SETUP} ] || \
( printf '%s\n%s\n' \
'\# generated by python.port.mk' \
'from setuptools import setup; setup()' \
> ${WRKSRC}/${MODPY_SETUP}; \
echo '*** generating minimal setup.py; consider using MODPY_PYBUILD')
_MODPY_PRE_BUILD_STEPS += ;${MODPY_CMD} egg_info || true
# Setuptools opportunistically picks up plugins. If it picks one up that
# uses finalize_distribution_options (usually setuptools_scm), junking
# that plugin will cause failure at the end of build.
# In the absence of a targetted means of disabling this, use a big hammer:
DPB_PROPERTIES += nojunk
.elif ${MODPY_PYBUILD:L} != no
BUILD_DEPENDS += devel/py-build${MODPY_FLAVOR} \
devel/py-installer${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-build \
devel/py-installer
. if ${MODPY_PYBUILD} == flit
BUILD_DEPENDS += devel/py-flit${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-flit
. elif ${MODPY_PYBUILD} == flit_core
BUILD_DEPENDS += devel/py-flit_core${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-flit_core
. elif ${MODPY_PYBUILD} == flit_scm
BUILD_DEPENDS += devel/py-flit_scm${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-flit_scm
. elif ${MODPY_PYBUILD} == hatch-vcs
BUILD_DEPENDS += devel/py-hatch-vcs${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-hatch-vcs
_MODPY_EXPECTED_BACKEND = hatchling
. elif ${MODPY_PYBUILD} == hatchling
BUILD_DEPENDS += devel/py-hatchling${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-hatchling
. elif ${MODPY_PYBUILD} == jupyter_packaging
BUILD_DEPENDS += devel/py-jupyter_packaging${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-jupyter_packaging
_MODPY_EXPECTED_BACKEND = setuptools
. elif ${MODPY_PYBUILD} == maturin
BUILD_DEPENDS += devel/maturin
MODCARGO_CARGO_BIN = maturin
_MODPY_WHEELSDIR = target/wheels
_MODPY_USE_CARGO = Yes
. elif ${MODPY_PYBUILD} == mesonpy
BUILD_DEPENDS += devel/meson-python
. elif ${MODPY_PYBUILD} == pbr
BUILD_DEPENDS += devel/py-pbr \
devel/py-setuptools \
devel/py-wheel
. elif ${MODPY_PYBUILD} == pdm
BUILD_DEPENDS += devel/py-pdm-backend${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-pdm-backend
. elif ${MODPY_PYBUILD} == poetry-core
BUILD_DEPENDS += devel/py-poetry-core${MODPY_FLAVOR}
. elif ${MODPY_PYBUILD} == setuptools || ${MODPY_PYBUILD} == setuptools_scm
BUILD_DEPENDS += devel/py-setuptools${MODPY_FLAVOR} \
devel/py-wheel${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-poetry-core
_MODPY_EXPECTED_BACKEND = poetry.core
. elif ${MODPY_PYBUILD} == setuptools || \
${MODPY_PYBUILD} == setuptools_scm || \
${MODPY_PYBUILD} == setuptools-rust
BUILD_DEPENDS += devel/py-setuptools \
devel/py-wheel
_MODPY_EXPECTED_BACKEND = setuptools
. if ${MODPY_PYBUILD} == setuptools_scm
BUILD_DEPENDS += devel/py-setuptools_scm${MODPY_FLAVOR}
BUILD_DEPENDS += devel/py-setuptools_scm
. elif ${MODPY_PYBUILD} == setuptools-rust
BUILD_DEPENDS += devel/py-setuptools-rust
_MODPY_USE_CARGO = Yes
. endif
. elif !${MODPY_PYBUILD:L:Mother}
ERRORS += "Fatal: unknown MODPY_PYBUILD value (flit, flit_core, flit_scm, hatch-vcs, hatchling, jupyter_packaging, pdm, maturin, other, poetry-core, setuptools, setuptools_scm)"
ERRORS += "Fatal: unknown MODPY_PYBUILD value (flit, flit_core, flit_scm, hatch-vcs, hatchling, jupyter_packaging, pbr, pdm, maturin, mesonpy, other, poetry-core, setuptools, setuptools_scm, setuptools-rust)"
. endif
_MODPY_EXPECTED_BACKEND ?= ${MODPY_PYBUILD}
_MODPY_WHEELSDIR ?= dist
. if ${_MODPY_USE_CARGO:L} == yes
MODCARGO_INSTALL ?= No
MODCARGO_TEST ?= No
MODULES += devel/cargo
. endif
.else
# Try to detect the case where a port will build regardless of setuptools
# but the final plist will be different if it's present.
MODPY_SETUPUTILS = No
# Detect the case where a port is capable of building with setup.py
# via fallback to distutils, but should use py-build instead.
_MODPY_SETUPUTILS_FAKE_DIR = \
${WRKDIR}/lib/python${MODPY_VERSION}/site-packages/setuptools
_MODPY_PRE_BUILD_STEPS += \
@ -210,23 +201,35 @@ _MODPY_PRE_BUILD_STEPS += \
;exec 3>&1 \
;exec >${_MODPY_SETUPUTILS_FAKE_DIR}/__init__.py \
;echo 'def setup(*args, **kwargs):' \
;echo ' msg = "OpenBSD ports: MODPY_PYBUILD or MODPY_SETUPTOOLS is required"' \
;echo ' msg = "SecBSD ports: use MODPY_PYBUILD"' \
;echo ' raise Exception(msg)' \
;echo 'Extension = Feature = find_packages = setup' \
;exec 1>&3
MODPY_SETUPUTILS = No
_MODPY_USERBASE = ${WRKDIR}
.endif
# XXX If we run into too many problems with setuptools ports and junking
# XXX then this can be enabled, however if a "nojunk" port fails to build,
# XXX DPB will no longer junk on that node, likely resulting in running
# XXX out of disk space in /usr/local. So far it has only happened very
# XXX occasionally and a single port failure is easier to clean up, and
# XXX setuptools use is decreasing, so trying to avoid this!
#
#.if ${MODPY_SETUPTOOLS:L} == "yes" || ${MODPY_PYBUILD:Msetuptools*}
# Setuptools opportunistically picks up plugins. If it picks one up that
# uses finalize_distribution_options (usually setuptools_scm), junking
# that plugin will cause failure at the end of build.
# In the absence of a targetted means of disabling this, use a big hammer:
#DPB_PROPERTIES += nojunk
#.endif
.if ${MODPY_PI:L} == "yes"
_MODPY_EGG_NAME = ${DISTNAME:S/-${MODPY_EGG_VERSION}//}
_MODPY_EGG_NAME = ${DISTNAME:S/-${MODPY_DISTV}//}
MODPY_PI_DIR ?= ${DISTNAME:C/^([a-zA-Z0-9]).*/\1/}/${_MODPY_EGG_NAME}
SITES = ${SITE_PYPI:=${MODPY_PI_DIR}/}
HOMEPAGE ?= https://pypi.python.org/pypi/${_MODPY_EGG_NAME}
.endif
MODPY_TKINTER_DEPENDS = lang/python/${_MODPY_SUBDIR},-tkinter
MODPY_BIN = ${LOCALBASE}/bin/python${MODPY_VERSION}
MODPY_INCDIR = ${LOCALBASE}/include/python${MODPY_VERSION}
MODPY_LIBDIR = ${LOCALBASE}/lib/python${MODPY_VERSION}
@ -266,7 +269,7 @@ MODPY_TEST_CMD = cd ${MODPY_TEST_DIR} && ${SETENV} ${ALL_TEST_ENV} ${MODPY_BIN}
.if ${MODPY_PYTEST:L} == "yes"
MODPY_PYTEST_USERARGS ?=
MODPY_TEST_CMD += -m pytest ${MODPY_PYTEST_USERARGS}
MODPY_TEST_LIBDIR ?= ${WRKSRC}/build/lib:${WRKSRC}/build/lib.openbsd-${OSREV}-${ARCH}-cpython-${MODPY_MAJORMINOR}:${WRKSRC}/lib.openbsd-${OSREV}-${ARCH}-${MODPY_VERSION}
MODPY_TEST_LIBDIR ?= ${WRKINST}${MODPY_SITEPKG}:${WRKSRC}/build/lib:${WRKSRC}/build/lib.openbsd-${OSREV}-${ARCH}-cpython-${MODPY_MAJORMINOR}:${WRKSRC}/lib.openbsd-${OSREV}-${ARCH}-${MODPY_VERSION}
.else
MODPY_TEST_CMD += ./${MODPY_SETUP} ${MODPY_SETUP_ARGS}
.endif
@ -280,10 +283,10 @@ TEST_ENV += PYTHONPATH=${MODPY_TEST_LIBDIR}:lib:src
.endif
SUBST_VARS := MODPY_PYCACHE MODPY_COMMENT MODPY_ABI3SO MODPY_PYC_MAGIC_TAG \
MODPY_BIN MODPY_EGG_VERSION MODPY_VERSION MODPY_BIN_SUFFIX \
MODPY_BIN MODPY_DISTV MODPY_VERSION \
MODPY_PY_PREFIX MODPY_PYOEXTENSION ${SUBST_VARS}
UPDATE_PLIST_ARGS += -S MODPY_BIN_SUFFIX -S MODPY_PYOEXTENSION \
UPDATE_PLIST_ARGS += -S MODPY_PYOEXTENSION \
-I MODPY_ABI3SO -c MODPY_COMMENT -I MODPY_PYCACHE
# set MODPY_BIN for executable scripts
@ -303,12 +306,34 @@ MODPY_COMPILEALL = ${MODPY_BIN} -m compileall
MODPY_COMPILEALL = ${MODPY_BIN} -m compileall -j ${MAKE_JOBS} -s ${WRKINST} -o 0 -o 1
.endif
MODPY_TEST_TARGET =
MODPY_TEST_LINK_SO ?= No
.if ${MODPY_TEST_LINK_SO:L} == "yes" && !empty(MODPY_TEST_LIBDIR)
MODPY_TEST_SO_CMD = for _dir in ${MODPY_TEST_LIBDIR:S,:, ,g}; do \
if [ -d $${_dir} ]; then \
cd $${_dir} && \
find . -name '*.so' -type f \
-exec ln -sf $${_dir}/{} ${WRKSRC}/{} \; ;\
fi; done
MODPY_TEST_TARGET += ${MODPY_TEST_SO_CMD};
.endif
.if ${MODPY_PYBUILD:L} != no
. if ! ${MODPY_PYBUILD:Msetuptools_scm}
_MODPY_PRE_BUILD_STEPS += ; if [ -e ${WRKSRC}/pyproject.toml ]; then \
grep -q '^requires.*setuptools_scm' ${WRKSRC}/pyproject.toml && \
echo && sleep 1 && \
echo "*** Port appears to require setuptools_scm" && sleep 2; \
_MODPY_PRE_BUILD_STEPS += ; if [ -e ${WRKSRC}/pyproject.toml ] && \
grep -q '^requires.*setuptools[-_]scm' ${WRKSRC}/pyproject.toml; then \
(echo; echo '*** Port may need MODPY_PYBUILD=setuptools_scm'; \
grep -H -e ^build-backend -e '^requires.*setuptools' \
${WRKSRC}/pyproject.toml; echo ) >> ${WRKDIR}/.modpy-warn; \
fi
. endif
. if ${_MODPY_EXPECTED_BACKEND} != other
_MODPY_PRE_BUILD_STEPS += ; if [ -e ${WRKSRC}/pyproject.toml ] && \
grep '^build-backend' ${WRKSRC}/pyproject.toml | \
grep -qv ${_MODPY_EXPECTED_BACKEND}; then \
(echo; echo '*** Check MODPY_PYBUILD setting (currently "${MODPY_PYBUILD}")'; \
grep -H ^build-backend ${WRKSRC}/pyproject.toml; echo ) >> \
${WRKDIR}/.modpy-warn; \
fi
. endif
MODPY_PYBUILD_ARGS ?=
@ -316,8 +341,8 @@ MODPY_BUILD_TARGET = ${_MODPY_PRE_BUILD_STEPS}; \
${_MODPY_RUNBIN} -sBm build -w --no-isolation ${MODPY_PYBUILD_ARGS}
MODPY_INSTALL_TARGET = \
${INSTALL_DATA_DIR} ${WRKINST}${MODPY_LIBDIR}; \
${_MODPY_RUNBIN} -m installer -d ${WRKINST} ${WRKSRC}/dist/*.whl
MODPY_TEST_TARGET = ${MODPY_TEST_CMD}
${_MODPY_RUNBIN} -m installer -d ${WRKINST} ${WRKSRC}/${_MODPY_WHEELSDIR}/*.whl
MODPY_TEST_TARGET += ${MODPY_TEST_CMD}
. if ${MODPY_PYTEST:L} == "yes"
MODPY_TEST_TARGET += ${MODPY_PYTEST_ARGS}
. endif
@ -328,7 +353,7 @@ MODPY_INSTALL_TARGET = \
${MODPY_CMD} ${MODPY_DISTUTILS_BUILD} ${MODPY_DISTUTILS_BUILDARGS} \
${MODPY_DISTUTILS_INSTALL} ${MODPY_DISTUTILS_INSTALLARGS}
MODPY_TEST_TARGET = ${MODPY_TEST_CMD}
MODPY_TEST_TARGET += ${MODPY_TEST_CMD}
. if ${MODPY_PYTEST:L} == "yes"
MODPY_TEST_TARGET += ${MODPY_PYTEST_ARGS}
. elif ${MODPY_SETUPUTILS:L} == "yes"
@ -336,11 +361,22 @@ MODPY_TEST_TARGET += ${TEST_TARGET}
. endif
.endif
# dirty way to do it with no modifications in bsd.port.mk
MODPY_INSTALL_TARGET += ; if [ -r ${WRKDIR}/.modpy-warn ]; then cat ${WRKDIR}/.modpy-warn; fi
.if empty(CONFIGURE_STYLE)
. if !target(do-configure) && ${_MODPY_USE_CARGO:L} == yes
do-configure:
@${MODCARGO_configure}
. endif
. if !target(do-build)
do-build:
. if ${_MODPY_USE_CARGO:L} == yes
@${MODCARGO_BUILD_TARGET}
. endif
. if ${MODPY_PYBUILD} != maturin
@${MODPY_BUILD_TARGET}
. endif
. endif
# extra documentation or scripts should be installed via post-install
@ -349,20 +385,10 @@ do-install:
@${MODPY_INSTALL_TARGET}
. endif
# setuptools supports regress testing from setup.py using a standard target,
# though this is deprecated and in most cases MODPY_PYTEST should be used
# (possibly with MODPY_PYTEST_ARGS pointed at test dirs/files if the automatic
# search picks up files in lib/).
. if !target(do-test) && \
(${MODPY_SETUPUTILS:L} == "yes" || ${MODPY_PYTEST:L} == "yes")
do-test:
@${MODPY_TEST_TARGET}
. endif
. if make(update-plist) || make(plist)
. if defined(FLAVORS) && ${FLAVORS:Mpython3} && !${FLAVOR:Mpython3}
ERRORS += "***\n*** WARNING: running update-plist without FLAVOR=python3\n***\n***"
. endif
. endif
.endif