Skip to content

Commit 23b8d60

Browse files
authored
Add build wheels CI, remove python2.7 CI (onnx#15)
* add build_wheels.yml Signed-off-by: daquexian <[email protected]> * compile protobuf as static lib to avoid https://stackoverflow.com/q/37051635/5283216 Signed-off-by: daquexian <[email protected]> * use manylinux2010 and gcc8 Signed-off-by: daquexian <[email protected]> * more verbose pip wheel Signed-off-by: daquexian <[email protected]> * Add patch for onnx tensor Signed-off-by: daquexian <[email protected]> * change before_build to before_all Signed-off-by: daquexian <[email protected]> * change before_build to before_all Signed-off-by: daquexian <[email protected]> * test windows Signed-off-by: daquexian <[email protected]> * use static protobuf on windows Signed-off-by: daquexian <[email protected]> * build static protobuf Signed-off-by: daquexian <[email protected]> * add github action build wheels ci Signed-off-by: daquexian <[email protected]> * fix windows python path Signed-off-by: daquexian <[email protected]> * remove py2.7 tests, set submodule to recursive Signed-off-by: daquexian <[email protected]> * remove mis-added file Signed-off-by: daquexian <[email protected]> * set protobuf version in ci to 3.13.0 Signed-off-by: daquexian <[email protected]>
1 parent 746c02f commit 23b8d60

File tree

5 files changed

+54
-31
lines changed

5 files changed

+54
-31
lines changed

.github/workflows/Linux-CI.yml

+14-24
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ jobs:
88
strategy:
99
matrix:
1010
include:
11-
- python-version: '2.7'
12-
onnx_ml: 0
13-
onnx_debug: 0
1411
- python-version: '3.6'
1512
onnx_ml: 0
1613
onnx_debug: 0
@@ -34,7 +31,7 @@ jobs:
3431
activate-environment: py${{ matrix.python-version }}
3532
python-version: ${{ matrix.python-version }}
3633
channels: conda-forge
37-
- run: conda install protobuf
34+
- run: conda install libprotobuf=3.13.0 protobuf
3835
shell: bash -l {0}
3936
- run: |
4037
python -m pip install --upgrade pip
@@ -68,33 +65,26 @@ jobs:
6865
! grep -R --include='*.cc' --include='*.h' 'onnx::' .
6966
7067
# onnx python api tests
71-
if [ "${{ matrix.python-version }}" == "2.7" ]; then
72-
pip install --quiet pytest nbval
73-
else
74-
# pytest 6.0 made deprecation warnings fail by default, pinning pytest to 5.4.3.
75-
# TODO replace deprecated function with the suggested one. https://docs.pytest.org/en/stable/deprecations.html#id5
76-
pip install --quiet pytest==5.4.3 nbval
77-
fi
68+
# pytest 6.0 made deprecation warnings fail by default, pinning pytest to 5.4.3.
69+
# TODO replace deprecated function with the suggested one. https://docs.pytest.org/en/stable/deprecations.html#id5
70+
pip install --quiet pytest==5.4.3 nbval
7871
7972
pytest
8073
if [ $? -ne 0 ]; then
8174
echo "pytest failed"
8275
exit 1
8376
fi
8477
85-
# Mypy only works with Python 3
86-
if [ "${{ matrix.python-version }}" != "2.7" ]; then
87-
# Mypy only works with our generated _pb.py files when we install in develop mode, so let's do that
88-
pip uninstall -y onnxoptimizer
89-
ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI pip install --no-use-pep517 -e .[mypy]
90-
python setup.py --quiet typecheck
91-
if [ $? -ne 0 ]; then
92-
echo "type check failed"
93-
exit 1
94-
fi
95-
pip uninstall -y onnxoptimizer
96-
rm -rf .setuptools-cmake-build
97-
ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI pip install .
78+
# Mypy only works with our generated _pb.py files when we install in develop mode, so let's do that
79+
pip uninstall -y onnxoptimizer
80+
ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI pip install --no-use-pep517 -e .[mypy]
81+
python setup.py --quiet typecheck
82+
if [ $? -ne 0 ]; then
83+
echo "type check failed"
84+
exit 1
9885
fi
86+
pip uninstall -y onnxoptimizer
87+
rm -rf .setuptools-cmake-build
88+
ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI pip install .
9989
name: 'Run ONNX Optimizer tests'
10090
shell: bash -l {0}

.github/workflows/MacOS-CI.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ jobs:
88
strategy:
99
matrix:
1010
include:
11-
- python-version: '2.7'
12-
onnx_ml: 0
1311
- python-version: '3.6'
1412
onnx_ml: 0
1513
- python-version: '3.6'
@@ -18,7 +16,7 @@ jobs:
1816
steps:
1917
- uses: actions/checkout@v2
2018
with:
21-
submodules: true
19+
submodules: recursive
2220
- name: Create Anaconda environment
2321
uses: goanpeca/setup-miniconda@v1
2422
with:

.github/workflows/Windows-CI.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v2
2626
with:
27-
submodules: true
27+
submodules: recursive
2828
- name: Create Anaconda environment
2929
uses: goanpeca/setup-miniconda@v1
3030
with:
3131
activate-environment: py${{ matrix.python-version }}
3232
python-version: ${{ matrix.python-version }}
3333
channels: conda-forge
34-
- run: conda install numpy libprotobuf=3.11.3 protobuf
34+
- run: conda install numpy libprotobuf=3.13.0 protobuf
3535
shell: pwsh
3636
- name: Install and test ONNX Optimizer
3737
shell: cmd /C call {0}

.github/workflows/build-wheels.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Wheels
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_wheels:
7+
env:
8+
CIBW_BEFORE_ALL_LINUX: /opt/python/cp38-cp38/bin/python -m pip install cmake && cp /opt/python/cp38-cp38/bin/cmake /usr/bin/cmake && mkdir temp && curl -L https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protobuf-all-3.13.0.tar.gz -o protobuf.tar.gz && tar xf protobuf.tar.gz -C temp && rm -rf protobuf.tar.gz && cd temp/* && mkdir cmake/build && cd cmake/build && cmake -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release .. && cmake --build . -j4 && cmake -P cmake_install.cmake && cd ../../../.. && rm -rf temp
9+
CIBW_BEFORE_ALL_MACOS: pip install cmake && git clone https://github.com/protocolbuffers/protobuf.git && cd protobuf && git checkout v3.13.0 && cd cmake && mkdir build && cd build && cmake -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release .. && cmake --build . -j4 && cmake -P cmake_install.cmake
10+
CIBW_BEFORE_ALL_WINDOWS: git clone https://github.com/protocolbuffers/protobuf.git && cd protobuf && git checkout v3.13.0 && cd cmake && mkdir build && cd build && cmake -G "Visual Studio 15 2017 Win64" -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=C:/protobuf_install -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON .. && cmake --build . --config Release -j4 && cmake -P cmake_install.cmake --config Release
11+
CIBW_ENVIRONMENT_WINDOWS: CMAKE_PREFIX_PATH=C:/protobuf_install CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON" USE_MSVC_STATIC_RUNTIME=0
12+
# Only build on Python 3 and skip 32-bit builds
13+
CIBW_BUILD: cp3?-*
14+
CIBW_SKIP: "*-win32 *-manylinux_i686"
15+
name: Build wheels on ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-16.04, vs2017-win2016, macos-10.14]
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
submodules: recursive
24+
- uses: actions/setup-python@v2
25+
name: Install Python
26+
with:
27+
python-version: '3.7'
28+
- name: Build wheels
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install cibuildwheel==1.5.5
32+
cibuildwheel --output-dir wheelhouse .
33+
- uses: actions/upload-artifact@v2
34+
with:
35+
path: ./wheelhouse/*.whl

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
## ONNX
5555

5656
# build, distribute, and bins (+ python proto bindings)
57-
build
58-
build_*
57+
build/
58+
build_*/
5959
.build_debug/*
6060
.build_release/*
6161
.setuptools-cmake-build/*

0 commit comments

Comments
 (0)