Revert "Mk/Uses/python.mk: Fix USE_PYTHON=pep517: always compile and install bytecode"

Despite installer's default behaviour to compile and install bytecode,
we are not doing so going forward at stage/package time. [0] During
initial development and qualification of PEP-517 framework support,
compiling and installing bytecode at stage/package time was considered,
but was found problematic, fragile and ultimately unreliable, both
currently and historically (with USE_PYTHON=distutils), due to our
fixed plist requirement. While the living binary distribution format
(wheel) specification [1] says to compile bytecode, that is in the
pure Python package management context (pip, etc); nuance always
exists when interacting with "system" package management.

Additionally, "bytecode is an implementation detail of the CPython
interpreter. No guarantees are made that bytecode will not be added,
removed, or changed between versions of Python," thus "should not
be considered to work across Python VMs or Python releases." [2]
This is important to ensuring correctness for those ports specifying
NO_ARCH.

Instead of compiling and installing bytecode at stage/package time,
there is a WIP, review D34739, that compiles and installs bytecode
at install time instead, using triggers.

The aforementioned build_fs_violations will be investigated.

This reverts commit de6965254c.

With hat:	python
Approved by:	tcberner (mentor, portmgr)
Reference:	https://wiki.freebsd.org/Python/PEP-517 [0]
		https://packaging.python.org/en/latest/specifications/binary-distribution-format/ [1]
		https://docs.python.org/3/library/dis.html [2]
This commit is contained in:
Charlie Li 2023-02-05 14:05:02 -05:00
parent de6965254c
commit f5890bd3cb
No known key found for this signature in database
GPG key ID: FEB7852BE29B3E87
23 changed files with 11 additions and 30 deletions

View file

@ -179,13 +179,13 @@
# 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 --no-isolation --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 --destdir ${STAGEDIR} ${BUILD_WRKSRC}/dist/${PORTNAME:C|[-_]+|_|g}-${PORTVERSION}-*.whl
# default: ${PYTHON_CMD} -m installer -d ${STAGEDIR} --no-compile-bytecode ${BUILD_WRKSRC}/dist/${PORTNAME:C/[-_]+/_/g}-${PORTVERSION}-*.whl
#
# PEP517_INSTALL_DEPEND - Port needed to execute ${PEP517_INSTALL_CMD}.
# default: ${PYTHON_PKGNAMEPREFIX}installer>0:devel/py-installer@${PY_FLAVOR}
@ -656,10 +656,10 @@ PYDISTUTILS_EGGINFO?= ${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_
PYDISTUTILS_EGGINFODIR?=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
# PEP-517 support
PEP517_BUILD_CMD?= ${PYTHON_CMD} -m build --no-isolation --wheel
PEP517_BUILD_DEPEND?= ${PYTHON_PKGNAMEPREFIX}build>=0:devel/py-build@${PY_FLAVOR}
PEP517_INSTALL_CMD?= ${PYTHON_CMD} -m installer --destdir ${STAGEDIR} ${BUILD_WRKSRC}/dist/${PORTNAME:C/[-_]+/_/g}-${PORTVERSION}-*.whl
PEP517_INSTALL_DEPEND?= ${PYTHON_PKGNAMEPREFIX}installer>=0:devel/py-installer@${PY_FLAVOR}
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:C/[-_]+/_/g}-${PORTVERSION}-*.whl
PEP517_INSTALL_DEPEND?= ${PYTHON_PKGNAMEPREFIX}installer>0:devel/py-installer@${PY_FLAVOR}
# nose support
. if defined(_PYTHON_FEATURE_NOSE)
@ -858,8 +858,7 @@ do-install:
@${SED} -e 's|^|${PYTHONPREFIX_SITELIBDIR}/|' \
-e 's|^${PYTHONPREFIX_SITELIBDIR}/../../../bin/|bin/|' \
-e 's|\,.*$$||' \
${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/${PORTNAME:C|[-_]+|_|g}-${PORTVERSION}.dist-info/RECORD >> ${_PYTHONPKGLIST}
@cd ${STAGEDIR}${PREFIX} && ${FIND} lib -name '*.pyc' >> ${_PYTHONPKGLIST}
${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/${PORTNAME:C/[-_]+/_/g}-${PORTVERSION}.dist-info/RECORD >> ${_PYTHONPKGLIST}
. endif
. endif # defined(_PYTHON_FEATURE_PEP517)

View file

@ -1,6 +1,5 @@
PORTNAME= gTTS
DISTVERSION= 2.3.1
PORTREVISION= 1
CATEGORIES= audio python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= resdk
DISTVERSION= 16.0.0
PORTREVISION= 1
CATEGORIES= biology python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,7 +1,6 @@
PORTNAME= cocotb
DISTVERSIONPREFIX= v
DISTVERSION= 1.7.2
PORTREVISION= 1
CATEGORIES= cad python
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,6 @@
PORTNAME= poetry
DISTVERSION= 1.3.2
PORTREVISION= 2
PORTREVISION= 1
CATEGORIES= devel python
MASTER_SITES= PYPI
PKGNAMESUFFIX= -python-tool

View file

@ -1,6 +1,5 @@
PORTNAME= find-libpython
PORTVERSION= 0.3.0
PORTREVISION= 1
CATEGORIES= devel python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= importlib-metadata
PORTVERSION= 6.0.0
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= interface-meta
PORTVERSION= 1.3.0
PORTREVISION= 1
CATEGORIES= devel python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,6 @@
PORTNAME= mediafile
DISTVERSION= 0.11.0
PORTREVISION= 2
PORTREVISION= 1
CATEGORIES= devel python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= poetry-plugin-export
DISTVERSION= 1.2.0
PORTREVISION= 1
CATEGORIES= devel python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,6 @@
PORTNAME= pyls-black
PORTVERSION= 0.4.7
PORTREVISION= 3
PORTREVISION= 2
CATEGORIES= devel python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= pytoolconfig
PORTVERSION= 1.2.5
PORTREVISION= 1
CATEGORIES= devel python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,6 @@
PORTNAME= letsdns
DISTVERSION= 1.0.1
PORTREVISION= 2
PORTREVISION= 1
CATEGORIES= dns
MAINTAINER= flo@FreeBSD.org

View file

@ -1,6 +1,5 @@
PORTNAME= glcontext
DISTVERSION= 2.3.7
PORTREVISION= 1
CATEGORIES= graphics
#MASTER_SITES= PYPI # no tests
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= moderngl-window
DISTVERSION= 2.4.2
PORTREVISION= 1
CATEGORIES= graphics
#MASTER_SITES= PYPI # no tests
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= moderngl
DISTVERSION= 5.7.4
PORTREVISION= 1
CATEGORIES= graphics
#MASTER_SITES= PYPI # no tests
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= traitsui
DISTVERSION= 7.4.3
PORTREVISION= 1
CATEGORIES= graphics python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= einops
DISTVERSION= 0.6.0
PORTREVISION= 1
CATEGORIES= misc # machine-learning
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= securesystemslib
PORTVERSION= 0.26.0
PORTREVISION= 1
CATEGORIES= security python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= tuf
PORTVERSION= 2.1.0
PORTREVISION= 1
CATEGORIES= security devel python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= docker
PORTVERSION= 6.0.1
PORTREVISION= 1
CATEGORIES= sysutils python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= sphinx-autoapi
DISTVERSION= 2.0.1
PORTREVISION= 1
CATEGORIES= textproc python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

View file

@ -1,6 +1,5 @@
PORTNAME= fastapi
PORTVERSION= 0.89.1
PORTREVISION= 1
CATEGORIES= www python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}