From fdfcf2021da73623ad71d8fa8966615011ceb261 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Fri, 15 Nov 2024 21:07:26 +0100 Subject: [PATCH] make-rules: implement Python Dependency Groups (PEP 735) using pyproject_installer --- .../dependency-groups/python-integrate-project.conf | 20 -------------------- .../python/flit_core/python-integrate-project.conf | 1 - .../python/packaging/python-integrate-project.conf | 1 - .../python/tomli/python-integrate-project.conf | 1 - make-rules/pyproject.mk | 19 ++++++++++++++++--- make-rules/setup.py.mk | 17 +++-------------- 6 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 components/python/dependency-groups/python-integrate-project.conf diff --git a/components/python/dependency-groups/python-integrate-project.conf b/components/python/dependency-groups/python-integrate-project.conf deleted file mode 100644 index 64f6477e20..0000000000 --- a/components/python/dependency-groups/python-integrate-project.conf +++ /dev/null @@ -1,20 +0,0 @@ -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright 2024 Marcel Telka -# - -%include-2% -# This component is required by following bootstrapped components so it must be -# bootstrapped too. -# - Userland testing framework (see setup.py.mk) -PYTHON_TEST_BOOTSTRAP = yes diff --git a/components/python/flit_core/python-integrate-project.conf b/components/python/flit_core/python-integrate-project.conf index e80e6a2c9c..5e8e59ba5c 100644 --- a/components/python/flit_core/python-integrate-project.conf +++ b/components/python/flit_core/python-integrate-project.conf @@ -17,7 +17,6 @@ # This component is required by following bootstrapped components so it must be # bootstrapped too. # - build -# - dependency-groups (test bootstrap) # - flit_scm (test bootstrap) # - installer # - packaging diff --git a/components/python/packaging/python-integrate-project.conf b/components/python/packaging/python-integrate-project.conf index a201d0e62b..6ea879ebf5 100644 --- a/components/python/packaging/python-integrate-project.conf +++ b/components/python/packaging/python-integrate-project.conf @@ -17,7 +17,6 @@ # This component is required by following bootstrapped components so it must be # bootstrapped too. # - build -# - dependency-groups (test bootstrap) # - hatchling (test bootstrap) # - pyproject_api (test bootstrap) # - pytest (test bootstrap) diff --git a/components/python/tomli/python-integrate-project.conf b/components/python/tomli/python-integrate-project.conf index 169d08b37f..88c105eaf0 100644 --- a/components/python/tomli/python-integrate-project.conf +++ b/components/python/tomli/python-integrate-project.conf @@ -21,7 +21,6 @@ DOWNLOAD_URL='https://github.com/hukkin/tomli/archive/refs/tags/$(HUMAN_VERSION) # This component is required by following bootstrapped components so it must be # bootstrapped too. # - build -# - dependency-groups (test bootstrap) # - flit_scm (test bootstrap) # - hatchling (test bootstrap) # - pyproject_api (test bootstrap) diff --git a/make-rules/pyproject.mk b/make-rules/pyproject.mk index 50ade2a207..2857e29b1a 100644 --- a/make-rules/pyproject.mk +++ b/make-rules/pyproject.mk @@ -56,7 +56,11 @@ COMPONENT_POST_INSTALL_ACTION += \ $(MV) $(PROTO_DIR)/$(PYTHON_DIR)/site-packages $(PROTO_DIR)/$(PYTHON_LIB) ; \ fi ; -# Generate raw lists of hatch, pdm, pipenv, and poetry test dependencies per Python version +# Generate raw list of hatch, pdm, pep735, pipenv, and poetry test dependencies +# per Python version. +# +# Please note we set PATH below for tox to workaround +# https://github.com/tox-dev/tox/issues/2538 COMPONENT_POST_INSTALL_ACTION += \ cd $(@D)$(COMPONENT_SUBDIR:%=/%) ; \ cfg=$(BUILD_DIR)/pyproject_deps-$(PYTHON_VERSION).json ; \ @@ -67,6 +71,15 @@ COMPONENT_POST_INSTALL_ACTION += \ for p in $(TEST_REQUIREMENTS_PDM) ; do \ $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pdm_$$p pdm $$p ; \ done ; \ + for p in $(TEST_REQUIREMENTS_PEP735) ; do \ + $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pep735_$$p pep735 $$p ; \ + done ; \ + if [ "$(strip $(TEST_STYLE))" == "tox" -a -x "$(TOX)" ] ; then \ + for p in $$(PATH=$(PATH) PYTHONPATH=$(PROTO_DIR)/$(PYTHON_DIR)/site-packages:$(PROTO_DIR)/$(PYTHON_LIB) \ + $(TOX) -qq --no-provision --print-dependency-groups-to=- $(TOX_TESTENV)) ; do \ + $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pep735_$$p pep735 $$p ; \ + done ; \ + fi ; \ for p in $(TEST_REQUIREMENTS_PIPENV) ; do \ $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pipenv_$$p pipenv Pipfile $$p ; \ done ; \ @@ -75,8 +88,8 @@ COMPONENT_POST_INSTALL_ACTION += \ done ; \ if [ -f $$cfg ] ; then \ $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg sync ; \ - $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg eval --depformat '$$nname' \ - >> $(@D)/.depend-test ; \ + $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg eval \ + | $(PYTHON) $(WS_TOOLS)/python-requires - >> $(@D)/.depend-test ; \ fi ; # Add build dependencies from project metadata to REQUIRED_PACKAGES diff --git a/make-rules/setup.py.mk b/make-rules/setup.py.mk index 5bb9117c27..cfa0670590 100644 --- a/make-rules/setup.py.mk +++ b/make-rules/setup.py.mk @@ -346,15 +346,11 @@ COMPONENT_TEST_TRANSFORMS += \ USERLAND_TEST_REQUIRED_PACKAGES += library/python/tox USERLAND_TEST_REQUIRED_PACKAGES += library/python/tox-current-env -# The dependency-groups is used to print dependency groups if they are -# specified in the tox config (see below) -USERLAND_TEST_REQUIRED_PACKAGES += library/python/dependency-groups - # Generate raw lists of test dependencies per Python version -# Please note we set PATH below six times for tox to workaround +# Please note we set PATH below five times for tox to workaround # https://github.com/tox-dev/tox/issues/2538 COMPONENT_POST_INSTALL_ACTION += \ - if [ -x "$(COMPONENT_TEST_CMD)" ] ; then \ + if [ -x "$(TOX)" ] ; then \ cd $(@D)$(COMPONENT_SUBDIR:%=/%) ; \ echo "Testing dependencies:" ; \ PATH=$(PATH) PYTHONPATH=$(PROTO_DIR)/$(PYTHON_DIR)/site-packages:$(PROTO_DIR)/$(PYTHON_LIB) \ @@ -375,14 +371,7 @@ COMPONENT_POST_INSTALL_ACTION += \ $(TOX) -qq --no-provision --print-extras-to=- $(TOX_TESTENV)) ; do \ PYTHONPATH=$(PROTO_DIR)/$(PYTHON_DIR)/site-packages:$(PROTO_DIR)/$(PYTHON_LIB) \ $(PYTHON) $(WS_TOOLS)/python-requires $(COMPONENT_NAME) $$e ; \ - done ; \ - PATH=$(PATH) PYTHONPATH=$(PROTO_DIR)/$(PYTHON_DIR)/site-packages:$(PROTO_DIR)/$(PYTHON_LIB) \ - $(TOX) -qq --no-provision --print-dependency-groups-to=- $(TOX_TESTENV) \ - | /usr/gnu/bin/xargs -r /usr/bin/dependency-groups-$(PYTHON_VERSION) \ - | $(WS_TOOLS)/python-resolve-deps \ - PYTHONPATH=$(PROTO_DIR)/$(PYTHON_DIR)/site-packages:$(PROTO_DIR)/$(PYTHON_LIB) \ - $(PYTHON) $(WS_TOOLS)/python-requires $(COMPONENT_NAME) \ - | $(PYTHON) $(WS_TOOLS)/python-requires - \ + done \ ) | $(GSED) -e '/^tox\(-current-env\)\?$$/d' >> $(@D)/.depend-test ; \ fi ; else ifeq ($(strip $(TEST_STYLE)),pytest) -- 2.11.4.GIT