mirror of https://github.com/labapart/gattlib
ci: Generate Python package with cibuildwheel
parent
18e1658d6f
commit
13bd692bb4
|
@ -24,21 +24,29 @@ jobs:
|
||||||
|
|
||||||
generate-python-binary-packages:
|
generate-python-binary-packages:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
python-version: ["3.9", "3.10", "3.11"]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: sudo apt install -y libbluetooth-dev
|
- run: sudo apt install -y libbluetooth-dev
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
- run: ./ci/generate-python-package.sh
|
- run: ./ci/generate-python-package.sh
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
env:
|
||||||
|
CIBW_BEFORE_BUILD_LINUX: "sh ci/install-bluez.sh"
|
||||||
|
#TODO: To support 'musllinux', we need to replace 'yum install' by 'apk install' - and detect which platform we are
|
||||||
|
CIBW_SKIP: "*-musllinux_*"
|
||||||
|
- run: ./ci/generate-python-package.sh
|
||||||
|
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
|
||||||
|
env:
|
||||||
|
CIBW_BEFORE_BUILD_LINUX: "sh ci/install-bluez.sh"
|
||||||
|
GATTLIB_PY_VERSION: '0.0.1'
|
||||||
|
CIBW_ENVIRONMENT_PASS_LINUX: "GATTLIB_PY_VERSION"
|
||||||
|
#TODO: To support 'musllinux', we need to replace 'yum install' by 'apk install' - and detect which platform we are
|
||||||
|
CIBW_SKIP: "*-musllinux_*"
|
||||||
- name: Archive Python packages
|
- name: Archive Python packages
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: python-${{ matrix.python-version }}-binary-package
|
name: python-binary-packages
|
||||||
path: dist/*
|
path: dist/*
|
||||||
|
|
||||||
# publish-python-packages:
|
# publish-python-packages:
|
||||||
|
|
|
@ -23,6 +23,10 @@ cp -r ${ROOT_PATH}/include ${gattlib_py_package_dir}/
|
||||||
cp -r ${ROOT_PATH}/CMakeLists.txt ${gattlib_py_package_dir}/
|
cp -r ${ROOT_PATH}/CMakeLists.txt ${gattlib_py_package_dir}/
|
||||||
cp -r ${ROOT_PATH}/CrossCompilation.cmake ${gattlib_py_package_dir}/
|
cp -r ${ROOT_PATH}/CrossCompilation.cmake ${gattlib_py_package_dir}/
|
||||||
|
|
||||||
|
# Build script
|
||||||
|
mkdir ${gattlib_py_package_dir}/ci/
|
||||||
|
cp -r ${ROOT_PATH}/ci/install-bluez.sh ${gattlib_py_package_dir}/ci/
|
||||||
|
|
||||||
# Create MANIFEST.in
|
# Create MANIFEST.in
|
||||||
cat <<EOT >> MANIFEST.in
|
cat <<EOT >> MANIFEST.in
|
||||||
graft common
|
graft common
|
||||||
|
@ -34,13 +38,13 @@ include CrossCompilation.cmake
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
# Install requirements
|
# Install requirements
|
||||||
python3 -m pip install wheel
|
python3 -m pip --disable-pip-version-check install cibuildwheel==2.16.5
|
||||||
|
|
||||||
# Generate packages
|
# Generate packages
|
||||||
pushd ${gattlib_py_package_dir}
|
pushd ${gattlib_py_package_dir}
|
||||||
|
|
||||||
# Binary package
|
# Binary package
|
||||||
python3 setup.py bdist_wheel
|
python3 -m cibuildwheel --output-dir dist
|
||||||
|
|
||||||
# Source package
|
# Source package
|
||||||
python setup.py sdist
|
python setup.py sdist
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Exit immediately if a command exits with a non-zero status.
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
yum -y install wget dbus-devel
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.66.tar.xz
|
||||||
|
tar -xf bluez-5.66.tar.xz
|
||||||
|
pushd bluez-5.66
|
||||||
|
./configure --prefix=/usr/local --disable-obex --disable-udev --disable-cups --disable-client --disable-manpages --disable-tools \
|
||||||
|
--disable-obex --disable-monitor --disable-hog --disable-hid --disable-network --disable-a2dp --disable-avrcp --disable-bap \
|
||||||
|
--disable-mcp --disable-vcp --enable-library
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
popd
|
||||||
|
rm -Rf bluez-5.66
|
|
@ -102,18 +102,24 @@ if(GATTLIB_PYTHON_INTERFACE)
|
||||||
else()
|
else()
|
||||||
set(Python_USE_STATIC_LIBS TRUE)
|
set(Python_USE_STATIC_LIBS TRUE)
|
||||||
endif()
|
endif()
|
||||||
find_package(Python COMPONENTS Interpreter Development)
|
|
||||||
if (NOT Python_Development_FOUND)
|
find_package(Python3 COMPONENTS Interpreter Development)
|
||||||
find_package(Python COMPONENTS Development.Module)
|
if (NOT Python3_Development_FOUND)
|
||||||
if (NOT Python_Development.Module_FOUND)
|
find_package(Python3 COMPONENTS Development.Module)
|
||||||
|
if (NOT Python3_Development.Module_FOUND)
|
||||||
message(FATAL_ERROR "Could not find Python developer package")
|
message(FATAL_ERROR "Could not find Python developer package")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Case of mainlinux container to build Wheel Python package
|
||||||
|
if (NOT Python3_LIBRARIES)
|
||||||
|
set(Python3_LIBRARIES "")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${Python_INCLUDE_DIRS})
|
include_directories(${Python3_INCLUDE_DIRS})
|
||||||
list(APPEND gattlib_LIBS ${Python_LIBRARIES})
|
list(APPEND gattlib_LIBS ${Python3_LIBRARIES})
|
||||||
|
|
||||||
add_definitions(-DWITH_PYTHON -DPYTHON_VERSION_MAJOR=${Python_VERSION_MAJOR} -DPYTHON_VERSION_MINOR=${Python_VERSION_MINOR})
|
add_definitions(-DWITH_PYTHON -DPYTHON_VERSION_MAJOR=${Python3_VERSION_MAJOR} -DPYTHON_VERSION_MINOR=${Python3_VERSION_MINOR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Gattlib
|
# Gattlib
|
||||||
|
|
Loading…
Reference in New Issue