Marcel Telka
2022-12-06 6b1855350ab7593dbcc15b29829ee6a17fd82832
pyproject.mk: evaluate build dependencies

2 files modified
51 ■■■■■ changed files
make-rules/pyproject.mk 21 ●●●● patch | view | raw | blame | history
make-rules/setup.py.mk 30 ●●●●● patch | view | raw | blame | history
make-rules/pyproject.mk
@@ -92,6 +92,21 @@
        $(MV) $(PROTO_DIR)/$(PYTHON_DIR)/site-packages $(PROTO_DIR)/$(PYTHON_LIB) ; \
    fi ;
# To make the package names comparable we normalize them by following the PyPA
# Core metadata specifications and PEP 503.
#
# Before we reach bootstrap checkpoint 2 we use simple normalizer for build
# dependencies.  After that we use python-requires to get dependencies
# evaluated too.
ifneq ($(filter $(strip $(COMPONENT_NAME)),$(PYTHON_BOOTSTRAP_CHECKPOINT_2)),)
PYTHON_PACKAGE_NORMALIZER = \
    $(GSED) -e $$'s/^[ \t]*''\([a-zA-Z0-9]\([a-zA-Z0-9._-]*[a-zA-Z0-9]\)\{0,1\}\).*/\1/' \
    | tr [A-Z] [a-z] | $(GSED) -e 's/[._-]\{1,\}/-/g'
else
PYTHON_PACKAGE_NORMALIZER = \
    $(PYTHON) $(WS_TOOLS)/python-requires -
endif
# Add build dependencies from project metadata to REQUIRED_PACKAGES
REQUIRED_PACKAGES_RESOLVED += $(BUILD_DIR)/META.depend.res
$(BUILD_DIR)/META.depend.res: $(SOURCE_DIR)/.prep
@@ -99,16 +114,12 @@
    # PYTHON_ENV is needed here to have the PYTHONPATH set properly when we
    # bootstrap the pyproject_installer bootstrapper.
    #
    # To make the package names comparable we normalize them here by
    # following the PyPA Core metadata specifications and PEP 503.
    #
    # Once we obsolete Python 3.7 we should change $(PYTHON.3.9) to $(PYTHON) here
    $(PYTHON_ENV) $(PYTHON.3.9) -c ' \
            from pathlib import Path; \
            from pyproject_installer.build_cmd._build import parse_build_system_spec; \
            [print(x) for x in parse_build_system_spec(Path("'$(SOURCE_DIR)'"))["requires"]]' \
        | $(GSED) -e $$'s/^[ \t]*''\([a-zA-Z0-9]\([a-zA-Z0-9._-]*[a-zA-Z0-9]\)\{0,1\}\).*/\1/' \
        | tr [A-Z] [a-z] | $(GSED) -e 's/[._-]\{1,\}/-/g' \
        | $(PYTHON_PACKAGE_NORMALIZER) \
        | $(GSED) -e 's/.*/depend type=require fmri=pkg:\/library\/python\/&-$$(PYV)/' \
        > $@
make-rules/setup.py.mk
@@ -54,7 +54,7 @@
#
#     To achieve this checkpoint we just need to build pyproject_installer
#     using pyproject_installer without detecting its requirements (they are
#     none anyway) and without testing it (since no testing infrastrusture is
#     none anyway) and without testing it (since no testing infrastructure is
#     ready yet).
#
# (2)    The python-requires script works.
@@ -102,6 +102,20 @@
ifeq ($(strip $(PYTHON_BOOTSTRAP)),yes)
PYTHON_TEST_BOOTSTRAP = yes
endif
#
# Lists of Python projects needed to achieve particular bootstrap checkpoint.
# Indentation shows project dependencies (e.g. packaging requires pyparsing).
#
PYTHON_BOOTSTRAP_CHECKPOINT_1 +=    pyproject_installer
#
PYTHON_BOOTSTRAP_CHECKPOINT_2 +=    $(PYTHON_BOOTSTRAP_CHECKPOINT_1)
PYTHON_BOOTSTRAP_CHECKPOINT_2 +=    packaging
PYTHON_BOOTSTRAP_CHECKPOINT_2 +=        pyparsing
PYTHON_BOOTSTRAP_CHECKPOINT_2 +=            flit_core
PYTHON_BOOTSTRAP_CHECKPOINT_2 +=        setuptools
PYTHON_BOOTSTRAP_CHECKPOINT_2 +=        wheel
PYTHON_BOOTSTRAP_CHECKPOINT_2 +=            setuptools
# Particular python runtime is always required (at least to run setup.py)
PYTHON_REQUIRED_PACKAGES += runtime/python
@@ -465,17 +479,9 @@
USERLAND_REQUIRED_PACKAGES += library/python/importlib-metadata-37
# The python-requires script requires packaging to provide useful output but
# packaging might be unavailable during bootstrap of the following projects:
#
# - pyproject_installer (the bootstrapper)
# - packaging (obviously),
# - pyparsing (required by packaging)
# - flit_core (required by pyparsing)
# - wheel (required by packaging)
# - setuptools (required by packaging and wheel)
#
# So require it conditionally.
ifeq ($(filter $(strip $(COMPONENT_NAME)),pyproject_installer packaging pyparsing flit_core wheel setuptools),)
# packaging might be unavailable during bootstrap until we reach bootstrap
# checkpoint 2.  So require it conditionally.
ifeq ($(filter $(strip $(COMPONENT_NAME)),$(PYTHON_BOOTSTRAP_CHECKPOINT_2)),)
PYTHON_USERLAND_REQUIRED_PACKAGES += library/python/packaging
endif