Skip to contentSkip to conversation

python3-scikit-build: New recipe

PATCH Superseded Zoltán Böszörményi 1 participant 3 messages Mar 10, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 python3-scikit-build: New recipe

Used by python3-cmake and python3-ninja.

---
 .../python/python3-scikit-build_0.16.7.bb     | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-scikit-build_0.16.7.bb
meta-python/recipes-devtools/python/python3-scikit-build_0.16.7.bb new file +21 -0
new file mode 100644
index 000000000..7eacd936b
@@ -0,0 +1,21 @@
+SUMMARY = "Improved build system generator for Python C/C++/Fortran/Cython extensions"
+LICENSE = "MIT & BSD-2-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=7c96d2b08b3cec6d3c67fb864d1fd8cc"
+
+DEPENDS = "python3-setuptools-scm-native"
+
+PYPI_PACKAGE = "scikit-build"
+
+inherit pypi python_setuptools_build_meta
+SRC_URI[sha256sum] = "a9b9cc7479b71e6c8d434596dfade025253aae23adb22a9a2d85850fd51cecfd"
+
+RDEPENDS:${PN} = " \
+	python3-distro \
+	python3-packaging \
+	python3-setuptools \
+	python3-typing-extensions \
+	python3-wheel \
+	cmake \
+"
+
+BBCLASSEXTEND = "native"
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/3 python3-cmake: New recipe

Some python modules rely on "import cmake".

Only build and ship the python parts, and don't download and build cmake from sources. Use the already built cmake instead.

The CMakeLists.txt file is a crippled copy from this cmake python module's sources, removing almost everything, and adding a dummy install target, so do_install() doesn't fail.

The python code is patched so cmake is used from PATH.

---
 .../python/python3-cmake/CMakeLists.txt       | 11 ++++++
 .../python3-cmake/run-cmake-from-path.patch   | 11 ++++++
 .../python/python3-cmake_3.25.2.bb            | 37 +++++++++++++++++++
 3 files changed, 59 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-cmake/CMakeLists.txt
 create mode 100644 meta-python/recipes-devtools/python/python3-cmake/run-cmake-from-path.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-cmake_3.25.2.bb
