From c4a4ca2bf86a29262e410c1f31a1f690a8fe17a7 Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Fri, 2 Apr 2021 14:41:57 +0200 Subject: [PATCH] Fix #3586: NumPy versions --- .github/actions/numpy_vers/README.md | 14 ++++ .github/actions/numpy_vers/action.yml | 93 +++++++++++++++++++++++++ .github/actions/python-build/action.yml | 8 +++ .github/workflows/macOS-amd64.yml | 17 ++++- 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 .github/actions/numpy_vers/README.md create mode 100644 .github/actions/numpy_vers/action.yml diff --git a/.github/actions/numpy_vers/README.md b/.github/actions/numpy_vers/README.md new file mode 100644 index 00000000..57d28ece --- /dev/null +++ b/.github/actions/numpy_vers/README.md @@ -0,0 +1,14 @@ +GitHub Action to set NumPy versions +=================================== + +This actions aims at computing correct values for NumPy dependencies: + - `NUMPY_BUILD_VERSION`: range of accepted versions at Python binding build time + - `NUMPY_DEP_VERSION`: range of accepted versions for execution time + +Versions are set considering several factors: + - API and ABI compatibility ; otherwise we can have the binding wrapper + throwing errors like "Illegal instruction", or computing wrong values + because of changed memory layout + - Wheels availability: for CI and end users, we want to avoid having to + rebuild numpy so we stick to versions where there is an existing upstream + `wheel` file diff --git a/.github/actions/numpy_vers/action.yml b/.github/actions/numpy_vers/action.yml new file mode 100644 index 00000000..9671df81 --- /dev/null +++ b/.github/actions/numpy_vers/action.yml @@ -0,0 +1,93 @@ +name: "get numpy versions" +description: "Get proper NumPy build and runtime versions dependencies range" +inputs: + pyver: + description: "Python version" + required: true +outputs: + build_version: + description: "NumPy build dependency" + value: ${{ steps.numpy.outputs.build }} + dep_version: + description: "NumPy runtime dependency" + value: ${{ steps.numpy.outputs.dep }} +runs: + using: "composite" + steps: + - id: numpy + run: | + NUMPY_BUILD_VERSION="==1.7.0" + NUMPY_DEP_VERSION=">=1.7.0" + + OS=$(uname -s) + ARCH=$(uname -m) + + case "${OS}:${ARCH}" in + Linux:x86_64) + case "${{ inputs.pyver }}" in + 3.7*) + NUMPY_BUILD_VERSION="==1.14.5" + NUMPY_DEP_VERSION=">=1.14.5" + ;; + 3.8*) + NUMPY_BUILD_VERSION="==1.17.3" + NUMPY_DEP_VERSION=">=1.17.3" + ;; + 3.9*) + NUMPY_BUILD_VERSION="==1.19.4" + NUMPY_DEP_VERSION=">=1.19.4" + ;; + esac + ;; + + Darwin:*) + case "${{ inputs.pyver }}" in + 3.6*) + NUMPY_BUILD_VERSION="==1.9.0" + NUMPY_DEP_VERSION=">=1.9.0" + ;; + 3.7*) + NUMPY_BUILD_VERSION="==1.14.5" + NUMPY_DEP_VERSION=">=1.14.5,<=1.17.0" + ;; + 3.8*) + NUMPY_BUILD_VERSION="==1.17.3" + NUMPY_DEP_VERSION=">=1.17.3,<=1.17.3" + ;; + 3.9*) + NUMPY_BUILD_VERSION="==1.19.4" + NUMPY_DEP_VERSION=">=1.19.4" + ;; + esac + ;; + + # TODO: 'Windows*' might not be good + Windows*:x86_64) + case "${{ inputs.pyver }}" in + 3.5*) + NUMPY_BUILD_VERSION="==1.11.0" + NUMPY_DEP_VERSION=">=1.11.0,<1.12.0" + ;; + 3.6*) + NUMPY_BUILD_VERSION="==1.12.0" + NUMPY_DEP_VERSION=">=1.12.0,<1.14.5" + ;; + 3.7*) + NUMPY_BUILD_VERSION="==1.14.5" + NUMPY_DEP_VERSION=">=1.14.5,<=1.17.0" + ;; + 3.8*) + NUMPY_BUILD_VERSION="==1.17.3" + NUMPY_DEP_VERSION=">=1.17.3,<=1.17.3" + ;; + 3.9*) + NUMPY_BUILD_VERSION="==1.19.4" + NUMPY_DEP_VERSION=">=1.19.4" + ;; + esac + ;; + esac + + echo "::set-output name=build::${NUMPY_BUILD_VERSION}" + echo "::set-output name=dep::${NUMPY_DEP_VERSION}" + shell: bash diff --git a/.github/actions/python-build/action.yml b/.github/actions/python-build/action.yml index 428a5eb1..24c607d1 100644 --- a/.github/actions/python-build/action.yml +++ b/.github/actions/python-build/action.yml @@ -4,6 +4,12 @@ inputs: build_flavor: description: "Python package name" required: true + numpy_build: + description: "NumPy build dependecy" + required: true + numpy_dep: + description: "NumPy runtime dependecy" + required: true local_cflags: description: "CFLAGS for Python package" required: false @@ -32,6 +38,8 @@ runs: PROJECT_NAME="deepspeech-tflite" fi + NUMPY_BUILD_VERSION="${{ inputs.numpy_build }}" \ + NUMPY_DEP_VERSION="${{ inputs.numpy_dep }}" \ EXTRA_CFLAGS=${{ inputs.local_cflags }} \ EXTRA_LDFLAGS=${{ inputs.local_ldflags }} \ EXTRA_LIBS=${{ inputs.local_libs }} \ diff --git a/.github/workflows/macOS-amd64.yml b/.github/workflows/macOS-amd64.yml index 15f12dca..26648dfa 100644 --- a/.github/workflows/macOS-amd64.yml +++ b/.github/workflows/macOS-amd64.yml @@ -55,6 +55,9 @@ jobs: name: "Build CTC decoder Python package for testing" needs: [ swig_macOS ] runs-on: macos-10.15 + strategy: + matrix: + python-version: [3.6.8] if: ${{ github.event_name == 'pull_request' }} steps: - uses: actions/checkout@v2 @@ -62,7 +65,7 @@ jobs: fetch-depth: 0 - uses: ./.github/actions/install-python-upstream with: - version: 3.6.8 + version: ${{ matrix.python-version }} - run: | python --version pip --version @@ -74,7 +77,13 @@ jobs: ls -hal ${{ github.workspace }}/native_client/ds-swig/bin ln -s ds-swig ${{ github.workspace }}/native_client/ds-swig/bin/swig chmod +x ${{ github.workspace }}/native_client/ds-swig/bin/ds-swig ${{ github.workspace }}/native_client/ds-swig/bin/swig + - id: get_numpy + uses: ./.github/actions/numpy_vers + with: + pyver: ${{ matrix.python-version }} - run: | + NUMPY_BUILD_VERSION=${{ steps.get_numpy.outputs.build_version }} \ + NUMPY_DEP_VERSION=${{ steps.get_numpy.outputs.dep_version }} \ make -C native_client/ctcdecode/ \ NUM_PROCESSES=$(sysctl hw.ncpu |cut -d' ' -f2) \ bindings @@ -276,9 +285,15 @@ jobs: #- uses: actions/setup-python@v2 # with: # python-version: ${{ matrix.python-version }} + - id: get_numpy + uses: ./.github/actions/numpy_vers + with: + pyver: ${{ matrix.python-version }} - uses: ./.github/actions/python-build with: build_flavor: ${{ matrix.build-flavor }} + numpy_build: "${{ steps.get_numpy.outputs.build_version }}" + numpy_dep: "${{ steps.get_numpy.outputs.dep_version }}" - uses: actions/upload-artifact@v2 with: name: "deepspeech-${{ matrix.build-flavor }}-${{ matrix.python-version }}.whl"