Skip to content

Add build for python packages on Windows #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 86 additions & 40 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,20 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest] # ubuntu-latest,
python-version: [3.8] # [3.6, 3.7, 3.8, 3.9]
platform: [x64]
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
platform: [x32, x64]
with_contrib: [0, 1]
without_gui: [0, 1]
build_sdist: [0]
# include:
# - os: ubuntu-latest
# python-version: 3.8
# build_sdist: 1
# with_contrib: 0
# without_gui: 0
# - os: ubuntu-latest
# python-version: 3.8
# build_sdist: 1
# with_contrib: 0
# without_gui: 1
# - os: ubuntu-latest
# python-version: 3.8
# build_sdist: 1
# with_contrib: 1
# without_gui: 0
# - os: ubuntu-latest
# python-version: 3.8
# build_sdist: 1
# with_contrib: 1
# without_gui: 1
exclude:
- os: macos-latest
platform: x32
- os: ubuntu-latest
platform: x32

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
REPO_DIR: .
BUILD_COMMIT: master
PROJECT_SPEC: opencv-python
Expand Down Expand Up @@ -78,51 +63,44 @@ jobs:
- name: Update submodules
run: |
git submodule update --remote

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Setup Environment variables
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: |
if [ "macos-latest" == "${{ matrix.os }}" ]; then echo "TRAVIS_OS_NAME=osx" >> $GITHUB_ENV; else echo "TRAVIS_OS_NAME=${{ matrix.os }}" >> $GITHUB_ENV; fi
if [ "schedule" == "${{ github.event_name }}" ]; then echo "TRAVIS_EVENT_TYPE=cron" >> $GITHUB_ENV; else echo "TRAVIS_EVENT_TYPE=${{ github.event_name }}" >> $GITHUB_ENV; fi
if [ "schedule" == "${{ github.event_name }}" ]; then echo "BUILD_COMMIT=master" >> $GITHUB_ENV; else echo "BUILD_COMMIT=$BUILD_COMMIT" >> $GITHUB_ENV; fi
echo "BUILD_DEPENDS=$(echo $NP_BUILD_DEP)" >> $GITHUB_ENV;
echo "TEST_DEPENDS=$(echo $NP_TEST_DEP)" >> $GITHUB_ENV;

- name: before install
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
run: |
set -e

if [[ $SDIST == 0 ]]; then
# Check out and prepare the source
# Multibuild doesn't have releases, so --depth would break eventually (see
# https://superuser.com/questions/1240216/server-does-not-allow-request-for-unadvertised)
git submodule update --init multibuild

source multibuild/common_utils.sh

# https://github.com/matthew-brett/multibuild/issues/116
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export ARCH_FLAGS=" "; fi

source multibuild/travis_steps.sh
# This sets -x

# source travis_multibuild_customize.sh
echo $ENABLE_CONTRIB > contrib.enabled
echo $ENABLE_HEADLESS > headless.enabled

echo "end"
# Not interested in travis internal scripts' output
fi

set +x

# Build and package
set -x

ls
if [[ $SDIST == 1 ]]; then
python -m pip install --upgrade pip
Expand All @@ -131,9 +109,7 @@ jobs:
else
build_wheel $REPO_DIR $PLAT
fi

set +x

# Install and run tests
set -x
if [[ $SDIST == 1 ]]; then
Expand All @@ -142,15 +118,58 @@ jobs:
else
install_run $PLAT && rc=$? || rc=$?
fi

set +x

#otherwise, Travis logic terminates prematurely
#https://travis-ci.community/t/shell-session-update-command-not-found-in-build-log-causes-build-to-fail-if-trap-err-is-set/817
trap ERR
test "$rc" -eq 0

- name: Setup MSBuild.exe
if: ${{ matrix.os == 'windows-latest' }}
uses: warrenbuckley/Setup-MSBuild@v1

- name: build script
if: ${{ matrix.os == 'windows-latest' }}
run: |
python --version
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
set "CI_BUILD=1" && python -m pip wheel --wheel-dir=%cd%\dist . --verbose
shell: cmd

- name: before test
if: ${{ matrix.os == 'windows-latest' }}
run: |
cd ${{ github.workspace }}/tests
$env:PYTHONWARNINGS = "ignore:::pip._internal.cli.base_command"
&python -m pip install --user --no-warn-script-location (ls "../dist/opencv_*.whl")
if ($LastExitCode -ne 0) {throw $LastExitCode}
shell: powershell

- name: run test
if: ${{ matrix.os == 'windows-latest' }}
run: |
cd ${{ github.workspace }}/tests
python -m unittest test
shell: cmd

- name: saving artifacts
if: ${{ matrix.os == 'windows-latest' }}
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-wheels-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
path: dist\opencv*.whl

# - name: Upload wheels
- name: saving artifacts
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}-wheels-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.with_contrib }}-${{ matrix.without_gui }}-${{ matrix.build_sdist }}
path: ./wheelhouse/opencv*.whl


# - name: Upload wheels ${{ matrix.os }}
# if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }}
# env:
# # PYPI repository
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand All @@ -163,3 +182,30 @@ jobs:
# twine upload --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/*
# # Upload wheels to PYPITEST
# #twine upload --skip-existing ${TRAVIS_BUILD_DIR}/wheelhouse/*

# - name: Upload wheels ${{ matrix.os }}
# if: ${{ matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/')}}
# env:
# USER: fXgF9uyy6sT0JoVOR7BoqA==
# PASS: 0bXSOVjf9x8L7nErTivu92TF1FwNosTjFJQPmxp8Dys=
# run: |
# cd ${{ github.workspace }}
# if (${Env:ENABLE_CONTRIB} -eq 0) {
# if (${Env:ENABLE_HEADLESS} -eq 0) {
# echo "This is a default build. Deployment will be done to PyPI entry opencv-python."
# }
# else {
# echo "This is a headless build. Deployment will be done to PyPI entry opencv-python-headless."
# }
# }
# else {
# if (${Env:ENABLE_HEADLESS} -eq 0) {
# echo "This is a contrib build. Deployment will be done to PyPI entry opencv-contrib-python."
# }
# else {
# echo "This is a headless contrib build. Deployment will be done to PyPI entry opencv-contrib-python-headless."
# }
# }
# &python -m pip install twine
# &python -m twine upload -u ${Env:USER} -p ${Env:PASS} --skip-existing dist/opencv*
# shell: powershell