meta-python/recipes-devtools/python/python3-cmake/CMakeLists.txt new file +11 -0
new file mode 100644
index 000000000..8ba81970f
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.6)
+
+#
+# For more details, see docs/building.rst
+#
+
+project(CMakePythonDistributions NONE)
+
+install(CODE "
+  message(STATUS \"Install CMake project\")
+")
meta-python/recipes-devtools/python/python3-cmake/run-cmake-from-path.patch new file +11 -0
new file mode 100644
index 000000000..5c38fadce
@@ -0,0 +1,11 @@
+--- cmake-3.25.2/src/cmake/__init__.py.old	2023-03-10 09:40:43.582315753 +0100
++++ cmake-3.25.2/src/cmake/__init__.py	2023-03-10 09:41:38.030874047 +0100
+@@ -36,7 +36,7 @@
+ 
+ 
+ def _program(name, args):
+-    return subprocess.call([os.path.join(CMAKE_BIN_DIR, name)] + args, close_fds=False)
++    return subprocess.call([name] + args, close_fds=False)
+ 
+ 
+ def cmake():
meta-python/recipes-devtools/python/python3-cmake_3.25.2.bb new file +37 -0
new file mode 100644
index 000000000..d0e11f9a6
@@ -0,0 +1,37 @@
+SUMMARY = "CMake is an open-source, cross-platform family of tools designed to build, test and package software"
+LICENSE = "BSD-3-Clause & Apache-2.0"
+LIC_FILES_CHKSUM = " \
+	file://LICENSE_BSD_3;md5=9134cb61aebbdd79dd826ccb9ae6afcd \
+	file://LICENSE_Apache_20;md5=19cbd64715b51267a47bf3750cc6a8a5 \
+"
+
+DEPENDS = "ninja-native cmake-native python3-scikit-build-native"
+
+PYPI_PACKAGE = "cmake"
+PYPI_ARCHIVE_NAME_PREFIX = "pypi-"
+
+inherit pypi python_setuptools_build_meta
+SRC_URI[sha256sum] = "bcf9f0369743278ec26961542b31ed1610e6f4cfc20c00a3f1c61985abb3b0d2"
+
+SRC_URI += " \
+	file://CMakeLists.txt \
+	file://run-cmake-from-path.patch \
+"
+
+addtask do_patchbuild after do_patch before do_configure
+
+do_patchbuild () {
+	rm -f ${S}/CMakeLists.txt
+	cp ${WORKDIR}/CMakeLists.txt ${S}/
+}
+
+do_install:append () {
+	rm -rf ${D}${bindir}
+}
+
+RDEPENDS:${PN} = " \
+	cmake \
+	python3-scikit-build \
+"
+
+BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.39.2
#2 lore raw

PATCH 3/3 python3-ninja: New recipe

In reply to Zoltán Böszörményi

Some python modules rely on "import ninja".

Only build and ship the python parts, and don't download and build ninja from sources. Use the already built ninja instead.

The CMakeLists.txt file is a crippled copy from this ninja python module's sources, removing almost everything, and adding a dummy install target, so do_install() doesn't fail.

The python code is patched so ninja is used from PATH.

---
 .../python/python3-ninja/CMakeLists.txt       |  9 +++++
 .../python3-ninja/run-ninja-from-path.patch   | 11 ++++++
 .../python/python3-ninja_1.11.1.bb            | 34 +++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-ninja/CMakeLists.txt
 create mode 100644 meta-python/recipes-devtools/python/python3-ninja/run-ninja-from-path.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-ninja_1.11.1.bb
meta-python/recipes-devtools/python/python3-ninja/CMakeLists.txt new file +9 -0
new file mode 100644
index 000000000..04fa451e7
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(NinjaPythonDistributions)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
+
+install(CODE "
+ message(STATUS \"Install ninja project\")
+")
meta-python/recipes-devtools/python/python3-ninja/run-ninja-from-path.patch new file +11 -0
new file mode 100644
index 000000000..26bd03737
@@ -0,0 +1,11 @@
+--- ninja-1.11.1/src/ninja/__init__.py.old	2022-11-05 09:49:23.000000000 +0100
++++ ninja-1.11.1/src/ninja/__init__.py	2023-03-10 09:45:13.452082888 +0100
+@@ -44,7 +44,7 @@
+ 
+ 
+ def _program(name, args):
+-    return subprocess.call([os.path.join(BIN_DIR, name)] + args, close_fds=False)
++    return subprocess.call([name] + args, close_fds=False)
+ 
+ 
+ def ninja():
meta-python/recipes-devtools/python/python3-ninja_1.11.1.bb new file +34 -0
new file mode 100644
index 000000000..635fd076a
@@ -0,0 +1,34 @@
+SUMMARY = "Ninja is a small build system with a focus on speed"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://LICENSE_Apache_20;md5=19cbd64715b51267a47bf3750cc6a8a5"
+
+DEPENDS = "ninja-native cmake-native python3-scikit-build-native"
+
+PYPI_PACKAGE = "ninja"
+PYPI_ARCHIVE_NAME_PREFIX = "pypi-"
+
+inherit pypi python_setuptools_build_meta
+SRC_URI[sha256sum] = "c833a47d39b2d1eee3f9ca886fa1581efd5be6068b82734ac229961ee8748f90"
+
+SRC_URI += " \
+	file://CMakeLists.txt \
+	file://run-ninja-from-path.patch \
+"
+
+addtask do_patchbuild after do_patch before do_configure
+
+do_patchbuild () {
+	rm -f ${S}/CMakeLists.txt
+	cp ${WORKDIR}/CMakeLists.txt ${S}/
+}
+
+do_install:append () {
+	rm -rf ${D}${bindir}
+}
+
+RDEPENDS:${PN} = " \
+	ninja \
+	python3-scikit-build \
+"
+
+BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.39.2