Skip to content
This repository was archived by the owner on Feb 19, 2024. It is now read-only.

Commit 03efa89

Browse files
authored
Fix/make linux build manylinux (#104)
* Add support for building with manylinux * Integrate Azure DevOps with Docker * Do not link with Python library on Linux * Add support for uc4 build
1 parent e5edb58 commit 03efa89

3 files changed

Lines changed: 86 additions & 45 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ foreach(SD_API_VER ${SD_API_VERS})
114114
target_include_directories(${PYTHON_MODULE_${SD_API_VER}} PRIVATE ${PC_BLE_DRIVER_PY_OUTDIR})
115115
endif()
116116

117-
target_link_libraries(${PYTHON_MODULE_${SD_API_VER}} PRIVATE nrf::nrf_ble_driver_sd_api_v${SD_API_VER}_${NRF_BLE_DRIVER_LINKAGE_TYPE} ${PYTHON_LIBRARY})
117+
set(LINK_LIBRARIES nrf::nrf_ble_driver_sd_api_v${SD_API_VER}_${NRF_BLE_DRIVER_LINKAGE_TYPE})
118+
if (WIN32 OR APPLE)
119+
set(LINK_LIBRARIES ${LINK_LIBRARIES} ${PYTHON_LIBRARY})
120+
endif()
121+
122+
message(STATUS "LINK_LIBRARIES are not ${LINK_LIBRARIES}")
123+
124+
target_link_libraries(${PYTHON_MODULE_${SD_API_VER}} PRIVATE ${LINK_LIBRARIES})
118125

119126
get_target_property(CONNECTIVITY_SD_API_V${SD_API_VER}_PATH nrf::nrf_ble_driver_sd_api_v${SD_API_VER}_${NRF_BLE_DRIVER_LINKAGE_TYPE} INTERFACE_INCLUDE_DIRECTORIES)
120127
set(CONNECTIVITY_SD_API_V${SD_API_VER}_PATH ${CONNECTIVITY_SD_API_V${SD_API_VER}_PATH}/../../share/nrf-ble-driver/hex/sd_api_v${SD_API_VER})

azure-pipelines.yml

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,26 @@ trigger:
66

77
jobs:
88
# Linux
9-
- job: Linux
9+
- job: 'Linux'
1010
variables:
11-
conda_version: 'Linux-x86_64'
12-
conda_root: '$(Agent.HomeDirectory)/miniconda3'
13-
VCPKG_ROOT: '$(Agent.HomeDirectory)/vcpkg'
14-
python_arch: 'x64'
11+
wheel_platform: 'manylinux2010_x86_64'
1512
pool:
1613
vmImage: 'ubuntu-16.04'
1714
steps:
18-
- script: |
19-
sudo apt-get update
20-
sudo apt-get install ninja-build swig libudev-dev
21-
displayName: 'Install toolchain'
22-
- script: |
23-
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-$(conda_version).sh -O $(Agent.HomeDirectory)/miniconda.sh
24-
bash $(Agent.HomeDirectory)/miniconda.sh -b -p $(conda_root)
25-
displayName: 'Install conda'
26-
- script: |
27-
git clone https://github.com/NordicPlayground/vcpkg.git $(VCPKG_ROOT)
28-
$(VCPKG_ROOT)/bootstrap-vcpkg.sh
29-
displayName: 'Install vcpkg'
30-
- script: |
31-
export PATH=$VCPKG_ROOT:$PATH
32-
vcpkg install nrf-ble-driver:$(python_arch)-linux
33-
displayName: 'Install nrf-ble-driver'
34-
- script: |
35-
$(conda_root)/bin/conda create -yq -n python2.7 python=2.7
36-
displayName: 'Install Python 2.7'
37-
- bash: |
38-
export PATH=$(conda_root)/envs/python2.7/bin:$PATH
39-
rm -rf _skbuild
40-
pip install -r requirements-dev.txt
41-
python setup.py bdist_wheel --build-type RelWithDebInfo
42-
displayName: 'Build for python 2.7'
43-
- script: |
44-
$(conda_root)/bin/conda create -yq -n python3.7 python=3.7
45-
displayName: 'Install Python 3.7'
46-
- bash: |
47-
export PATH=$(conda_root)/envs/python3.7/bin:$PATH
48-
rm -rf _skbuild
49-
pip install -r requirements-dev.txt
50-
python setup.py bdist_wheel --build-type RelWithDebInfo
51-
displayName: 'Build for python 3.7'
15+
- task: Docker@2
16+
displayName: Login to Docker Hub
17+
inputs:
18+
command: login
19+
containerRegistry: DockerImage
20+
- task: Docker@2
21+
displayName: 'Build ManyLinux'
22+
inputs:
23+
containerRegistry: DockerImage
24+
command: run
25+
arguments: '--rm -e PLAT=$(wheel_platform) -v $(System.DefaultWorkingDirectory):/data pypywheels/manylinux2010-pypy_x86_64 /data/build_many_linux.sh'
5226
- bash: |
53-
cp -R dist/*.whl "$(Build.ArtifactStagingDirectory)"
27+
ls -R wheelhouse
28+
cp --verbose -R wheelhouse/*.whl "$(Build.ArtifactStagingDirectory)"
5429
displayName: 'Copy artifacts'
5530
- task: GitHubRelease@0
5631
inputs:
@@ -63,8 +38,6 @@ jobs:
6338
isDraft: 'true'
6439
addChangeLog: 'false'
6540
condition: ne(variables['Build.Reason'], 'PullRequest')
66-
67-
6841
# macOS
6942
- job: macOS
7043
variables:
@@ -86,6 +59,7 @@ jobs:
8659
displayName: 'Install vcpkg'
8760
- script: |
8861
export PATH=$VCPKG_ROOT:$PATH
62+
export VCPKG_OSX_DEPLOYMENT_TARGET=10.9
8963
vcpkg install nrf-ble-driver:$(python_arch)-osx
9064
displayName: 'Install nrf-ble-driver'
9165
- bash: |
@@ -98,13 +72,13 @@ jobs:
9872
rm -rf _skbuild
9973
pypath=`which python2.7`
10074
${pypath} -m pip install -r requirements-dev.txt
101-
${pypath} setup.py bdist_wheel --build-type RelWithDebInfo -- -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9
75+
${pypath} setup.py bdist_wheel --build-type Release -- -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9
10276
displayName: 'Build for python 2.7'
10377
- bash: |
10478
rm -rf _skbuild
10579
pypath=`which python3.7`
10680
${pypath} -m pip install -r requirements-dev.txt
107-
${pypath} setup.py bdist_wheel --build-type RelWithDebInfo -- -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9
81+
${pypath} setup.py bdist_wheel --build-type Release -- -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9
10882
displayName: 'Build for python 3.7'
10983
- bash: |
11084
cp -R dist/*.whl "$(Build.ArtifactStagingDirectory)"

build_many_linux.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
yes | yum update
5+
yes | yum install libudev-devel pcre-devel
6+
7+
export TOOLS_ROOT=$HOME/tools
8+
export VCPKG_ROOT=$TOOLS_ROOT/vcpkg
9+
export PATH=$TOOLS_ROOT/bin:$TOOLS_ROOT:$VCPKG_ROOT:$PATH
10+
11+
export DOWNLOAD_CMAKE_VERSION=3.14.4
12+
export DOWNLOAD_CMAKE_FILENAME=cmake-$DOWNLOAD_CMAKE_VERSION-Linux-x86_64.sh
13+
export DOWNLOAD_CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v$DOWNLOAD_CMAKE_VERSION/$DOWNLOAD_CMAKE_FILENAME
14+
15+
export DOWNLOAD_NINJA_URL=https://github.com/ninja-build/ninja/archive/v1.9.0.zip
16+
export DOWNLOAD_SWIG_URL=https://github.com/swig/swig/archive/rel-4.0.0.tar.gz
17+
18+
rm -rf $TOOLS_ROOT
19+
mkdir -p $TOOLS_ROOT
20+
21+
curl -L -O $DOWNLOAD_CMAKE_URL
22+
bash $DOWNLOAD_CMAKE_FILENAME --skip-license --prefix=$TOOLS_ROOT
23+
24+
# Build recent version of Ninja
25+
curl -L -O $DOWNLOAD_NINJA_URL
26+
mkdir $HOME/temp
27+
unzip v1.9.0.zip -d $HOME/temp
28+
cd $HOME/temp/ninja-1.9.0
29+
./configure.py --bootstrap
30+
cp ninja $TOOLS_ROOT/bin
31+
cd $HOME && rm -rf $HOME/temp
32+
33+
# Build recent version of SWIG
34+
curl -L -O $DOWNLOAD_SWIG_URL
35+
mkdir $HOME/temp
36+
tar zxf rel-4.0.0.tar.gz --directory $HOME/temp
37+
cd $HOME/temp/swig-rel-4.0.0
38+
./autogen.sh
39+
./configure --prefix=$TOOLS_ROOT --without-tcl --without-perl5 --without-octave --without-scilab --without-java --without-javascript --without-android --without-guile --without-mzscheme --without-ruby --without-php --without-ocaml --without-csharp --without-lua --without-r --without-go --without-d
40+
make
41+
make install
42+
43+
# Build vcpkg
44+
git clone https://github.com/NordicPlayground/vcpkg.git $VCPKG_ROOT
45+
$VCPKG_ROOT/bootstrap-vcpkg.sh
46+
47+
# Build nrf-ble-driver
48+
vcpkg install nrf-ble-driver
49+
50+
# Build the wheels
51+
for PYBIN in /opt/python/cp[23]7-cp[23]7*/bin; do
52+
echo "Compiling for $PYBIN"
53+
rm -rf /data/_skbuild
54+
"${PYBIN}/pip" install -r /data/requirements-dev.txt
55+
"${PYBIN}/pip" wheel /data/ -w wheelhouse/
56+
done;
57+
58+
for whl in wheelhouse/*.whl; do
59+
auditwheel repair "$whl" --plat $PLAT -w /data/wheelhouse/
60+
done

0 commit comments

Comments
 (0)