Some Python ports now use pyproject.toml with various build backends. It
seems that the best way for us to work with these is going to be to use
"pip wheel" to generate a wheel, and py-installer to place files from
that wheel into the fake-install directory.

There are a few flit_core-based ports where so far I've been using
"python -m flit_core.wheel" directly to generate the wheel, and all of
these are working by instead using "pip wheel -v --no-index --no-cache
--no-deps --no-build-isolation ."

Also it looks like the same works for other ports using hatchling
(I need to do some rearrangement to split combined py2+3 py- ports
off into a separate py2- so I can update the py3 version to get
deps updated before we can use that).

So here are some WIP changes to python.port.mk and those ports to
handle it more nicely.

Does anyone else have any kind of handle on this stuff? If so does
this seem sane?

Index: lang/python/python.port.mk
===================================================================
RCS file: /cvs/ports/lang/python/python.port.mk,v
retrieving revision 1.147
diff -u -p -r1.147 python.port.mk
--- lang/python/python.port.mk  4 Aug 2022 19:15:59 -0000       1.147
+++ lang/python/python.port.mk  4 Aug 2022 20:00:55 -0000
@@ -147,8 +147,19 @@ RUN_DEPENDS +=             ${MODPY_RUN_DEPENDS}
 TEST_DEPENDS +=                ${MODPY_TEST_DEPENDS}
 .endif
 
+MODPY_SETUPTOOLS ?=
+MODPY_SETUPUTILS ?=
+MODPY_PEP517 ?=                No
+MODPY_PI ?=
+
 _MODPY_PRE_BUILD_STEPS = :
-.if defined(MODPY_SETUPTOOLS) && ${MODPY_SETUPTOOLS:L} == "yes"
+
+.if ${MODPY_PEP517:L} == "no"
+_MODPY_PRE_BUILD_STEPS += ; [ -e ${WRKSRC}/pyproject.toml ] && echo "OpenBSD 
ports: use MODPY_PEP517?"
+.endif
+
+
+.if ${MODPY_SETUPTOOLS:L} == "yes"
 # The setuptools module provides a package locator (site.py) that is
 # required at runtime for the pkg_resources stuff to work
 .  if ${MODPY_MAJOR_VERSION} == 2
@@ -160,6 +171,7 @@ MODPY_SETUPUTILS_DEPEND ?= devel/py-setu
 MODPY_RUN_DEPENDS +=   ${MODPY_SETUPUTILS_DEPEND}
 BUILD_DEPENDS +=       ${MODPY_SETUPUTILS_DEPEND}
 MODPY_SETUPUTILS =     Yes
+
 # The setuptools uses test target
 TEST_TARGET ?= test
 _MODPY_USERBASE =
@@ -174,6 +186,15 @@ _MODPY_PRE_BUILD_STEPS += ;${MODPY_CMD} 
 # 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_PEP517:L} != no
+BUILD_DEPENDS +=       devel/py-installer${MODPY_FLAVOR}
+.  if ${MODPY_PEP517:L:Mflit_core}
+BUILD_DEPENDS +=       devel/py-flit_core${MODPY_FLAVOR}
+.  elif ${MODPY_PEP517:L:Mflit}
+BUILD_DEPENDS +=       devel/py-flit${MODPY_FLAVOR}
+.  elif ${MODPY_PEP517:L:Mhatch}
+BUILD_DEPENDS +=       devel/py-hatchling${MODPY_FLAVOR}
+.  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.
@@ -192,7 +213,7 @@ MODPY_SETUPUTILS =  No
 _MODPY_USERBASE =      ${WRKDIR}
 .endif
 
