make-rules/setup.py.mk | ●●●●● patch | view | raw | blame | history | |
tools/python-requires | ●●●●● patch | view | raw | blame | history |
make-rules/setup.py.mk
@@ -277,6 +277,30 @@ $(GSED) -e 's/^\(set name=pkg.fmri [^@]*\)\(.*\)$$/\1-$$(PYV)\2/' endif # Add runtime dependencies from project metadata to generated manifest GENERATE_EXTRA_DEPS += $(BUILD_DIR)/META.depend-runtime.res GENERATE_EXTRA_CMD += | \ $(CAT) - <( \ echo "" ; \ echo "\# Automatically generated dependencies based on distribution metadata" ; \ $(CAT) $(BUILD_DIR)/META.depend-runtime.res \ ) # Add runtime dependencies from project metadata to REQUIRED_PACKAGES REQUIRED_PACKAGES_RESOLVED += $(BUILD_DIR)/META.depend-runtime.res # Generate raw lists of runtime dependencies per Python version COMPONENT_POST_INSTALL_ACTION += \ PYTHONPATH=$(PROTO_DIR)/$(PYTHON_DIR)/site-packages:$(PROTO_DIR)/$(PYTHON_LIB) \ $(PYTHON) $(WS_TOOLS)/python-requires $(COMPONENT_NAME) > $(@D)/.depend-runtime ; # Convert raw per version lists of runtime dependencies to single resolved # runtime dependency list $(BUILD_DIR)/META.depend-runtime.res: $(INSTALL_TARGET) $(CAT) $(INSTALL_TARGET:%.installed=%.depend-runtime) | LC_ALL=C $(GSORT) -u \ | $(GSED) -e 's/.*/depend type=require fmri=pkg:\/library\/python\/&-$$(PYV)/' > $@ clean:: $(RM) -r $(SOURCE_DIR) $(BUILD_DIR) tools/python-requires
New file @@ -0,0 +1,47 @@ #! /usr/bin/python # # 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 2022 Marcel Telka # # # Print requirements for a package. # Evaluated and normalized. # import sys import re try: try: from importlib.metadata import requires except ImportError: from importlib_metadata import requires from packaging.requirements import Requirement from packaging.markers import UndefinedEnvironmentName except: exit() if len(sys.argv) < 2: exit() try: for req in requires(sys.argv[1]): r = Requirement(req) try: if not r.marker or r.marker.evaluate(): print(re.sub(r"[-_.]+", "-", r.name).lower()) except UndefinedEnvironmentName: pass except: pass