curl: update to 8.11.1
[oi-userland.git] / make-rules / pyproject.mk
blob2857e29b1a3a5d89649efffdbc2009d193935640
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 list of hatch, pdm, pep735, pipenv, and poetry test dependencies
60 # per Python version.
62 # Please note we set PATH below for tox to workaround
63 # https://github.com/tox-dev/tox/issues/2538
64 COMPONENT_POST_INSTALL_ACTION += \
65 cd $(@D)$(COMPONENT_SUBDIR:%=/%) ; \
66 cfg=$(BUILD_DIR)/pyproject_deps-$(PYTHON_VERSION).json ; \
67 $(RM) $$cfg ; \
68 for p in $(TEST_REQUIREMENTS_HATCH) ; do \
69 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add hatch_$$p hatch pyproject.toml $$p ; \
70 done ; \
71 for p in $(TEST_REQUIREMENTS_PDM) ; do \
72 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pdm_$$p pdm $$p ; \
73 done ; \
74 for p in $(TEST_REQUIREMENTS_PEP735) ; do \
75 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pep735_$$p pep735 $$p ; \
76 done ; \
77 if [ "$(strip $(TEST_STYLE))" == "tox" -a -x "$(TOX)" ] ; then \
78 for p in $$(PATH=$(PATH) PYTHONPATH=$(PROTO_DIR)/$(PYTHON_DIR)/site-packages:$(PROTO_DIR)/$(PYTHON_LIB) \
79 $(TOX) -qq --no-provision --print-dependency-groups-to=- $(TOX_TESTENV)) ; do \
80 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pep735_$$p pep735 $$p ; \
81 done ; \
82 fi ; \
83 for p in $(TEST_REQUIREMENTS_PIPENV) ; do \
84 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add pipenv_$$p pipenv Pipfile $$p ; \
85 done ; \
86 for p in $(TEST_REQUIREMENTS_POETRY) ; do \
87 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg add poetry_$$p poetry $$p ; \
88 done ; \
89 if [ -f $$cfg ] ; then \
90 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg sync ; \
91 $(PYTHON) -m pyproject_installer deps --depsconfig $$cfg eval \
92 | $(PYTHON) $(WS_TOOLS)/python-requires - >> $(@D)/.depend-test ; \
93 fi ;
95 # Add build dependencies from project metadata to REQUIRED_PACKAGES
96 REQUIRED_PACKAGES_RESOLVED += $(BUILD_DIR)/META.depend.res
97 $(BUILD_DIR)/META.depend.res: $(SOURCE_DIR)/.prep
98 $(MKDIR) $(BUILD_DIR)
99 # PYTHON_ENV is needed four times here to have the PYTHONPATH set
100 # properly when we bootstrap the pyproject_installer bootstrapper.
101 $(PYTHON_ENV) $(PYTHON) -m pyproject_installer deps --depsconfig $(BUILD_DIR)/pyproject_deps.json add build_pep517 pep517
102 $(PYTHON_ENV) $(PYTHON) -m pyproject_installer deps --depsconfig $(BUILD_DIR)/pyproject_deps.json add build_pep518 pep518
103 cd $(SOURCE_DIR) ; $(PYTHON_ENV) $(PYTHON) -m pyproject_installer deps --depsconfig $(BUILD_DIR)/pyproject_deps.json sync
104 $(PYTHON_ENV) $(PYTHON) -m pyproject_installer deps --depsconfig $(BUILD_DIR)/pyproject_deps.json eval --depformat '$$nname' \
105 | $(GSED) -e 's/.*/depend type=require fmri=pkg:\/library\/python\/&-$$(PYV)/' \
106 > $@
107 # PYTHON_ENV (see above) needs BITS
108 $(BUILD_DIR)/META.depend.res: BITS = $(PREFERRED_BITS)
110 # We need pyproject_installer for two purposes:
111 # - to detect build dependencies for all Python projects, and
112 # - to bootstrap some other Python projects.
113 # The pyproject_installer is not needed (and cannot be needed) for its own
114 # build.
115 ifneq ($(strip $(COMPONENT_NAME)),pyproject_installer)
116 USERLAND_REQUIRED_PACKAGES.python += library/python/pyproject-installer
117 endif