-.if defined(MODPY_PI) && ${MODPY_PI:L} == "yes"
+.if ${MODPY_PI:L} == "yes"
 _MODPY_EGG_NAME =      ${DISTNAME:S/-${MODPY_EGG_VERSION}//}
 MODPY_PI_DIR ?=                
${DISTNAME:C/^([a-zA-Z0-9]).*/\1/}/${_MODPY_EGG_NAME}
 MASTER_SITES =         ${MASTER_SITE_PYPI:=${MODPY_PI_DIR}/}
@@ -268,6 +289,13 @@ MODPY_ADJ_FILES ?=
 MODPYTHON_pre-configure += cd ${WRKSRC} && ${MODPY_BIN_ADJ} ${MODPY_ADJ_FILES}
 .endif
 
+.if ${MODPY_PEP517:L} != nos
+MODPY_BUILD_TARGET = ${_MODPY_PRE_BUILD_STEPS}; \
+       cd ${WRKSRC} && pip wheel -v --no-index --no-cache --no-deps 
--no-build-isolation .
+MODPY_INSTALL_TARGET = \
+       ${INSTALL_DATA_DIR} ${WRKINST}${MODPY_LIBDIR}; \
+       ${MODPY_BIN} -m installer -d ${WRKINST} ${WRKSRC}/*.whl
+.else
 MODPY_BUILD_TARGET = ${_MODPY_PRE_BUILD_STEPS}; \
        ${MODPY_CMD} ${MODPY_DISTUTILS_BUILD} ${MODPY_DISTUTILS_BUILDARGS}
 MODPY_INSTALL_TARGET = \
@@ -275,10 +303,11 @@ MODPY_INSTALL_TARGET = \
                ${MODPY_DISTUTILS_INSTALL} ${MODPY_DISTUTILS_INSTALLARGS}
 
 MODPY_TEST_TARGET =    ${MODPY_TEST_CMD}
-.if ${MODPY_PYTEST:L} == "yes"
+.  if ${MODPY_PYTEST:L} == "yes"
 MODPY_TEST_TARGET +=   ${MODPY_PYTEST_ARGS}
-.elif ${MODPY_SETUPUTILS:L} == "yes"
+.  elif ${MODPY_SETUPUTILS:L} == "yes"
 MODPY_TEST_TARGET +=   ${TEST_TARGET}
+.  endif
 .endif
 
 # dirty way to do it with no modifications in bsd.port.mk
Index: devel/py-flit/Makefile
===================================================================
RCS file: /cvs/ports/devel/py-flit/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- devel/py-flit/Makefile      2 Aug 2022 11:10:47 -0000       1.2
+++ devel/py-flit/Makefile      4 Aug 2022 20:00:55 -0000
@@ -30,15 +30,7 @@ MODPY_PYTEST =       Yes
 TEST_DEPENDS = devel/py-testpath${MODPY_FLAVOR} \
                www/py-responses${MODPY_FLAVOR}
 
-BUILD_DEPENDS += devel/py-flit_core${MODPY_FLAVOR} \
-               devel/py-installer${MODPY_FLAVOR}
-
-do-build:
-       cd ${WRKSRC} && ${MODPY_BIN} -m flit_core.wheel
-
-do-install:
-       ${INSTALL_DATA_DIR} ${WRKINST}${MODPY_LIBDIR}
-       ${MODPY_BIN} -m installer -d ${WRKINST} ${WRKSRC}/dist/*.whl
+MODPY_PEP517 = flit_core
 
 pre-test:
        ln -s ${MODPY_BIN} ${WRKDIR}/bin/python
Index: devel/py-pep517/Makefile
===================================================================
RCS file: /cvs/ports/devel/py-pep517/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- devel/py-pep517/Makefile    2 Aug 2022 11:10:48 -0000       1.2
+++ devel/py-pep517/Makefile    4 Aug 2022 20:00:55 -0000
@@ -26,14 +26,6 @@ MODPY_PYTEST =       Yes
 TEST_DEPENDS = devel/py-pip${MODPY_FLAVOR}
 PORTHOME =     ${WRKDIR}
 
-BUILD_DEPENDS += devel/py-flit_core${MODPY_FLAVOR} \
-               devel/py-installer${MODPY_FLAVOR}
-
-do-build:
-       cd ${WRKSRC} && ${MODPY_BIN} -m flit_core.wheel
-
-do-install:
-       ${INSTALL_DATA_DIR} ${WRKINST}${MODPY_LIBDIR}
-       ${MODPY_BIN} -m installer -d ${WRKINST} ${WRKSRC}/dist/*.whl
+MODPY_PEP517 = flit_core
 
 .include <bsd.port.mk>
Index: devel/py-testpath/Makefile
===================================================================
RCS file: /cvs/ports/devel/py-testpath/Makefile,v
retrieving revision 1.25
diff -u -p -r1.25 Makefile
--- devel/py-testpath/Makefile  2 Aug 2022 11:10:48 -0000       1.25
+++ devel/py-testpath/Makefile  4 Aug 2022 20:00:55 -0000
@@ -3,7 +3,7 @@ COMMENT =               test utilities working with f
 MODPY_EGG_VERSION =    0.4.2
 DISTNAME =             testpath-${MODPY_EGG_VERSION}
 PKGNAME =              py-${DISTNAME}
-REVISION =             8
+REVISION =             9
 
 CATEGORIES =           devel
 
@@ -20,14 +20,6 @@ MODPY_PYTEST =               Yes
 FLAVORS =              python3
 FLAVOR =               python3
 
-BUILD_DEPENDS += devel/py-flit_core${MODPY_FLAVOR} \
-               devel/py-installer${MODPY_FLAVOR}
-
-do-build:
-       cd ${WRKSRC} && ${MODPY_BIN} -m flit_core.wheel
-
-do-install:
-       ${INSTALL_DATA_DIR} ${WRKINST}${MODPY_LIBDIR}
-       ${MODPY_BIN} -m installer -d ${WRKINST} ${WRKSRC}/dist/*.whl
+MODPY_PEP517 =         flit
 
 .include <bsd.port.mk>
Index: textproc/py-sphinx-notfound-page/Makefile
===================================================================
RCS file: /cvs/ports/textproc/py-sphinx-notfound-page/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- textproc/py-sphinx-notfound-page/Makefile   2 Aug 2022 11:12:52 -0000       
1.8
+++ textproc/py-sphinx-notfound-page/Makefile   4 Aug 2022 20:00:55 -0000
@@ -25,14 +25,6 @@ RUN_DEPENDS =                textproc/py-sphinx${MODPY
 
 NO_TEST =              Yes
 
-BUILD_DEPENDS += devel/py-flit_core${MODPY_FLAVOR} \
-               devel/py-installer${MODPY_FLAVOR}
-
-do-build:
-       cd ${WRKSRC} && ${MODPY_BIN} -m flit_core.wheel
-
-do-install:
-       ${INSTALL_DATA_DIR} ${WRKINST}${MODPY_LIBDIR}
-       ${MODPY_BIN} -m installer -d ${WRKINST} ${WRKSRC}/dist/*.whl
+MODPY_PEP517 =         flit_core
 
 .include <bsd.port.mk>
Index: textproc/py-tomli/Makefile
===================================================================
RCS file: /cvs/ports/textproc/py-tomli/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- textproc/py-tomli/Makefile  2 Aug 2022 11:10:47 -0000       1.3
+++ textproc/py-tomli/Makefile  4 Aug 2022 20:00:55 -0000
@@ -21,14 +21,6 @@ NO_TEST =            Yes
 FLAVORS =              python3
 FLAVOR =               python3
 
-BUILD_DEPENDS += devel/py-flit_core${MODPY_FLAVOR} \
-               devel/py-installer${MODPY_FLAVOR}
-
-do-build:
-       cd ${WRKSRC} && ${MODPY_BIN} -m flit_core.wheel
-
-do-install:
-       ${INSTALL_DATA_DIR} ${WRKINST}${MODPY_LIBDIR}
-       ${MODPY_BIN} -m installer -d ${WRKINST} ${WRKSRC}/dist/*.whl
+MODPY_PEP517 =         flit_core
 
 .include <bsd.port.mk>
Index: textproc/py-tomli_w/Makefile
===================================================================
RCS file: /cvs/ports/textproc/py-tomli_w/Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile
--- textproc/py-tomli_w/Makefile        2 Aug 2022 11:10:47 -0000       1.2
+++ textproc/py-tomli_w/Makefile        4 Aug 2022 20:00:55 -0000
@@ -21,14 +21,6 @@ FLAVORS =    python3
 
 NO_TEST =      Yes
 
-BUILD_DEPENDS += devel/py-flit_core${MODPY_FLAVOR} \
-               devel/py-installer${MODPY_FLAVOR}
-
-do-build:
-       cd ${WRKSRC} && ${MODPY_BIN} -m flit_core.wheel
-
-do-install:
-       ${INSTALL_DATA_DIR} ${WRKINST}${MODPY_LIBDIR}
-       ${MODPY_BIN} -m installer -d ${WRKINST} ${WRKSRC}/dist/*.whl
+MODPY_PEP517 =         flit_core
 
 .include <bsd.port.mk>

Reply via email to