From 959f2dde54e57a39dfd2bd014fe8251429cd8906 Mon Sep 17 00:00:00 2001 From: Janakarajan Natarajan <68447808+janaknat@users.noreply.github.com> Date: Thu, 14 Jan 2021 18:35:16 -0600 Subject: [PATCH] Add Github Actions x86 and mac jobs to build python wheels (#3024) * Add Github Actions x86 and mac jobs to build python wheels It uses multibuild for the building and testing process. * Update .github/workflows/build-wheels.yml * Update .github/workflows/build-wheels.yml * Apply suggestions from code review * Update .github/workflows/build-wheels.yml Co-authored-by: Michael Penkov --- .github/workflows/build-wheels.yml | 86 ++++++++++++++++++++++++++++++ .gitmodules | 3 ++ config.sh | 27 ++++++++++ multibuild | 1 + 4 files changed, 117 insertions(+) create mode 100644 .github/workflows/build-wheels.yml create mode 100644 .gitmodules create mode 100755 config.sh create mode 160000 multibuild diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml new file mode 100644 index 0000000000..5430dcdb7a --- /dev/null +++ b/.github/workflows/build-wheels.yml @@ -0,0 +1,86 @@ +name: Build wheels + +on: + push: + branches: [ develop ] + pull_request: + branches: [ develop ] + schedule: + - cron: '0 0 * * sun,wed' + +jobs: + build: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + python-version: [3.6, 3.7, 3.8] + os: [ubuntu-latest, macos-latest] + platform: [x64] + include: + - os: ubuntu-latest + python-version: 3.7 + skip-network-tests: 1 + - os: ubuntu-latest + python-version: 3.8 + skip-network-tests: 1 + - os: macos-latest + travis-os-name: osx # For multibuild + skip-network-tests: 1 + env: + PKG_NAME: gensim + REPO_DIR: gensim + BUILD_COMMIT: HEAD + PLAT: x86_64 + UNICODE_WIDTH: 32 + MB_PYTHON_VERSION: ${{ matrix.python-version }} # MB_PYTHON_VERSION is needed by Multibuild + TEST_DEPENDS: Morfessor==2.0.2a4 python-levenshtein==0.12.0 visdom==0.1.8.9 pytest mock cython nmslib pyemd testfixtures scikit-learn pyemd + DOCKER_TEST_IMAGE: multibuild/xenial_x86_64 + TRAVIS_OS_NAME: ${{ matrix.travis-os-name }} + SKIP_NETWORK_TESTS: ${{ matrix.skip-network-tests }} + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + fetch-depth: 0 + - name: Print environment variables + run: | + echo "PLAT: ${PLAT}" + echo "DOCKER_TEST_IMAGE: ${DOCKER_TEST_IMAGE}" + echo "TEST_DEPENDS: ${TEST_DEPENDS}" + echo "TRAVIS_OS_NAME: ${TRAVIS_OS_NAME}" + echo "SKIP_NETWORK_TESTS: ${SKIP_NETWORK_TESTS}" + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install virtualenv + - name: Build and Install Wheels + run: | + echo ::group::Set up Multibuild + source multibuild/common_utils.sh + source multibuild/travis_steps.sh + source config.sh + echo ::endgroup:: + echo ::group::Before install + before_install + echo ::endgroup:: + echo ::group::Build wheel + build_wheel $REPO_DIR ${{ matrix.PLAT }} + echo ::endgroup:: + echo ::group::Install run + install_run ${{ matrix.PLAT }} + echo ::endgroup:: + - name: Upload wheels to s3://gensim-wheels + if: always() + run: | + pip install wheelhouse-uploader + ls wheelhouse/*.whl + python -m wheelhouse_uploader upload --local-folder wheelhouse/ --no-ssl-check gensim-wheels --provider S3 --no-enable-cdn diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..347fe93043 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "multibuild"] + path = multibuild + url = https://github.com/matthew-brett/multibuild.git diff --git a/config.sh b/config.sh new file mode 100755 index 0000000000..8a2be6e0dd --- /dev/null +++ b/config.sh @@ -0,0 +1,27 @@ +# Define custom utilities + +function pre_build { + # Any stuff that you need to do before you start building the wheels + # Runs in the root directory of this repository. + : +} + +function build_wheel_cmd { + local cmd=${1:-pip_wheel_cmd} + local wheelhouse=$(abspath ${WHEEL_SDIR:-wheelhouse}) + start_spinner + if [ -n "$(is_function "pre_build")" ]; then pre_build; fi + stop_spinner + if [ -n "$BUILD_DEPENDS" ]; then + pip install $(pip_opts) $BUILD_DEPENDS + fi + $cmd $wheelhouse + repair_wheelhouse $wheelhouse +} + +function run_tests { + # Runs tests on installed distribution from an empty directory + python --version + pip freeze + pytest -rfxEXs --durations=20 --disable-warnings --showlocals --pyargs gensim +} diff --git a/multibuild b/multibuild new file mode 160000 index 0000000000..a01ddf7203 --- /dev/null +++ b/multibuild @@ -0,0 +1 @@ +Subproject commit a01ddf72034b184f1b15341fe8cc7c02ea30bcb9