2014-08-09 17:44:27 +02:00
# Provide support for Python related ports. This includes detecting Python
# interpreters, ports providing package and modules for python as well as
# consumer ports requiring Python at build or run time.
#
# Feature: python
2019-07-03 09:31:01 +02:00
# Usage: USES=python[:version-spec][,arg,...]
2020-09-28 15:00:09 +02:00
# Valid ARGS: <version-spec>, patch, build, run, test, env
2019-07-03 09:31:01 +02:00
#
# version-spec Declarative specification for the Python version(s) the
# port supports. Subsets and ranges can be specified:
#
# * <version>
# * <minimum-version>-<maximum-version>
# * <minimum-version>+
# * -<maximum-version>
#
# Examples:
#
# USES=python:2.7 # Supports Python 2.7 Only
2021-12-31 13:57:46 +01:00
# USES=python:3.7+ # Supports Python 3.7 or later
# USES=python:3.7-3.9 # Supports Python 3.7 to 3.9
2020-10-12 15:52:42 +02:00
# USES=python:-3.8 # Supports Python up to 3.8
2021-12-31 13:57:46 +01:00
# USES=python # Supports 3.7+
2019-07-03 09:31:01 +02:00
#
# NOTE: <version-spec> should be as specific as possible, matching the versions
# upstream declares support for, without being incorrect. In particular,
2021-12-31 13:57:46 +01:00
# USES=python *without* a <version-spec> means 3.7+,
2021-02-04 15:35:22 +01:00
# including unreleased versions, which is probably incorrect.
2019-07-03 09:31:01 +02:00
#
# Not specifying a <version-spec> should only be used when a more specific
# <version-spec> cannot be specified due to syntax limitations, for
2021-12-31 13:57:46 +01:00
# example: 2.7,3.7-3.8, but even in this case, X.Y+ (2.7+), or -X.Y (-3.7)
2019-07-03 09:31:01 +02:00
# is preferred and likely more correct.
#
# patch Python is needed at patch time. Adds dependency to PATCH_DEPENDS.
# build Python is needed at build time. Adds dependency to BUILD_DEPENDS.
# run Python is needed at run time. Adds dependency to RUN_DEPENDS.
# test Python is needed at test time. Adds dependency to TEST_DEPENDS.
# env Does not depend on Python but needs the environment set up. This
# is mainly used when depending on flavored python ports, or when a
# correct PYTHON_CMD is required. It has the same effect as setting
2017-12-04 16:27:29 +01:00
# PYTHON_NO_DEPENDS.
2014-08-09 17:44:27 +02:00
#
2016-01-02 16:24:37 +01:00
# If build, run and test are omitted, Python will be added as BUILD_DEPENDS,
2018-01-25 13:36:54 +01:00
# RUN_DEPENDS and TEST_DEPENDS.
# patch is independant, it does not prevent the default build/run/test
# dependency.
# env or PYTHON_NO_DEPENDS can be set to not add any dependencies.
2014-08-09 17:44:27 +02:00
#
2019-01-16 16:13:51 +01:00
# Exported variables:
2014-08-09 17:44:27 +02:00
#
# PYTHON_VERSION - The chosen Python interpreter including the version,
2019-07-03 08:35:48 +02:00
# e.g. python2.7, python3.5, etc.
2014-08-09 17:44:27 +02:00
#
# Variables, which can be set by the port:
#
2014-08-14 19:04:30 +02:00
# USE_PYTHON - A list of additional features and functionality to
2014-08-09 17:44:27 +02:00
# enable. Supported features are:
#
# concurrent - Indicates that the port can be installed for
# different python versions at the same time. The port
# is supposed to use a unique prefix for certain
# directories using USES=uniquefiles:dirs (see the
# uniquefiles.mk Uses for details about the
# directories), if set to yes. Binaries receive an
# additional suffix, based on ${PYTHON_VER}.
#
# The values for the uniquefiles USES are set as
# follows:
#
# UNIQUE_PREFIX= ${PYTHON_PKGNAMEPREFIX}
# UNIQUE_SUFFIX= -${PYTHON_VER}
#
# If the port is installed for the current default
# python version, scripts and binaries in
#
# ${PREFIX}/bin
# ${PREFIX}/sbin
# ${PREFIX}/libexec
#
# are linked from the prefixed version to the
# prefix-less original name, e.g.
# bin/foo-2.7 --> bin/foo.
#
2017-11-30 16:50:30 +01:00
# cython - Depend on lang/cython at build-time.
#
# cython_run - Depend on lang/cython at run-time.
#
# flavors - Force creation of flavors for Python 2 and 3 default
# versions, where applicable.
#
# noflavors - Disable automatic creation of flavors if they would
# otherwise be created and they are not wanted.
#
# allflavors - Generate flavors for all possible versions and not
2018-01-22 20:59:31 +01:00
# simply the default ones. Only to be used for py-*
# ports that are part of the Python distribution, but
# kept as separate ports.
2017-11-30 16:50:30 +01:00
#
# optsuffix - Set PKGNAMESUFFIX to PYTHON_PKGNAMESUFFIX if not the
# default python version.
#
2014-08-09 17:44:27 +02:00
# distutils - Use distutils as do-configure, do-build and
2017-11-30 16:50:30 +01:00
# do-install targets. implies flavors.
2014-08-09 17:44:27 +02:00
#
# autoplist - Automatically generates the packaging list for a
# port that uses distutils when defined.
# requires: distutils
#
# py3kplist - Automatically generates Python 3.x compatible
# __pycache__ entries from a Python 2.x packaging list
# when defined. Use this for ports that do *not* use
# standard Python packaging mechanisms such as
# distutils, and support *both* Python 2.x and 3.x.
2014-08-14 19:04:30 +02:00
# Not needed, if USE_PYTHON=autoplist is set.
2014-08-09 17:44:27 +02:00
#
# pythonprefix - Says that the port installs in ${PYTHONBASE} instead
# of ${PREFIX}.
#
# noegginfo - Skip an egg-info entry from plist, if defined.
#
2022-06-03 18:56:59 +02:00
# nose - Run tests with nose (devel/py-nose)
#
# nose2 - Run tests with nose2 (devel/py-nose2)
#
# pytest - Run tests with latest pytest (devel/py-pytest)
#
# pytest4 - Run tests with pytest 4.x (devel/py-pytest4)
#
# unittest - Run tests with unittest
#
# unittest2 - Run tests with unittest2 (devel/py-unittest2)
#
2014-08-09 17:44:27 +02:00
# PYTHON_CMD - Python's command line file name, including the
# version number (used for dependencies).
# default: ${PYTHONBASE}/bin/${PYTHON_VERSION}
#
# PYSETUP - Name of the setup script used by the distutils
# package.
# default: setup.py
#
# PYDISTUTILS_PKGNAME
# - Internal name in the distutils for egg-info.
# default: ${PORTNAME}
#
# PYDISTUTILS_PKGVERSION
# - Internal version in the distutils for egg-info.
# default: ${PORTVERSION}
#
# PYDISTUTILS_CONFIGURE_TARGET
# - Pass this command to distutils on configure stage.
# default: config
#
# PYDISTUTILS_BUILD_TARGET
# - Pass this command to distutils on build stage.
# default: build
#
# PYDISTUTILS_INSTALL_TARGET
# - Pass this command to distutils on install stage.
# default: install
#
# PYDISTUTILS_CONFIGUREARGS
# - Arguments to config with distutils.
# default: <empty>
#
# PYDISTUTILS_BUILDARGS
# - Arguments to build with distutils.
# default: <empty>
#
# PYDISTUTILS_INSTALLARGS
# - Arguments to install with distutils.
# default: -c -O1 --prefix=${PREFIX} --single-version-externally-managed --root=${STAGEDIR}
#
# PYDISTUTILS_EGGINFO
# - Canonical name for egg-info.
# default: ${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info
#
2022-06-03 18:56:59 +02:00
# PYTEST_BROKEN_TESTS - Lists of 'pytest -k' patterns to skip tests which
# require fixing.
# default: <empty>
#
# PYTEST_IGNORED_TESTS - Lists of 'pytest -k' patterns to skip tests which are
# not expected to pass, e.g. requiring a database access.
# default: <empty>
#
2014-08-09 17:44:27 +02:00
# The following variables can be read by ports and must not be modified:
#
# PYTHONBASE - The installation prefix of the chosen Python
# interpreter, e.g. /usr/local
#
2021-04-09 15:28:59 +02:00
# PYTHON_DISTVERSION
# - Version number suitable for ${DISTVERSION}.
2014-08-09 17:44:27 +02:00
#
# PYTHON_PORTSDIR - The port directory of the chosen Python interpreter
#
# PYTHON_REL - The release number of the chosen Python interpreter
2021-04-10 01:15:37 +02:00
# without dots, e.g. 20706, 30401, ...
2014-08-09 17:44:27 +02:00
#
# PYTHON_SUFFIX - The major-minor release number of the chosen Python
2019-07-03 08:35:48 +02:00
# interpreter without dots, e.g. 27, 36, ...
2014-08-09 17:44:27 +02:00
# Used for prefixes and suffixes.
#
# PYTHON_MAJOR_VER - The major release version of the chosen Python
# interpreter, e.g. 2, 3, ...
#
# PYTHON_VER - The major-minor release version of the chosen Python
2021-12-31 13:57:46 +01:00
# interpreter, e.g. 2.7, 3.7, ...
2014-08-09 17:44:27 +02:00
#
# PYTHON_ABIVER - Additional ABI flags set by the chosen Python
# interpreter, e.g. md
#
# PYTHON_INCLUDEDIR - Location of the Python include files.
# default: ${PYTHONBASE}/include/${PYTHON_VERSION}
#
# PYTHON_LIBDIR - Base of the python library tree
# default: ${PYTHONBASE}/lib/${PYTHON_VERSION}
#
# PYTHON_SITELIBDIR - Location of the site-packages tree. Don't change,
# unless you know what you do.
# default: ${PYTHON_LIBDIR}/site-packages
#
# There are PREFIX-clean variants of the PYTHON_*DIR variables above.
# They are meant to be used by ports instead of the above variables, so the
2014-08-14 19:04:30 +02:00
# ports respect ${PREFIX} (unless USE_PYTHON=pythonprefix is specified).
2014-08-09 17:44:27 +02:00
#
# PYTHONPREFIX_INCLUDEDIR default: ${PREFIX}/include/${PYTHON_VERSION}
# PYTHONPREFIX_LIBDIR default: ${PREFIX}/lib/${PYTHON_VERSION}
# PYTHONPREFIX_SITELIBDIR default: ${PYTHONPREFIX_LIBDIR}/site-packages
#
# PYTHON_PLATFORM - Python's idea of the OS release.
# This is faked with ${OPSYS} and ${OSREL} until we
# find out how to delay defining a variable until
# after a certain target has been built.
#
# PYTHON_PKGNAMEPREFIX
# - Use this as a ${PKGNAMEPREFIX} to distinguish
# packages for different Python versions.
# default: py${PYTHON_SUFFIX}-
#
2019-04-27 20:27:43 +02:00
# PYTHON_PKGNAMESUFFIX
# - Use this as a ${PKGNAMESUFFIX} to distinguish
# packages for different Python versions.
# default: -py${PYTHON_SUFFIX}
#
2021-03-03 19:17:59 +01:00
# Using USES=python also will add some useful entries to PLIST_SUB:
2014-08-09 17:44:27 +02:00
#
# PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;}
# PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;}
# PYTHON_PLATFORM=${PYTHON_PLATFORM}
# PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;}
2017-01-07 22:42:28 +01:00
# PYTHON_SUFFIX=${PYTHON_SUFFIX}
2014-09-25 23:01:57 +02:00
# PYTHON_VER=${PYTHON_VER}
2016-01-02 18:30:28 +01:00
# PYTHON_VERSION=${PYTHON_VERSION}
2014-08-09 17:44:27 +02:00
#
2017-01-07 22:42:28 +01:00
# 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
2014-08-09 17:44:27 +02:00
#
# PYDISTUTILS_INSTALLNOSINGLE
# - Deprecated without replacement
#
2022-06-03 18:56:59 +02:00
# The following variables may be set by the user:
#
# PYTEST_ENABLE_ALL_TESTS - Enable tests skipped by PYTEST_BROKEN_TESTS
# and PYTEST_IGNORED_TESTS.
# PYTEST_ENABLE_BROKEN_TESTS - Enable tests skipped by PYTEST_BROKEN_TESTS.
# PYTEST_ENABLE_IGNORED_TESTS - Enable tests skipped by PYTEST_IGNORED_TESTS.
#
2014-08-09 17:44:27 +02:00
# MAINTAINER: python@FreeBSD.org
. i f ! d e f i n e d ( _ I N C L U D E _ U S E S _ P Y T H O N _ M K )
_INCLUDE_USES_PYTHON_MK = yes
# What Python version and what Python interpreters are currently supported?
2016-04-14 15:34:25 +02:00
# When adding a version, please keep the comment in
# Mk/bsd.default-versions.mk in sync.
2022-06-26 22:31:43 +02:00
_PYTHON_VERSIONS = 3.9 3.8 3.7 3.10 3.11 2.7 # preferred first
_PYTHON_PORTBRANCH = 3.9 # ${_PYTHON_VERSIONS:[1]}
2014-08-09 17:44:27 +02:00
_PYTHON_BASECMD = ${ LOCALBASE } /bin/python
2016-04-28 14:17:09 +02:00
_PYTHON_RELPORTDIR = lang/python
2014-08-09 17:44:27 +02:00
2019-04-18 15:16:44 +02:00
# List all valid USE_PYTHON features here
2022-08-22 03:39:08 +02:00
_VALID_PYTHON_FEATURES = allflavors autoplist concurrent cython cython_run \
2022-06-03 18:56:59 +02:00
distutils flavors noegginfo noflavors nose nose2 \
optsuffix py3kplist pytest pytest4 pythonprefix \
unittest unittest2
2019-04-18 15:16:44 +02:00
_INVALID_PYTHON_FEATURES =
2022-04-24 12:00:20 +02:00
. f o r v a r i n $ { U S E _ P Y T H O N }
. if empty(_VALID_PYTHON_FEATURES : M ${var })
2019-04-18 15:16:44 +02:00
_INVALID_PYTHON_FEATURES += ${ var }
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d f o r
. i f ! e m p t y ( _ I N V A L I D _ P Y T H O N _ F E A T U R E S )
2019-04-18 15:16:44 +02:00
IGNORE = uses unknown USE_PYTHON features: ${ _INVALID_PYTHON_FEATURES }
2022-04-24 12:00:20 +02:00
. e n d i f
2019-04-18 15:16:44 +02:00
2014-08-09 17:44:27 +02:00
# Make each individual feature available as _PYTHON_FEATURE_<FEATURENAME>
2022-04-24 12:00:20 +02:00
. f o r v a r i n $ { U S E _ P Y T H O N }
2017-11-30 16:50:30 +01:00
_PYTHON_FEATURE_${var : C /=.*$//:tu }= ${var :C /.*=//:S /, / /g }
2022-04-24 12:00:20 +02:00
. e n d f o r
2022-06-03 18:56:59 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T E S T ) & & d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T E S T 4 )
IGNORE = uses either USE_PYTHON = pytest or USE_PYTHON = pytest4, not both of them
. e n d i f
2014-08-09 17:44:27 +02:00
2017-11-30 16:50:30 +01:00
# distutils automatically generates flavors depending on the supported
# versions.
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ D I S T U T I L S )
2017-11-30 16:50:30 +01:00
_PYTHON_FEATURE_FLAVORS = yes
2022-04-24 12:00:20 +02:00
. e n d i f
2017-11-30 16:50:30 +01:00
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ N O F L A V O R S )
2017-11-30 16:50:30 +01:00
. u n d e f _ P Y T H O N _ F E A T U R E _ F L A V O R S
2022-04-24 12:00:20 +02:00
. e n d i f
2017-11-30 16:50:30 +01:00
2014-08-09 17:44:27 +02:00
# Make sure that no dependency or some other environment variable
# pollutes the build/run dependency detection
. u n d e f _ P Y T H O N _ B U I L D _ D E P
. u n d e f _ P Y T H O N _ R U N _ D E P
2016-01-02 16:24:37 +01:00
. u n d e f _ P Y T H O N _ T E S T _ D E P
2014-08-09 17:44:27 +02:00
_PYTHON_ARGS = ${ python_ARGS : S /,/ /g }
2022-04-24 12:00:20 +02:00
. if ${_PYTHON_ARGS : Mpatch }
2018-01-25 13:36:54 +01:00
_PYTHON_PATCH_DEP = yes
_PYTHON_ARGS := ${ _PYTHON_ARGS : Npatch }
2022-04-24 12:00:20 +02:00
. e n d i f
. if ${_PYTHON_ARGS : Mbuild }
2014-08-09 17:44:27 +02:00
_PYTHON_BUILD_DEP = yes
_PYTHON_ARGS := ${ _PYTHON_ARGS : Nbuild }
2022-04-24 12:00:20 +02:00
. e n d i f
. if ${_PYTHON_ARGS : Mrun }
2014-08-09 17:44:27 +02:00
_PYTHON_RUN_DEP = yes
_PYTHON_ARGS := ${ _PYTHON_ARGS : Nrun }
2022-04-24 12:00:20 +02:00
. e n d i f
. if ${_PYTHON_ARGS : Mtest }
2016-01-02 16:24:37 +01:00
_PYTHON_TEST_DEP = yes
_PYTHON_ARGS := ${ _PYTHON_ARGS : Ntest }
2022-04-24 12:00:20 +02:00
. e n d i f
. if ${_PYTHON_ARGS : Menv }
2017-12-04 16:27:29 +01:00
PYTHON_NO_DEPENDS = yes
_PYTHON_ARGS := ${ _PYTHON_ARGS : Nenv }
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
2016-01-02 16:24:37 +01:00
# The port does not specify a build, run or test dependency, assume all are
2014-08-09 17:44:27 +02:00
# required.
2022-04-24 12:00:20 +02:00
. i f ! d e f i n e d ( _ P Y T H O N _ B U I L D _ D E P ) & & ! d e f i n e d ( _ P Y T H O N _ R U N _ D E P ) & & \
2016-01-02 16:24:37 +01:00
!defined( _PYTHON_TEST_DEP) && !defined( PYTHON_NO_DEPENDS)
2014-08-09 17:44:27 +02:00
_PYTHON_BUILD_DEP = yes
_PYTHON_RUN_DEP = yes
2016-01-02 16:24:37 +01:00
_PYTHON_TEST_DEP = yes
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
2022-04-24 12:00:20 +02:00
. i f ${PYTHON2_DEFAULT} != ${ PYTHON_DEFAULT } && ${ PYTHON3_DEFAULT } != ${ PYTHON_DEFAULT }
2017-12-04 12:07:04 +01:00
WARNING += "PYTHON_DEFAULT must be a version present in PYTHON2_DEFAULT or PYTHON3_DEFAULT, if you want more Python flavors, set BUILD_ALL_PYTHON_FLAVORS in your make.conf"
2022-04-24 12:00:20 +02:00
. e n d i f
2017-12-04 12:07:04 +01:00
2022-04-24 12:00:20 +02:00
. i f ${_PYTHON_ARGS} = = 2.7
2022-01-18 11:53:52 +01:00
DEV_WARNING += "lang/python27 reached End of Life and will be removed somewhere in the future, please convert to a modern version of python"
2022-04-24 12:00:20 +02:00
. e l i f ${_PYTHON_ARGS} = = 2
2018-02-26 20:33:21 +01:00
DEV_ERROR += "USES=python:2 is no longer supported, use USES=python:2.7"
2022-04-24 12:00:20 +02:00
. e l i f ${_PYTHON_ARGS} = = 3
2021-12-31 13:57:46 +01:00
DEV_ERROR += "USES=python:3 is no longer supported, use USES=python:3.7+ or an appropriate version range"
2022-04-24 12:00:20 +02:00
. e n d i f # ${_PYTHON_ARGS} == 2.7
2014-08-09 17:44:27 +02:00
2018-01-21 11:51:29 +01:00
_PYTHON_VERSION := ${ PYTHON_DEFAULT }
2014-08-09 17:44:27 +02:00
2022-04-24 12:00:20 +02:00
. i f e m p t y ( _ P Y T H O N _ A R G S )
2021-12-31 13:57:46 +01:00
_PYTHON_ARGS = 3.7+
2022-04-24 12:00:20 +02:00
. e n d i f
2021-02-04 15:35:22 +01:00
2014-08-09 17:44:27 +02:00
# Validate Python version whether it meets the version restriction.
2021-04-10 01:16:29 +02:00
_PYTHON_VERSION_CHECK := ${ _PYTHON_ARGS : C /^([1-9] \. [1-9]?[0-9]) $/ \1 - \1 / }
_PYTHON_VERSION_MINIMUM_TMP := ${ _PYTHON_VERSION_CHECK : C /([1-9] \. [1-9]?[0-9])[-+].*/ \1 / }
_PYTHON_VERSION_MINIMUM := ${ _PYTHON_VERSION_MINIMUM_TMP : M [1-9].[0-9] } ${ _PYTHON_VERSION_MINIMUM_TMP : M [1-9].[1-9][0-9] }
_PYTHON_VERSION_MAXIMUM_TMP := ${ _PYTHON_VERSION_CHECK : C /.*-([1-9] \. [1-9]?[0-9])/ \1 / }
_PYTHON_VERSION_MAXIMUM := ${ _PYTHON_VERSION_MAXIMUM_TMP : M [1-9].[0-9] } ${ _PYTHON_VERSION_MAXIMUM_TMP : M [1-9].[1-9][0-9] }
2014-08-09 17:44:27 +02:00
2019-04-18 15:16:44 +02:00
# At this point we should have no argument left in ${_PYTHON_ARGS}
# except a version spec
2021-04-10 01:16:29 +02:00
_V1 = [ 1-9] .[ 0-9]
_V2 = [ 1-9] .[ 1-9] [ 0-9]
_PYTHON_ARGS := ${ _PYTHON_ARGS : N ${ _V1 } - ${ _V1 } : N ${ _V1 } - ${ _V2 } : N ${ _V2 } - ${ _V2 } : N ${ _V1 } : N ${ _V2 } : N ${ _V1 } + : N ${ _V2 } + : N - ${ _V1 } : N - ${ _V2 } }
2022-04-24 12:00:20 +02:00
. i f ! e m p t y ( _ P Y T H O N _ A R G S )
2019-04-18 15:16:44 +02:00
IGNORE = uses unknown USES = python arguments: ${ _PYTHON_ARGS }
2022-04-24 12:00:20 +02:00
. e n d i f
2019-04-18 15:16:44 +02:00
2021-04-10 01:16:29 +02:00
# Pattern to convert python versions (X.Y or X.YY) to comparable format X.YY
_VC = C/^( [ 1-9] \. ) ( [ 0-9] ) $$ /\1 0\2 /
2014-08-09 17:44:27 +02:00
. u n d e f _ P Y T H O N _ V E R S I O N _ N O N S U P P O R T E D
2022-04-24 12:00:20 +02:00
. if !empty(_PYTHON_VERSION_MINIMUM) && (${_PYTHON_VERSION : ${_VC }} < ${_PYTHON_VERSION_MINIMUM :${_VC }})
2014-08-09 17:44:27 +02:00
_PYTHON_VERSION_NONSUPPORTED = ${ _PYTHON_VERSION_MINIMUM } at least
2022-04-24 12:00:20 +02:00
. elif !empty(_PYTHON_VERSION_MAXIMUM) && (${_PYTHON_VERSION : ${_VC }} > ${_PYTHON_VERSION_MAXIMUM :${_VC }})
2014-08-09 17:44:27 +02:00
_PYTHON_VERSION_NONSUPPORTED = ${ _PYTHON_VERSION_MAXIMUM } at most
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
# If we have an unsupported version of Python, try another.
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ V E R S I O N _ N O N S U P P O R T E D )
2014-08-09 17:44:27 +02:00
. u n d e f _ P Y T H O N _ V E R S I O N
2022-04-24 12:00:20 +02:00
. f o r v e r i n $ { P Y T H O N 2 _ D E F A U L T } $ { P Y T H O N 3 _ D E F A U L T } $ { _ P Y T H O N _ V E R S I O N S }
2014-08-09 17:44:27 +02:00
__VER = ${ ver }
2022-04-24 12:00:20 +02:00
. i f ! d e f i n e d ( _ P Y T H O N _ V E R S I O N ) & & \
2014-08-09 17:44:27 +02:00
!( !empty( _PYTHON_VERSION_MINIMUM) && ( \
2021-04-10 01:16:29 +02:00
${ __VER : ${ _VC } } < ${ _PYTHON_VERSION_MINIMUM : ${ _VC } } ) ) && \
2014-08-09 17:44:27 +02:00
!( !empty( _PYTHON_VERSION_MAXIMUM) && ( \
2021-04-10 01:16:29 +02:00
${ __VER : ${ _VC } } > ${ _PYTHON_VERSION_MAXIMUM : ${ _VC } } ) )
2014-08-09 17:44:27 +02:00
_PYTHON_VERSION = ${ ver }
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d f o r
. i f ! d e f i n e d ( _ P Y T H O N _ V E R S I O N )
2014-08-09 17:44:27 +02:00
IGNORE = needs an unsupported version of Python
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d i f # defined(_PYTHON_VERSION_NONSUPPORTED)
2014-08-09 17:44:27 +02:00
2017-11-30 16:50:30 +01:00
# Automatically generates FLAVORS if empty
2022-04-24 12:00:20 +02:00
. i f e m p t y ( F L A V O R S ) & & d e f i n e d ( _ P Y T H O N _ F E A T U R E _ F L A V O R S )
2017-11-30 16:50:30 +01:00
. u n d e f _ V A L I D _ P Y T H O N _ V E R S I O N S
2022-04-24 12:00:20 +02:00
. f o r v e r i n $ { P Y T H O N _ D E F A U L T } $ { P Y T H O N 2 _ D E F A U L T } $ { P Y T H O N 3 _ D E F A U L T } $ { _ P Y T H O N _ V E R S I O N S }
2017-11-30 16:50:30 +01:00
__VER = ${ ver }
2022-04-24 12:00:20 +02:00
. i f ! ( ! e m p t y ( _ P Y T H O N _ V E R S I O N _ M I N I M U M ) & & ( \
2021-04-10 01:16:29 +02:00
${ __VER : ${ _VC } } < ${ _PYTHON_VERSION_MINIMUM : ${ _VC } } ) ) && \
2017-11-30 16:50:30 +01:00
!( !empty( _PYTHON_VERSION_MAXIMUM) && ( \
2021-04-10 01:16:29 +02:00
${ __VER : ${ _VC } } > ${ _PYTHON_VERSION_MAXIMUM : ${ _VC } } ) )
2022-04-24 12:00:20 +02:00
. if empty(_VALID_PYTHON_VERSIONS : M ${ver })
2017-11-30 16:50:30 +01:00
_VALID_PYTHON_VERSIONS += ${ ver }
2022-04-24 12:00:20 +02:00
. e n d i f
2017-11-30 16:50:30 +01:00
. e n d i f
2022-04-24 12:00:20 +02:00
. e n d f o r
2017-11-30 16:50:30 +01:00
# Get all possible flavors depending on version requirements
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ V A L I D _ P Y T H O N _ V E R S I O N S )
2017-11-30 16:50:30 +01:00
_ALL_PYTHON_FLAVORS = ${ _VALID_PYTHON_VERSIONS : S /.// : S /^/py/ }
2022-04-24 12:00:20 +02:00
. e l s e
2017-11-30 16:50:30 +01:00
_ALL_PYTHON_FLAVORS = ${ _PYTHON_VERSIONS : S /.// : S /^/py/ }
2022-04-24 12:00:20 +02:00
. e n d i f
2017-11-30 16:50:30 +01:00
# Decide how many flavors we want. By default, only generate the default
# versions.
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( B U I L D _ A L L _ P Y T H O N _ F L A V O R S ) | | d e f i n e d ( _ P Y T H O N _ F E A T U R E _ A L L F L A V O R S )
2017-11-30 16:50:30 +01:00
FLAVORS = ${ _ALL_PYTHON_FLAVORS }
2022-04-24 12:00:20 +02:00
. e l s e
. f o r _ v i n $ { P Y T H O N _ D E F A U L T } $ { P Y T H O N 2 _ D E F A U L T } $ { P Y T H O N 3 _ D E F A U L T }
2017-11-30 16:50:30 +01:00
_f = py${ _v : S /.// }
2022-04-24 12:00:20 +02:00
. if ${_ALL_PYTHON_FLAVORS : M ${_f }} && !${FLAVORS :M ${_f }}
. i f ! e m p t y ( F L A V O R S )
2017-12-04 12:07:07 +01:00
FLAVORS := ${ FLAVORS } ${ _f }
2022-04-24 12:00:20 +02:00
. e l s e
2018-02-06 21:49:09 +01:00
FLAVORS := ${ _f }
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d i f
. e n d f o r
. e n d i f
. i f ! e m p t y ( F L A V O R S ) & & e m p t y ( F L A V O R )
2017-11-30 16:50:30 +01:00
FLAVOR = ${ FLAVORS : [1] }
2022-04-24 12:00:20 +02:00
. e n d i f
2017-11-30 16:50:30 +01:00
. e n d i f
2022-04-24 12:00:20 +02:00
. if ${FLAVOR : Mpy [23][0-9]}${FLAVOR :Mpy [23][1-9][0-9]}
2017-11-30 16:50:30 +01:00
_PYTHON_VERSION = ${ FLAVOR : S /py// : C /(.)/ \1 ./ }
2022-04-24 12:00:20 +02:00
. e n d i f
2017-11-30 16:50:30 +01:00
2022-04-24 12:00:20 +02:00
. i f ! e m p t y ( F L A V O R ) & & ${_PYTHON_VERSION} != ${ PYTHON_DEFAULT }
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ O P T S U F F I X )
2017-12-04 12:26:47 +01:00
DEV_WARNING += "USE_PYTHON=optsuffix is deprecated, consider migrating to using unconditional PKGNAMESUFFIX or PKGNAMEPREFIX"
2017-11-30 16:50:30 +01:00
PKGNAMESUFFIX = ${ PYTHON_PKGNAMESUFFIX }
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d i f
2017-11-30 16:50:30 +01:00
# To avoid having dependencies with @ and empty flavor:
2017-12-14 14:48:58 +01:00
# _PYTHON_VERSION is either set by (first that matches):
# - If using Python flavors, from the current Python flavor
2021-12-31 13:57:46 +01:00
# - If using a version restriction (USES=python:3.7+), from the first
2017-12-14 14:48:58 +01:00
# acceptable default Python version.
# - From PYTHON_DEFAULT
PY_FLAVOR = py${ _PYTHON_VERSION : S /.// }
2017-11-30 16:50:30 +01:00
2020-01-09 14:33:01 +01:00
PYTHON_VERSION = python${ _PYTHON_VERSION }
2014-10-27 19:58:21 +01:00
2014-08-09 17:44:27 +02:00
# Got the correct python version, set some publicly accessible variables
PYTHON_VER = ${ _PYTHON_VERSION }
PYTHON_SUFFIX = ${ _PYTHON_VERSION : S /.//g }
PYTHON_MAJOR_VER = ${ PYTHON_VER : R }
PYTHON_REL = # empty
PYTHON_ABIVER = # empty
PYTHON_PORTSDIR = ${ _PYTHON_RELPORTDIR } ${ PYTHON_SUFFIX }
2020-12-24 14:14:02 +01:00
2015-11-09 19:52:19 +01:00
# Protect partial checkouts from Mk/Scripts/functions.sh:export_ports_env().
2022-04-24 12:00:20 +02:00
. i f ! d e f i n e d ( _ P O R T S _ E N V _ C H E C K ) | | e x i s t s ( $ { P O R T S D I R } / $ { P Y T H O N _ P O R T S D I R } )
2016-04-28 14:17:09 +02:00
. i n c l u d e "${PORTSDIR}/${PYTHON_PORTSDIR}/Makefile.version"
2022-04-24 12:00:20 +02:00
. e n d i f
2021-04-10 01:15:37 +02:00
# Create a 5 integer version string, prefixing 0 to the minor and patch
# tokens if it's a single character. Only use the the first 3 tokens of
2015-09-14 10:28:57 +02:00
# PORTVERSION to support pre-release versions (rc3, alpha4, etc) of
# any Python port (lang/pythonXY)
2021-04-09 15:28:59 +02:00
PYTHON_REL = ${ PYTHON_DISTVERSION : C /^([0-9]+ \. [0-9]+ \. [0-9]+).*/ \1 / : C / \. ([0-9]) $/.0 \1 / : C / \. ([0-9] \. [0-9]+)/.0 \1 / : S /.//g }
2014-08-09 17:44:27 +02:00
# Might be overridden by calling ports
PYTHON_CMD ?= ${ _PYTHON_BASECMD } ${ _PYTHON_VERSION }
2022-04-24 12:00:20 +02:00
. i f ${PYTHON_VER} != 2.7
. i f e x i s t s ( $ { P Y T H O N _ C M D } - c o n f i g )
2014-08-09 17:44:27 +02:00
PYTHON_ABIVER != ${ PYTHON_CMD } -config --abiflags
2022-04-24 12:00:20 +02:00
. e l i f $ { P Y T H O N _ R E L } < 3 0 8 0 0
2021-12-31 13:57:46 +01:00
# Default ABI flags for lang/python37 port
2016-06-25 21:51:32 +02:00
PYTHON_ABIVER = m
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d i f
2014-08-09 17:44:27 +02:00
2022-04-24 12:00:20 +02:00
. i f $ { P Y T H O N _ R E L } > = 3 0 8 0 7
2021-04-12 20:28:04 +02:00
PYTHON_EXT_SUFFIX = .cpython-${ PYTHON_SUFFIX }
2022-04-24 12:00:20 +02:00
. e l s e
2021-04-12 20:28:04 +02:00
PYTHON_EXT_SUFFIX = # empty
2022-04-24 12:00:20 +02:00
. e n d i f
2021-04-12 20:28:04 +02:00
2022-04-24 12:00:20 +02:00
. i f ${PYTHON_MAJOR_VER} = = 2
2020-05-06 13:53:56 +02:00
DEPRECATED ?= Uses Python 2.7 which is EOLed upstream
2022-04-24 12:00:20 +02:00
. e n d i f
2020-05-06 13:53:56 +02:00
2022-04-24 12:00:20 +02:00
. i f ! d e f i n e d ( P Y T H O N B A S E )
2014-08-09 17:44:27 +02:00
PYTHONBASE != ( ${ PYTHON_CMD } -c 'import sys; print(sys.prefix)' \
2> /dev/null || ${ ECHO_CMD } ${ LOCALBASE } ) | ${ TAIL } -1
2022-04-24 12:00:20 +02:00
. e n d i f
2015-10-19 23:10:56 +02:00
_EXPORTED_VARS += PYTHONBASE
2014-08-09 17:44:27 +02:00
2014-10-27 19:58:21 +01:00
PYTHON_INCLUDEDIR = ${ PYTHONBASE } /include/python${ _PYTHON_VERSION } ${ PYTHON_ABIVER }
PYTHON_LIBDIR = ${ PYTHONBASE } /lib/python${ _PYTHON_VERSION }
2014-08-09 17:44:27 +02:00
PYTHON_PLATFORM = ${ OPSYS : tl } ${ OSREL : C / \. [0-9.]*// }
PYTHON_SITELIBDIR = ${ PYTHON_LIBDIR } /site-packages
PYTHON_PKGNAMEPREFIX = py${ PYTHON_SUFFIX } -
PYTHON_PKGNAMESUFFIX = -py${ PYTHON_SUFFIX }
PYTHONPREFIX_INCLUDEDIR = ${ PYTHON_INCLUDEDIR : S ; ${ PYTHONBASE } ; ${ PREFIX } ; }
PYTHONPREFIX_LIBDIR = ${ PYTHON_LIBDIR : S ; ${ PYTHONBASE } ; ${ PREFIX } ; }
PYTHONPREFIX_SITELIBDIR = ${ PYTHON_SITELIBDIR : S ; ${ PYTHONBASE } ; ${ PREFIX } ; }
# Used for recording the installed files.
_PYTHONPKGLIST = ${ WRKDIR } /.PLIST.pymodtmp
# Ports bound to a certain python version SHOULD
# - use the PYTHON_PKGNAMEPREFIX
# - use directories using the PYTHON_PKGNAMEPREFIX
# - install binaries using the required PYTHON_VER, with
# the default python version creating a symlink to the original binary
# name (for staging-aware ports).
#
# What makes a port 'bound' to a certain python version?
# - it installs data into PYTHON_SITELIBDIR, PYTHON_INCLUDEDIR, ...
# - it links against libpython*.so
2014-08-14 19:04:30 +02:00
# - it uses USE_PYTHON=distutils
2014-08-09 17:44:27 +02:00
#
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ C Y T H O N )
2022-03-25 14:10:55 +01:00
BUILD_DEPENDS += cython-${ PYTHON_VER } :lang/cython@${ PY_FLAVOR }
2022-04-24 12:00:20 +02:00
. e n d i f
2017-11-30 16:50:30 +01:00
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ C Y T H O N _ R U N )
2022-03-25 14:10:55 +01:00
RUN_DEPENDS += cython-${ PYTHON_VER } :lang/cython@${ PY_FLAVOR }
2022-04-24 12:00:20 +02:00
. e n d i f
2017-11-30 16:50:30 +01:00
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ C O N C U R R E N T )
. if !defined(_PYTHON_FEATURE_FLAVORS) && (${_PYTHON_VERSION_MINIMUM : M 3*} | | ${_PYTHON_VERSION_MAXIMUM :M 2*})
2017-12-12 13:31:10 +01:00
DEV_WARNING += "USE_PYTHON=concurrent when only one of Python 2 or 3 is supported AND not using flavors does not make any sense"
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
_USES_POST += uniquefiles:dirs
2022-04-24 12:00:20 +02:00
. if defined(_PYTHON_FEATURE_FLAVORS) && ${FLAVOR} == ${FLAVORS : [1]}
2017-12-11 13:41:56 +01:00
UNIQUE_DEFAULT_LINKS = yes
2022-04-24 12:00:20 +02:00
. e l i f ! d e f i n e d ( _ P Y T H O N _ F E A T U R E _ F L A V O R S ) & & ${_PYTHON_VERSION} = = ${ PYTHON_DEFAULT }
2014-08-09 17:44:27 +02:00
UNIQUE_DEFAULT_LINKS = yes
2022-04-24 12:00:20 +02:00
. e l s e
2014-08-09 17:44:27 +02:00
UNIQUE_DEFAULT_LINKS = no
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
UNIQUE_PREFIX = ${ PYTHON_PKGNAMEPREFIX }
UNIQUE_SUFFIX = -${ PYTHON_VER }
2017-12-19 17:23:48 +01:00
UNIQUE_SUFFIX_TYPES += SUFFIX_MAN
UNIQUE_SUFFIX_MAN_WITH_EXT = .[ 1-9ln]
UNIQUE_SUFFIX_MAN_EXTRA_EXT = .gz
2014-08-09 17:44:27 +02:00
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ A U T O P L I S T )
2017-12-19 17:23:48 +01:00
_UNIQUE_FIND_SUFFIX_FILES = ${ SED } -e 's|^${PREFIX}/||' ${ _PYTHONPKGLIST } ${ TMPPLIST }
2022-04-24 12:00:20 +02:00
. e l s e
2017-12-19 17:23:48 +01:00
_UNIQUE_FIND_SUFFIX_FILES = ${ SED } -e 's|^${PREFIX}/||' ${ TMPPLIST } 2>/dev/null
2022-04-24 12:00:20 +02:00
. e n d i f
2017-12-19 17:23:48 +01:00
UNIQUE_FIND_SUFFIX_FILES += ${ _UNIQUE_FIND_SUFFIX_FILES } | \
${ EGREP } -he '^bin/.*$$|^sbin/.*$$|^libexec/.*$$'
UNIQUE_FIND_SUFFIX_MAN_FILES += ${ _UNIQUE_FIND_SUFFIX_FILES } | \
2020-01-15 21:34:16 +01:00
${ EGREP } -he '^man/man[1-9ln]/.*$$|^share/man/man[1-9ln]/.*$$'
2022-04-24 12:00:20 +02:00
. e n d i f # defined(_PYTHON_FEATURE_CONCURRENT)
2014-08-09 17:44:27 +02:00
_CURRENTPORT := ${ PKGNAMEPREFIX } ${ PORTNAME } ${ PKGNAMESUFFIX }
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ D I S T U T I L S ) & & \
2021-05-26 17:17:56 +02:00
${ _CURRENTPORT } != ${ PYTHON_PKGNAMEPREFIX } setuptools && \
${ _CURRENTPORT } != ${ PYTHON_PKGNAMEPREFIX } setuptools44
2022-04-24 12:00:20 +02:00
. i f ${PYTHON_VER} = = 2.7
2021-05-26 17:17:56 +02:00
BUILD_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } setuptools44>0:devel/py-setuptools44@${ PY_FLAVOR }
RUN_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } setuptools44>0:devel/py-setuptools44@${ PY_FLAVOR }
2022-04-24 12:00:20 +02:00
. e l s e
2022-07-13 02:19:31 +02:00
BUILD_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } setuptools>= 63.1.0:devel/py-setuptools@${ PY_FLAVOR }
RUN_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } setuptools>= 63.1.0:devel/py-setuptools@${ PY_FLAVOR }
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d i f
2014-08-09 17:44:27 +02:00
# distutils support
PYSETUP ?= setup.py
PYDISTUTILS_SETUP ?= -c \
" import sys; import setuptools; \
__file__ = '${PYSETUP}' ; sys.argv[ 0] = '${PYSETUP}' ; \
exec( compile( open( __file__, 'rb' ) .read( ) .replace( b'\\r\\n' , b'\\n' ) , __file__, 'exec' ) ) "
PYDISTUTILS_CONFIGUREARGS ?= # empty
PYDISTUTILS_BUILDARGS ?= # empty
PYDISTUTILS_INSTALLARGS ?= -c -O1 --prefix= ${ PREFIX }
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ D I S T U T I L S )
. i f ! d e f i n e d ( P Y D I S T U T I L S _ I N S T A L L N O S I N G L E )
2014-08-09 17:44:27 +02:00
PYDISTUTILS_INSTALLARGS += --single-version-externally-managed
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
PYDISTUTILS_INSTALLARGS += --root= ${ STAGEDIR }
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
PYDISTUTILS_INSTALLARGS := --record ${ _PYTHONPKGLIST } \
${ PYDISTUTILS_INSTALLARGS }
PYDISTUTILS_PKGNAME ?= ${ PORTNAME }
PYDISTUTILS_PKGVERSION ?= ${ PORTVERSION }
PYDISTUTILS_EGGINFO ?= ${ PYDISTUTILS_PKGNAME : C /[^A-Za-z0-9.]+/_/g } -${ PYDISTUTILS_PKGVERSION : C /[^A-Za-z0-9.]+/_/g } -py${ PYTHON_VER } .egg-info
PYDISTUTILS_EGGINFODIR ?= ${ STAGEDIR } ${ PYTHONPREFIX_SITELIBDIR }
2022-06-03 18:56:59 +02:00
# nose support
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ N O S E )
TEST_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } nose>= 0:devel/py-nose@${ PY_FLAVOR }
. e n d i f
# nose2 support
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ N O S E 2 )
TEST_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } nose2>= 0:devel/py-nose2@${ PY_FLAVOR }
. e n d i f
# pytest support
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T E S T )
TEST_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } pytest>= 7,1:devel/py-pytest@${ PY_FLAVOR }
. e l i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T E S T 4 )
TEST_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } pytest4>= 4.6,1:devel/py-pytest4@${ PY_FLAVOR }
. e n d i f
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T E S T ) | | d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T E S T 4 )
PYTEST_BROKEN_TESTS ?= # empty
PYTEST_IGNORED_TESTS ?= # empty
_PYTEST_SKIPPED_TESTS ?= # empty
. i f ! d e f i n e d ( P Y T E S T _ E N A B L E _ A L L _ T E S T S )
. i f ! d e f i n e d ( P Y T E S T _ E N A B L E _ B R O K E N _ T E S T S )
_PYTEST_SKIPPED_TESTS += ${ PYTEST_BROKEN_TESTS }
. e n d i f
. i f ! d e f i n e d ( P Y T E S T _ E N A B L E _ I G N O R E D _ T E S T S )
_PYTEST_SKIPPED_TESTS += ${ PYTEST_IGNORED_TESTS }
. e n d i f
. e n d i f # !defined(PYTEST_ENABLE_ALL_TESTS)
_PYTEST_FILTER_EXPRESSION = ${ _PYTEST_SKIPPED_TESTS : C /^(.)/and not \1 / : tW : C /^and // }
. e n d i f # defined(_PYTHON_FEATURE_PYTEST) || defined(_PYTHON_FEATURE_PYTEST4)
# unittest2 support
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ U N I T T E S T 2 )
TEST_DEPENDS += ${ PYTHON_PKGNAMEPREFIX } unittest2>= 0:devel/py-unittest2@${ PY_FLAVOR }
. e n d i f
2022-04-24 12:00:20 +02:00
. i f ! d e f i n e d ( _ P Y T H O N _ F E A T U R E _ N O E G G I N F O ) & & \
2014-08-09 17:44:27 +02:00
!defined( _PYTHON_FEATURE_AUTOPLIST) && \
2014-10-02 09:53:52 +02:00
defined( _PYTHON_FEATURE_DISTUTILS) && \
2014-08-09 17:44:27 +02:00
defined( PYTHON_REL)
2016-04-22 11:24:34 +02:00
_USES_stage += 933:add-plist-egginfo
add-plist-egginfo :
2022-04-24 12:00:20 +02:00
. f o r e g g i n f o i n $ { P Y D I S T U T I L S _ E G G I N F O }
2014-08-09 17:44:27 +02:00
if [ -d " ${ PYDISTUTILS_EGGINFODIR } / ${ egginfo } " ] ; then \
${ LS } ${ PYDISTUTILS_EGGINFODIR } /${ egginfo } | while read f; do \
2014-10-07 18:51:20 +02:00
${ ECHO_CMD } ${ PYDISTUTILS_EGGINFODIR : S ;^ ${ STAGEDIR } ${ PREFIX } /;; } /${ egginfo } /$$ { f} >> ${ TMPPLIST } ; \
2014-08-09 17:44:27 +02:00
done ; \
fi ;
2022-04-24 12:00:20 +02:00
. e n d f o r
. e n d i f
2014-08-09 17:44:27 +02:00
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ A U T O P L I S T ) & & d e f i n e d ( _ P Y T H O N _ F E A T U R E _ D I S T U T I L S )
2014-08-09 17:44:27 +02:00
_RELSITELIBDIR = ${ PYTHONPREFIX_SITELIBDIR : S ; ${ PREFIX } /;; }
_RELLIBDIR = ${ PYTHONPREFIX_LIBDIR : S ; ${ PREFIX } /;; }
2016-04-22 11:24:34 +02:00
_USES_stage += 934:add-plist-pymod
2014-08-09 17:44:27 +02:00
add-plist-pymod :
2020-09-01 17:34:25 +02:00
@${ SED } -e 's|^"\(.*\)"$$|\1|' \
-e 's|^${STAGEDIR}${PREFIX}/||' \
2014-08-09 17:44:27 +02:00
-e 's|^${PREFIX}/||' \
2014-09-03 17:49:09 +02:00
-e 's|^\(man/.*man[0-9]\)/\(.*\.[0-9]\)$$|\1/\2.gz|' \
2020-01-15 21:34:16 +01:00
-e 's|^\(share/man/.*man[0-9]\)/\(.*\.[0-9]\)$$|\1/\2.gz|' \
2014-09-25 23:01:57 +02:00
-e 's|[[:alnum:]|[:space:]]*/\.\./*||g; s|/\./|/|g' \
2014-08-09 17:44:27 +02:00
${ _PYTHONPKGLIST } | ${ SORT } >> ${ TMPPLIST }
2022-04-24 12:00:20 +02:00
. e l s e
. i f $ { P Y T H O N _ R E L } > = 3 0 2 0 0 & & d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y 3 K P L I S T )
2014-08-09 17:44:27 +02:00
# When Python version is 3.2+ we rewrite all the filenames
# of TMPPLIST that end with .py[co], so that they conform
2018-11-03 23:26:41 +01:00
# to PEP 3147 (see https://www.python.org/dev/peps/pep-3147/)
2018-11-25 18:11:52 +01:00
PYMAGICTAG = ${ PYTHON_CMD } -c 'import sys; print(sys.implementation.cache_tag)'
2016-04-22 11:24:34 +02:00
_USES_stage += 935:add-plist-python
add-plist-python :
2014-08-09 17:44:27 +02:00
@${ AWK } ' \
2015-09-14 14:26:28 +02:00
/\. 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} \
2014-08-09 17:44:27 +02:00
/^@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} \
{ print} \
' \
2019-04-25 17:21:51 +02:00
pc = "__pycache__" mt = " $$ ( ${ PYMAGICTAG } ) " pyo = "opt-1.pyc" \
2014-08-09 17:44:27 +02:00
${ TMPPLIST } > ${ TMPPLIST } .pyc_tmp
@${ MV } ${ TMPPLIST } .pyc_tmp ${ TMPPLIST }
2022-04-24 12:00:20 +02:00
. e n d i f # ${PYTHON_REL} >= 30200 && defined(_PYTHON_FEATURE_PY3KPLIST)
. e n d i f # defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS)
2014-08-09 17:44:27 +02:00
# Fix for programs that build python from a GNU auto* environment
CONFIGURE_ENV += PYTHON = " ${ PYTHON_CMD } "
2015-06-10 11:23:54 +02:00
# By default CMake picks up the highest available version of Python package.
# Enforce the version required by the port or the default.
CMAKE_ARGS += -DPython_ADDITIONAL_VERSIONS= ${ PYTHON_VER }
2014-08-09 17:44:27 +02:00
# Python 3rd-party modules
2017-11-30 16:50:30 +01:00
PYGAME = ${ PYTHON_PKGNAMEPREFIX } game>0:devel/py-game@${ PY_FLAVOR }
2022-07-06 04:42:48 +02:00
PYNUMPY = ${ PYTHON_PKGNAMEPREFIX } numpy>= 1.16,1<1.24,1:math/py-numpy@${ PY_FLAVOR }
2017-11-30 16:50:30 +01:00
# Common Python modules that can be needed but only for some versions of Python.
2022-04-24 12:00:20 +02:00
. i f $ { P Y T H O N _ R E L } < 3 0 5 0 0
. e l s e
2020-03-24 20:51:44 +01:00
PY_PILLOW = ${ PYTHON_PKGNAMEPREFIX } pillow>= 7.0.0:graphics/py-pillow@${ PY_FLAVOR }
2022-04-24 12:00:20 +02:00
. e n d i f
2019-05-31 12:00:20 +02:00
2022-04-24 12:00:20 +02:00
. i f ${PYTHON_VER} != ${ PYTHON_DEFAULT }
2021-09-16 04:15:43 +02:00
PY_MERCURIAL = ${ PYTHON_PKGNAMEPREFIX } mercurial>= 5.9:devel/mercurial@${ PY_FLAVOR }
2022-04-24 12:00:20 +02:00
. e l s e
2021-09-16 04:15:43 +02:00
PY_MERCURIAL = mercurial>= 5.9:devel/mercurial@${ PY_FLAVOR }
2022-04-24 12:00:20 +02:00
. e n d i f
2020-09-06 17:09:27 +02:00
2018-04-18 15:58:15 +02:00
CMAKE_ARGS += -DBOOST_PYTHON_SUFFIX:STRING= ${ PYTHON_SUFFIX }
2018-04-18 15:57:42 +02:00
PY_BOOST_LIB = boost_python${ PYTHON_SUFFIX }
2018-02-15 13:34:49 +01:00
PY_BOOST = lib${ PY_BOOST_LIB } .so:devel/boost-python-libs@${ PY_FLAVOR }
2014-08-09 17:44:27 +02:00
# dependencies
2022-04-24 12:00:20 +02:00
. f o r _ s t a g e i n P A T C H B U I L D R U N T E S T
. i f d e f i n e d ( _ P Y T H O N _ $ { _ s t a g e } _ D E P )
2018-01-25 13:36:54 +01:00
${_stage}_DEPENDS += ${ PYTHON_CMD } :${ PYTHON_PORTSDIR }
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d f o r
2014-08-09 17:44:27 +02:00
# set $PREFIX as Python's one
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T H O N P R E F I X )
2014-08-09 17:44:27 +02:00
PREFIX = ${ PYTHONBASE }
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
# Substitutions for pkg-plist
# Use a short form of the PYTHONPREFIX_*DIR variables; we don't need the
# base directory in the plist file.
PLIST_SUB += PYTHON_INCLUDEDIR = ${ PYTHONPREFIX_INCLUDEDIR : S ; ${ PREFIX } /;; } \
PYTHON_LIBDIR = ${ PYTHONPREFIX_LIBDIR : S ; ${ PREFIX } /;; } \
PYTHON_PLATFORM = ${ PYTHON_PLATFORM } \
PYTHON_SITELIBDIR = ${ PYTHONPREFIX_SITELIBDIR : S ; ${ PREFIX } /;; } \
2017-01-07 22:42:28 +01:00
PYTHON_SUFFIX = ${ PYTHON_SUFFIX } \
2020-12-24 14:14:02 +01:00
PYTHON_EXT_SUFFIX = ${ PYTHON_EXT_SUFFIX } \
2016-01-02 18:30:28 +01:00
PYTHON_VER = ${ PYTHON_VER } \
2017-01-07 22:42:28 +01:00
PYTHON_VERSION = ${ PYTHON_VERSION }
2022-04-24 12:00:20 +02:00
. i f $ { P Y T H O N _ R E L } < 3 0 0 0 0
2017-01-07 22:42:28 +01:00
PLIST_SUB += PYTHON2 = "" PYTHON3 = "@comment "
2022-04-24 12:00:20 +02:00
. e l s e
2017-01-07 22:42:28 +01:00
PLIST_SUB += PYTHON2 = "@comment " PYTHON3 = ""
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
_USES_POST += python
. e n d i f # _INCLUDE_USES_PYTHON_MK
. i f d e f i n e d ( _ P O S T M K I N C L U D E D ) & & ! d e f i n e d ( _ I N C L U D E _ U S E S _ P Y T H O N _ P O S T _ M K )
_INCLUDE_USES_PYTHON_POST_MK = yes
# py-distutils support
PYDISTUTILS_CONFIGURE_TARGET ?= config
PYDISTUTILS_BUILD_TARGET ?= build
PYDISTUTILS_INSTALL_TARGET ?= install
2022-04-24 12:00:20 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ D I S T U T I L S )
2014-08-09 17:44:27 +02:00
LDSHARED ?= ${ CC } -shared
MAKE_ENV += LDSHARED = " ${ LDSHARED } " PYTHONDONTWRITEBYTECODE = PYTHONOPTIMIZE =
2022-04-24 12:00:20 +02:00
. i f ! t a r g e t ( d o - c o n f i g u r e ) & & ! d e f i n e d ( H A S _ C O N F I G U R E ) & & ! d e f i n e d ( G N U _ C O N F I G U R E )
2014-08-09 17:44:27 +02:00
do-configure :
@( cd ${ BUILD_WRKSRC } ; ${ SETENV } ${ MAKE_ENV } ${ PYTHON_CMD } ${ PYDISTUTILS_SETUP } ${ PYDISTUTILS_CONFIGURE_TARGET } ${ PYDISTUTILS_CONFIGUREARGS } )
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
2022-04-24 12:00:20 +02:00
. i f ! t a r g e t ( d o - b u i l d )
2014-08-09 17:44:27 +02:00
do-build :
@( cd ${ BUILD_WRKSRC } ; ${ SETENV } ${ MAKE_ENV } ${ PYTHON_CMD } ${ PYDISTUTILS_SETUP } ${ PYDISTUTILS_BUILD_TARGET } ${ PYDISTUTILS_BUILDARGS } )
2022-04-24 12:00:20 +02:00
. e n d i f
2014-08-09 17:44:27 +02:00
2022-04-24 12:00:20 +02:00
. i f ! t a r g e t ( d o - i n s t a l l )
2014-08-09 17:44:27 +02:00
do-install :
@( cd ${ INSTALL_WRKSRC } ; ${ SETENV } ${ MAKE_ENV } ${ PYTHON_CMD } ${ PYDISTUTILS_SETUP } ${ PYDISTUTILS_INSTALL_TARGET } ${ PYDISTUTILS_INSTALLARGS } )
2022-04-24 12:00:20 +02:00
. e n d i f
. e n d i f # defined(_PYTHON_FEATURE_DISTUTILS)
2022-06-03 18:56:59 +02:00
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ N O S E )
. i f ! t a r g e t ( d o - t e s t )
do-test :
cd ${ TEST_WRKSRC } && ${ SETENV } ${ TEST_ENV } ${ PYTHON_CMD } -m nose ${ TEST_ARGS : NDESTDIR =* } -v
. e n d i f
. e n d i f # defined(_PYTHON_FEATURE_NOSE)
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ N O S E 2 )
. i f ! t a r g e t ( d o - t e s t )
do-test :
cd ${ TEST_WRKSRC } && ${ SETENV } ${ TEST_ENV } ${ PYTHON_CMD } -m nose2 ${ TEST_ARGS : NDESTDIR =* } -v
. e n d i f
. e n d i f # defined(_PYTHON_FEATURE_NOSE2)
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T E S T ) | | d e f i n e d ( _ P Y T H O N _ F E A T U R E _ P Y T E S T 4 )
. i f ! t a r g e t ( d o - t e s t )
do-test :
cd ${ TEST_WRKSRC } && ${ SETENV } ${ TEST_ENV } ${ PYTHON_CMD } -m pytest -k '${_PYTEST_FILTER_EXPRESSION}' -rs -v -o addopts = ${ TEST_ARGS : NDESTDIR =* }
. e n d i f
. e n d i f # defined(_PYTHON_FEATURE_PYTEST) || defined(_PYTHON_FEATURE_PYTEST4)
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ U N I T T E S T )
. i f ! t a r g e t ( d o - t e s t )
do-test :
cd ${ TEST_WRKSRC } && ${ SETENV } ${ TEST_ENV } ${ PYTHON_CMD } -m unittest ${ TEST_ARGS : NDESTDIR =* } -v
. e n d i f
. e n d i f # defined(_PYTHON_FEATURE_UNITTEST)
. i f d e f i n e d ( _ P Y T H O N _ F E A T U R E _ U N I T T E S T 2 )
. i f ! t a r g e t ( d o - t e s t )
do-test :
cd ${ TEST_WRKSRC } && ${ SETENV } ${ TEST_ENV } ${ PYTHON_CMD } -m unittest2 ${ TEST_ARGS : NDESTDIR =* } -v
. e n d i f
. e n d i f # defined(_PYTHON_FEATURE_UNITTEST2)
2014-08-09 17:44:27 +02:00
. e n d i f # defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_PYTHON_POST_MK)