From 56520c1f119be8fc2e78127daac95fe557536ec8 Mon Sep 17 00:00:00 2001 From: Arnaud Taffanel Date: Tue, 10 Jan 2023 17:07:56 +0100 Subject: [PATCH 1/3] Fix python wheel build of the python binding --- .gitignore | 1 + Makefile | 12 +++++++----- bindings/setup.py | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f2360df107..4a64854c14 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ current_platform.mk bindings/build/* bindings/cffirmware_wrap.c +dist/ docs/.jekyll-metadata docs/.jekyll-cache diff --git a/Makefile b/Makefile index bb519cb534..72fb9f4ea0 100644 --- a/Makefile +++ b/Makefile @@ -215,14 +215,16 @@ ifeq ($(KBUILD_SRC),) MOD_INC = src/modules/interface MOD_SRC = src/modules/src -bindings_python cffirmware.py: bindings/setup.py $(MOD_SRC)/*.c +bindings_python build/cffirmware.py: bindings/setup.py $(MOD_SRC)/*.c swig -python -I$(MOD_INC) -Isrc/hal/interface -Isrc/utils/interface -o build/cffirmware_wrap.c bindings/cffirmware.i $(PYTHON) bindings/setup.py build_ext --inplace - mv build/cffirmware.py cffirmware.py -test_python: cffirmware.py - $(PYTHON) -m pytest test_python +test_python: build/cffirmware.py + PYTHONPATH=build $(PYTHON) -m pytest test_python + +python_wheel: build/cffirmware.py + $(PYTHON) bindings/setup.py bdist_wheel endif -.PHONY: all clean build compile unit prep erase flash check_submodules trace openocd gdb halt reset flash_dfu flash_dfu_manual flash_verify cload size print_version clean_version bindings_python +.PHONY: all clean build compile unit prep erase flash check_submodules trace openocd gdb halt reset flash_dfu flash_dfu_manual flash_verify cload size print_version clean_version bindings_python test_python python_wheel diff --git a/bindings/setup.py b/bindings/setup.py index 44e79c2d23..11139c31ee 100644 --- a/bindings/setup.py +++ b/bindings/setup.py @@ -68,5 +68,7 @@ def initialize_options(self): name="cffirmware", version="1.0", cmdclass={"build": BuildCommand}, - ext_modules=[cffirmware] + ext_modules=[cffirmware], + py_modules=["cffirmware"], + package_dir={"": "build"}, ) From 6d2b3934a87d9874c72e31eb9ed7d18f4aad9dbd Mon Sep 17 00:00:00 2001 From: Arnaud Taffanel Date: Tue, 10 Jan 2023 17:16:38 +0100 Subject: [PATCH 2/3] Add build script for the Python binding's wheel --- tools/build/python_wheel | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 tools/build/python_wheel diff --git a/tools/build/python_wheel b/tools/build/python_wheel new file mode 100755 index 0000000000..ee05e1e08c --- /dev/null +++ b/tools/build/python_wheel @@ -0,0 +1,6 @@ +#!/bin/env bash +set -e + +make cf2_defconfig +make include/generated/autoconf.h +make python_wheel From a0e96e33e5808212b96e6be075957bc40cce81f3 Mon Sep 17 00:00:00 2001 From: Arnaud Taffanel Date: Mon, 20 Feb 2023 12:53:13 +0100 Subject: [PATCH 3/3] Move python_wheel script out of the toolbelt script folder --- tools/{build => python_binding}/python_wheel | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{build => python_binding}/python_wheel (100%) diff --git a/tools/build/python_wheel b/tools/python_binding/python_wheel similarity index 100% rename from tools/build/python_wheel rename to tools/python_binding/python_wheel