Skip to content

Commit bfa06a9

Browse files
authored
Merge pull request #4 from asenyaev/asen/windows_python
Add build for python packages on Windows
2 parents 093968e + c7db704 commit bfa06a9

File tree

1 file changed

+86
-40
lines changed

1 file changed

+86
-40
lines changed

.github/workflows/build_wheels.yml

Lines changed: 86 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,20 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
os: [macos-latest] # ubuntu-latest,
26-
python-version: [3.8] # [3.6, 3.7, 3.8, 3.9]
27-
platform: [x64]
25+
os: [windows-latest, ubuntu-latest, macos-latest]
26+
python-version: [3.6, 3.7, 3.8, 3.9]
27+
platform: [x32, x64]
2828
with_contrib: [0, 1]
2929
without_gui: [0, 1]
3030
build_sdist: [0]
31-
# include:
32-
# - os: ubuntu-latest
33-
# python-version: 3.8
34-
# build_sdist: 1
35-
# with_contrib: 0
36-
# without_gui: 0
37-
# - os: ubuntu-latest
38-
# python-version: 3.8
39-
# build_sdist: 1
40-
# with_contrib: 0
41-
# without_gui: 1
42-
# - os: ubuntu-latest
43-
# python-version: 3.8
44-
# build_sdist: 1
45-
# with_contrib: 1
46-
# without_gui: 0
47-
# - os: ubuntu-latest
48-
# python-version: 3.8
49-
# build_sdist: 1
50-
# with_contrib: 1
51-
# without_gui: 1
31+
exclude:
32+
- os: macos-latest
33+
platform: x32
34+
- os: ubuntu-latest
35+
platform: x32
5236

5337
env:
38+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
5439
REPO_DIR: .
5540
BUILD_COMMIT: master
5641
PROJECT_SPEC: opencv-python
@@ -78,51 +63,44 @@ jobs:
7863
- name: Update submodules
7964
run: |
8065
git submodule update --remote
81-
66+
8267
- name: Set up Python ${{ matrix.python-version }}
8368
uses: actions/setup-python@v2
8469
with:
8570
python-version: ${{ matrix.python-version }}
8671

8772
- name: Setup Environment variables
73+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
8874
run: |
8975
if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
9076
if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
9177
if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
9278
echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
9379
echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;
94-
80+
9581
- name: before install
82+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
9683
run: |
9784
set -e
98-
9985
if [[ $SDIST == 0 ]]; then
10086
# Check out and prepare the source
10187
# Multibuild doesn't have releases, so --depth would break eventually (see
10288
# https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
10389
git submodule update --init multibuild
104-
10590
source multibuild/common_utils.sh
106-
10791
# https://github.com/matthew-brett/multibuild/issues/116
10892
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi
109-
11093
source multibuild/travis_steps.sh
11194
# This sets -x
112-
11395
# source travis_multibuild_customize.sh
11496
echo $ENABLE_CONTRIB > contrib.enabled
11597
echo $ENABLE_HEADLESS > headless.enabled
116-
11798
echo "end"
11899
# Not interested in travis internal scripts' output
119100
fi
120-
121101
set +x
122-
123102
# Build and package
124103
set -x
125-
126104
ls
127105
if [[ $SDIST == 1 ]]; then
128106
python -m pip install --upgrade pip
@@ -131,9 +109,7 @@ jobs:
131109
else
132110
build_wheel $REPO_DIR $PLAT
133111
fi
134-
135112
set +x
136-
137113
# Install and run tests
138114
set -x
139115
if [[ $SDIST == 1 ]]; then
@@ -142,15 +118,58 @@ jobs:
142118
else
143119
install_run $PLAT && rc=$? || rc=$?
144120
fi
145-
146121
set +x
147-
148122
#otherwise, Travis logic terminates prematurely
149123
#https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
150124
trap ERR
151125
test "$rc" -eq 0
126+
127+
- name: Setup MSBuild.exe
128+
if: ${{ matrix.os == 'windows-latest' }}
129+
uses: warrenbuckley/Setup-MSBuild@v1
130+
131+
- name: build script
132+
if: ${{ matrix.os == 'windows-latest' }}
133+
run: |
134+
python --version
135+
python -m pip install --upgrade pip
136+
python -m pip install --upgrade setuptools
137+
set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\dist . --verbose
138+
shell: cmd
139+
140+
- name: before test
141+
if: ${{ matrix.os == 'windows-latest' }}
142+
run: |
143+
cd ${{ github.workspace }}/tests
144+
$env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command"
145+
&python -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl")
146+
if ($LastExitCode -ne 0) {throw $LastExitCode}
147+
shell: powershell
148+
149+
- name: run test
150+
if: ${{ matrix.os == 'windows-latest' }}
151+
run: |
152+
cd ${{ github.workspace }}/tests
153+
python -m unittest test
154+
shell: cmd
155+
156+
- name: saving artifacts
157+
if: ${{ matrix.os == 'windows-latest' }}
158+
uses: actions/upload-artifact@v2
159+
with:
160+
name: ${{ matrix.os }}-wheels-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
161+
path: dist\opencv*.whl
152162

153-
# - name: Upload wheels
163+
- name: saving artifacts
164+
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
165+
uses: actions/upload-artifact@v2
166+
with:
167+
name: ${{ matrix.os }}-wheels-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
168+
path: ./wheelhouse/opencv*.whl
169+
170+
171+
# - name: Upload wheels ${{ matrix.os }}
172+
# if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
154173
# env:
155174
# # PYPI repository
156175
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
@@ -163,3 +182,30 @@ jobs:
163182
# twine upload --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/*
164183
# # Upload wheels to PYPITEST
165184
# #twine upload --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/*
185+
186+
# - name: Upload wheels ${{ matrix.os }}
187+
# if: ${{ matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/')}}
188+
# env:
189+
# USER: fXgF9uyy6sT0JoVOR7BoqA==
190+
# PASS: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
191+
# run: |
192+
# cd ${{ github.workspace }}
193+
# if (${Env:ENABLE_CONTRIB} -eq 0) {
194+
# if (${Env:ENABLE_HEADLESS} -eq 0) {
195+
# echo "This is a default build. Deployment will be done to PyPI entry opencv-python."
196+
# }
197+
# else {
198+
# echo "This is a headless build. Deployment will be done to PyPI entry opencv-python-headless."
199+
# }
200+
# }
201+
# else {
202+
# if (${Env:ENABLE_HEADLESS} -eq 0) {
203+
# echo "This is a contrib build. Deployment will be done to PyPI entry opencv-contrib-python."
204+
# }
205+
# else {
206+
# echo "This is a headless contrib build. Deployment will be done to PyPI entry opencv-contrib-python-headless."
207+
# }
208+
# }
209+
# &python -m pip install twine
210+
# &python -m twine upload -u ${Env:USER} -p ${Env:PASS} --skip-existing dist/opencv*
211+
# shell: powershell

0 commit comments

Comments
 (0)