From nobody Wed Jan 11 05:22:43 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NsGKJ2BxRz2p4vl; Wed, 11 Jan 2023 05:22:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NsGKJ1TNkz44qW; Wed, 11 Jan 2023 05:22:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673414564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sRNLBdSdqM7syz2c3Wsb6k5kupf2YqPKD1zY6aMFdqg=; b=BQM2VbETkYd68MCmQjKYRbmbg2ZbdWK0/9UdRVwwIweVp4tFkah7njJntrWkB2HhkQkqqm uljbdfr8Q9VWVGMrc94yafiql6B9wozzSOzbbEJcbvVJMQ5oAYLpNzotsJ4ryNAI4e0kdY EDKQJluNiCcn7F7/U2NvDrUD5DDhI8DZs1svsg0eweP0CUm3mSRYKmXQtDLhvt6E1gz/PQ doWimkAPeCOfW1xq2D5GpvidBUjXcIKQPgjPqlCCBalslYBnuzBeEp0BRkGrex1InzslVI zP6r9unkr5CybkXEcxxcKsqAr/FbpjHOF3Qz5F2Cmgwrvt1jgZ9rOpHdgv2pOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673414564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sRNLBdSdqM7syz2c3Wsb6k5kupf2YqPKD1zY6aMFdqg=; b=jT23HJTIWioR9+qS3RmyQjRuy2IZbVmRN1IcInIr9WMIiWupGiHmEaDqXkeYyH1o5bpEDR SDP60wyL4Ti7uNoL90wpl1FBjOw7JE0s4qElPIF7v+JtttvbHbFxVj4I8vxl++0bvb2f7/ zA8r+BpyoloSFKlRy6572In8xiQJQ34NPhBELMoN+96GiZP1wCto7cCx6VTYQ9i/hJb4L5 yJBjMN5nC5tkUQADoRGmcoiRJmyXkkZxdoiTzAcrzF8kzhhwfUI9+zp0iZSZkoW4yEfFKF gghjRafoRzBMQLKhGzp/6uA+l0EofoT04NNbvAwv1W5AJF/ETSdnegVAB46mtQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673414564; a=rsa-sha256; cv=none; b=WC8Zr0HI89X0uJxzxUtXcbwlNT6qxYpBvip03A0U0dhLUr3zkPlyEd4K0HzxhgJnxoZjxw NhZw3z/rO5dEozJLFu7tdMyNjzKquGDdXEsCqF86YHwz7kHpJv3gcR23vGYlqaZYkBeB+W 5ahchlrIGZk6j7XyVHHFXt2xLviapgUfqZk7+6NmVlKCQ87egdza1l8G1MrVSosaSZkfQf ori3KMbalOuubDrcKd2eJ6vZnqCEencAspaBUSjOC7LnrqxkM+Ix8b+vLq3gcaRJyJ34Le gBmmPvkX9AUmxg70kMmeyPQIQjXUYtOHZDOz9zSgw2iGkMdYOR/dWtaEAgK+1w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NsGKJ0RtSzcMV; Wed, 11 Jan 2023 05:22:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30B5MhMq022304; Wed, 11 Jan 2023 05:22:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30B5Mhj2022303; Wed, 11 Jan 2023 05:22:43 GMT (envelope-from git) Date: Wed, 11 Jan 2023 05:22:43 GMT Message-Id: <202301110522.30B5Mhj2022303@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Charlie Li Subject: git: cc8a1878e024 - main - python.mk: introduce USE_PYTHON=pep517 for PEP-517 support List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vishwin X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cc8a1878e0242055ab6a8c20d33654451f78720e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by vishwin: URL: https://cgit.FreeBSD.org/ports/commit/?id=cc8a1878e0242055ab6a8c20d33654451f78720e commit cc8a1878e0242055ab6a8c20d33654451f78720e Author: Charlie Li AuthorDate: 2022-11-16 23:31:40 +0000 Commit: Charlie Li CommitDate: 2023-01-11 05:22:16 +0000 python.mk: introduce USE_PYTHON=pep517 for PEP-517 support USE_PYTHON=pep517 takes no arguments. Operation is similar to USE_PYTHON=distutils, although the build backend specified in pyproject.toml is to be specified in BUILD_DEPENDS explicitly. A usage guide and implementation primer is available at: https://wiki.freebsd.org/Python/PEP-517 With hat: python Approved by: fluffy (mentor) Co-authored by: yuri PR: 255722 Differential Revision: https://reviews.freebsd.org/D36290 --- CHANGES | 13 ++++++++++ Mk/Uses/python.mk | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 35c4205aee0b..2c65d5dbbe11 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,19 @@ in the release notes and/or placed into UPDATING. All ports committers are allowed to commit to this file. +20230111: +AUTHOR: vishwin@FreeBSD.org + + USE_PYTHON=pep517 has been added to facilitate building using the + new format. + + USE_PYTHON=pep517 takes no arguments. Operation is similar to + USE_PYTHON=distutils, although the build backend specified in + pyproject.toml shall be specified in BUILD_DEPENDS. + + A usage guide and implementation primer is available at: + https://wiki.freebsd.org/Python/PEP-517 + 20221217: AUTHOR: tcberner@FreeBSD.org diff --git a/Mk/Uses/python.mk b/Mk/Uses/python.mk index fa7c7b7b7084..5f9bf0455f0a 100644 --- a/Mk/Uses/python.mk +++ b/Mk/Uses/python.mk @@ -103,6 +103,9 @@ # distutils - Use distutils as do-configure, do-build and # do-install targets. implies flavors. # +# pep517 - Follow the PEP-517 standard to build and install wheels +# as do-build and do-install targets. implies flavors. +# # autoplist - Automatically generates the packaging list for a # port that uses distutils when defined. # requires: distutils @@ -175,6 +178,18 @@ # - 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 # +# PEP517_BUILD_CMD - Command sequence for a PEP-517 build frontend that builds a wheel. +# default: ${PYTHON_CMD} -m build -n -w +# +# PEP517_BUILD_DEPEND - Port needed to execute ${PEP517_BUILD_CMD}. +# default: ${PYTHON_PKGNAMEPREFIX}build>0:devel/py-build@${PY_FLAVOR} +# +# PEP517_INSTALL_CMD - Command sequence for a PEP-517 install frontend that installs a wheel. +# default: ${PYTHON_CMD} -m installer -d ${STAGEDIR} --no-compile-bytecode ${BUILD_WRKSRC}/dist/${PORTNAME}-${PORTVERSION}-*.whl +# +# PEP517_INSTALL_DEPEND - Port needed to execute ${PEP517_INSTALL_CMD}. +# default: ${PYTHON_PKGNAMEPREFIX}installer>0:devel/py-installer@${PY_FLAVOR} +# # PYTEST_BROKEN_TESTS - Lists of 'pytest -k' patterns to skip tests which # require fixing. # default: @@ -283,7 +298,7 @@ _PYTHON_RELPORTDIR= lang/python # List all valid USE_PYTHON features here _VALID_PYTHON_FEATURES= allflavors autoplist concurrent cython cython_run \ distutils flavors noegginfo noflavors nose nose2 \ - optsuffix py3kplist pytest pytest4 pythonprefix \ + optsuffix pep517 py3kplist pytest pytest4 pythonprefix \ unittest unittest2 _INVALID_PYTHON_FEATURES= . for var in ${USE_PYTHON} @@ -309,6 +324,12 @@ IGNORE= uses either USE_PYTHON=pytest or USE_PYTHON=pytest4, not both of them _PYTHON_FEATURE_FLAVORS= yes . endif +# pep517 automatically generates flavors depending on the supported +# versions. +. if defined(_PYTHON_FEATURE_PEP517) +_PYTHON_FEATURE_FLAVORS= yes +. endif + . if defined(_PYTHON_FEATURE_NOFLAVORS) .undef _PYTHON_FEATURE_FLAVORS . endif @@ -595,6 +616,21 @@ RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>=63.1.0:devel/py-setuptools@${P . endif . endif +. if defined(_PYTHON_FEATURE_PEP517) +. if ${PYTHON_VER} == 2.7 +DEV_ERROR+= "USES=python:2.7 is incompatible with USE_PYTHON=pep517" +. endif +. if defined(_PYTHON_FEATURE_DISTUTILS) +DEV_ERROR+= "USE_PYTHON=distutils is incompatible with USE_PYTHON=pep517" +. endif +. if defined(_PYTHON_FEATURE_PY3KPLIST) +DEV_ERROR+= "USE_PYTHON=py3kplist is incompatible with USE_PYTHON=pep517" +. endif +. if defined(_PYTHON_FEATURE_NOEGGINFO) +DEV_ERROR+= "USE_PYTHON=noegginfo is incompatible with USE_PYTHON=pep517" +. endif +. endif + # distutils support PYSETUP?= setup.py PYDISTUTILS_SETUP?= -c \ @@ -618,6 +654,12 @@ 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} +# PEP-517 support +PEP517_BUILD_CMD?= ${PYTHON_CMD} -m build -n -w +PEP517_BUILD_DEPEND?= ${PYTHON_PKGNAMEPREFIX}build>0:devel/py-build@${PY_FLAVOR} +PEP517_INSTALL_CMD?= ${PYTHON_CMD} -m installer -d ${STAGEDIR} --no-compile-bytecode ${BUILD_WRKSRC}/dist/${PORTNAME}-${PORTVERSION}-*.whl +PEP517_INSTALL_DEPEND?= ${PYTHON_PKGNAMEPREFIX}installer>0:devel/py-installer@${PY_FLAVOR} + # nose support . if defined(_PYTHON_FEATURE_NOSE) TEST_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}nose>=0:devel/py-nose@${PY_FLAVOR} @@ -669,7 +711,7 @@ add-plist-egginfo: . endfor . endif -. if defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS) +. if defined(_PYTHON_FEATURE_AUTOPLIST) && (defined(_PYTHON_FEATURE_DISTUTILS) || defined(_PYTHON_FEATURE_PEP517)) _RELSITELIBDIR= ${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} _RELLIBDIR= ${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;} @@ -701,7 +743,7 @@ add-plist-python: ${TMPPLIST} > ${TMPPLIST}.pyc_tmp @${MV} ${TMPPLIST}.pyc_tmp ${TMPPLIST} . endif # ${PYTHON_REL} >= 30200 && defined(_PYTHON_FEATURE_PY3KPLIST) -. endif # defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS) +. endif # defined(_PYTHON_FEATURE_AUTOPLIST) && (defined(_PYTHON_FEATURE_DISTUTILS) || defined(_PYTHON_FEATURE_PEP517)) # Fix for programs that build python from a GNU auto* environment CONFIGURE_ENV+= PYTHON="${PYTHON_CMD}" @@ -790,6 +832,35 @@ do-install: . endif . endif # defined(_PYTHON_FEATURE_DISTUTILS) +. if defined(_PYTHON_FEATURE_PEP517) +. if !empty(PEP517_BUILD_DEPEND) +BUILD_DEPENDS+= ${PEP517_BUILD_DEPEND} +. endif +. if !empty(PEP517_INSTALL_DEPEND) +BUILD_DEPENDS+= ${PEP517_INSTALL_DEPEND} +. endif + +. if !target(do-configure) +do-configure: + @${DO_NADA} +. endif + +. if !target(do-build) +do-build: + @cd ${BUILD_WRKSRC} && ${SETENV} ${MAKE_ENV} ${PEP517_BUILD_CMD} +. endif + +. if !target(do-install) +do-install: + @${MKDIR} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} + @cd ${INSTALL_WRKSRC} && ${SETENV} ${MAKE_ENV} ${PEP517_INSTALL_CMD} + @${SED} -e 's|^|${PYTHONPREFIX_SITELIBDIR}/|' \ + -e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../bin/|bin/|' \ + -e 's|\,.*$$||' \ + ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/${PORTNAME}-${PORTVERSION}.dist-info/RECORD >> ${_PYTHONPKGLIST} +. endif +. endif # defined(_PYTHON_FEATURE_PEP517) + . if defined(_PYTHON_FEATURE_NOSE) . if !target(do-test) do-test: