thunderbird: update to 128.2.2
[oi-userland.git] / make-rules / pyproject.mk
blobd52ef1bfe3d7888917f441ae66e083c55ba7aae6
2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
5 # 1.0 of the CDDL.
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
13 # Copyright 2022 Marcel Telka
16 include $(WS_MAKE_RULES)/setup.py.mk
18 ifeq ($(strip $(PYTHON_BOOTSTRAP)),yes)
19 # To bootstrap the bootstrapper we need to make sure it finds its own modules
20 ifeq ($(strip $(COMPONENT_NAME)),pyproject_installer)
21 PYTHON_ENV += PYTHONPATH=$(@D)/src
22 endif
24 COMPONENT_BUILD_CMD = $(PYTHON) -m pyproject_installer build
25 COMPONENT_BUILD_ARGS =
27 COMPONENT_INSTALL_CMD = $(PYTHON) -m pyproject_installer install
28 COMPONENT_INSTALL_ARGS =
29 COMPONENT_INSTALL_ARGS += --destdir $(PROTO_DIR)
31 # pyproject_installer does not bytecompile after the install. Since we need
32 # pyc files we need to force that.
33 COMPONENT_POST_INSTALL_ACTION += \
34 $(PYTHON) -m compileall $(PROTO_DIR)/$(PYTHON_DIR)/site-packages $(PROTO_DIR)/$(PYTHON_LIB) ;
35 else
36 COMPONENT_BUILD_CMD = $(PYTHON) -m build
37 COMPONENT_BUILD_ARGS =
38 COMPONENT_BUILD_ARGS += --wheel
39 COMPONENT_BUILD_ARGS += --no-isolation
41 COMPONENT_INSTALL_CMD = $(PYTHON) -m installer
42 COMPONENT_INSTALL_ARGS =
43 COMPONENT_INSTALL_ARGS += --destdir $(PROTO_DIR)
44 COMPONENT_INSTALL_ARGS += $(@D)/dist/*.whl
46 USERLAND_REQUIRED_PACKAGES.python += library/python/build
47 USERLAND_REQUIRED_PACKAGES.python += library/python/installer
48 endif
50 # Move all modules from default site-packages directory to vendor-packages
51 # directory where we place modules shipped by the OS but not included in the
52 # core Python distribution.
53 COMPONENT_POST_INSTALL_ACTION += \
54 if [ -d $(PROTO_DIR)/$(PYTHON_DIR)/site-packages ] ; then \
55 $(RM) -r $(PROTO_DIR)/$(PYTHON_LIB) ; \
56 $(MV) $(PROTO_DIR)/$(PYTHON_DIR)/site-packages $(PROTO_DIR)/$(PYTHON_LIB) ; \
57 fi ;
59 # Generate raw lists of poetry, pdm, and pipenv test dependencies per Python version
60 COMPONENT_POST_INSTALL_ACTION += \
61 cd $(@D)$(COMPONENT_SUBDIR:%=/%) ; \
62 cfg=$(BUILD_DIR)/pyproject_deps-$(PYTHON_VERSION).json ; \
63 $(RM) $$cfg ; \
64 for p in $(TEST_REQUIREMENTS_POETRY) ; do \
65 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add poetry_$$p poetry $$p ; \
66 done ; \
67 for p in $(TEST_REQUIREMENTS_PDM) ; do \
68 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pdm_$$p pdm $$p ; \
69 done ; \
70 for p in $(TEST_REQUIREMENTS_PIPENV) ; do \
71 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pipenv_$$p pipenv Pipfile $$p ; \
72 done ; \
73 if [ -f $$cfg ] ; then \
74 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg sync ; \
75 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg eval --depformat '$$nname' \
76 >> $(@D)/.depend-test ; \
77 fi ;
79 # Add build dependencies from project metadata to REQUIRED_PACKAGES
80 REQUIRED_PACKAGES_RESOLVED += $(BUILD_DIR)/META.depend.res
81 $(BUILD_DIR)/META.depend.res: $(SOURCE_DIR)/.prep
82 $(MKDIR) $(BUILD_DIR)
83 # PYTHON_ENV is needed four times here to have the PYTHONPATH set
84 # properly when we bootstrap the pyproject_installer bootstrapper.
85 $(PYTHON_ENV) $(PYTHON) -m pyproject_installer deps --depsconfig $(BUILD_DIR)/pyproject_deps.json add build_pep517 pep517
86 $(PYTHON_ENV) $(PYTHON) -m pyproject_installer deps --depsconfig $(BUILD_DIR)/pyproject_deps.json add build_pep518 pep518
87 cd $(SOURCE_DIR) ; $(PYTHON_ENV) $(PYTHON) -m pyproject_installer deps --depsconfig $(BUILD_DIR)/pyproject_deps.json sync
88 $(PYTHON_ENV) $(PYTHON) -m pyproject_installer deps --depsconfig $(BUILD_DIR)/pyproject_deps.json eval --depformat '$$nname' \
89 | $(GSED) -e 's/.*/depend type=require fmri=pkg:\/library\/python\/&-$$(PYV)/' \
90 > $@
91 # PYTHON_ENV (see above) needs BITS
92 $(BUILD_DIR)/META.depend.res: BITS = $(PREFERRED_BITS)
94 # We need pyproject_installer for two purposes:
95 # - to detect build dependencies for all Python projects, and
96 # - to bootstrap some other Python projects.
97 # The pyproject_installer is not needed (and cannot be needed) for its own
98 # build.
99 ifneq ($(strip $(COMPONENT_NAME)),pyproject_installer)
100 USERLAND_REQUIRED_PACKAGES.python += library/python/pyproject-installer
101 endif