Skip to content

Commit

Permalink
Build wheels for Python 2.7 and 3.5, and PyPy 2.7 and 3.6 (and 3.7 on…
Browse files Browse the repository at this point in the history
… win32)
  • Loading branch information
YannickJadoul committed Feb 1, 2022
1 parent 647160f commit cfa2a4b
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
75 changes: 74 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,79 @@ jobs:
path: wheelhouse/praat_parselmouth-*-cp39-cp39-*manylinux2010_x86_64*.whl
if-no-files-found: error

legacy-wheels:
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
cibw-arch: manylinux_x86_64
- runs-on: ubuntu-latest
cibw-arch: manylinux_i686
- runs-on: macos-10.15
cibw-arch: macosx_x86_64
- runs-on: windows-latest
cibw-arch: win_amd64
- runs-on: windows-latest
cibw-arch: win32
python-arch: x86

name: Wheels (legacy) • ${{ matrix.cibw-arch }}
runs-on: ${{ matrix.runs-on }}
if: startsWith(github.ref, 'refs/heads/docs') != true

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: ${{ matrix.python-arch }}

- name: Setup CMake
uses: jwlawson/[email protected]

- name: Install requirements
run: |
python -m pip install "cibuildwheel<2" twine
- name: Configure cibuildwheel
shell: bash
run: |
CMAKE_ARCH="${{ matrix.cibw-arch == 'win32' && '-A Win32' || '' }}"
echo "DISTUTILS_USE_SDK=1" >> $GITHUB_ENV
echo "MSSdk=1" >> $GITHUB_ENV
echo "CIBW_BUILD=cp27-${{ matrix.cibw-arch }} cp35-${{ matrix.cibw-arch }} pp27-${{ matrix.cibw-arch }} pp36-${{ matrix.cibw-arch }} ${{ matrix.cibw-arch == 'win32' && 'pp37-win32' || '' }}" >> $GITHUB_ENV
echo "CIBW_MANYLINUX_X86_64_IMAGE=manylinux2010" >> $GITHUB_ENV
echo "CIBW_MANYLINUX_I686_IMAGE=manylinux2010" >> $GITHUB_ENV
CIBW_ENVIRONMENT_COMMON="PARSELMOUTH_EXTRA_CMAKE_ARGS=\"-DPREBUILT_DEPENDENCIES=\$(python -c 'import os; print(os.getcwd().replace(os.path.sep, '/'))')/build_dependencies\" CMAKE_BUILD_PARALLEL_LEVEL=2"
echo "CIBW_ENVIRONMENT=$CIBW_ENVIRONMENT_COMMON" >> $GITHUB_ENV
echo "CIBW_ENVIRONMENT_LINUX=$CIBW_ENVIRONMENT_COMMON PIP_ONLY_BINARY='numpy'" >> $GITHUB_ENV
echo "CIBW_ENVIRONMENT_MACOS=$CIBW_ENVIRONMENT_COMMON MACOSX_DEPLOYMENT_TARGET=10.9" >> $GITHUB_ENV
CIBW_BEFORE_ALL_COMMON="pip install cmake && cmake -S . -B build_dependencies $CMAKE_ARCH && cmake --build build_dependencies --target praat -j 2"
echo "CIBW_BEFORE_ALL=$CIBW_BEFORE_ALL_COMMON" >> $GITHUB_ENV
echo "CIBW_BEFORE_ALL_WINDOWS=$CIBW_BEFORE_ALL_COMMON --config Release" >> $GITHUB_ENV
echo "CIBW_BEFORE_BUILD=python -m pip install -U pip && rm -rf _skbuild" >> $GITHUB_ENV
- name: Run cibuildwheel
run: |
cibuildwheel
- name: Check built wheels
run: |
twine check wheelhouse/*
- name: Upload built wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: wheelhouse/praat_parselmouth-*.whl
if-no-files-found: error

trigger_rtd:
name: Trigger ReadTheDocs build
runs-on: ubuntu-latest
Expand All @@ -170,7 +243,7 @@ jobs:
name: Create release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [sdist, wheels]
needs: [sdist, wheels, legacy-wheels]

steps:
- name: Collect sdist and wheels
Expand Down
27 changes: 27 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with Parselmouth. If not, see <http://www.gnu.org/licenses/>

from __future__ import print_function

import io
import os
import re
Expand All @@ -28,6 +30,31 @@
raise


def patched_WindowsPlatform_init(self):
import textwrap
from skbuild.platform_specifics.windows import WindowsPlatform, CMakeVisualStudioCommandLineGenerator, CMakeVisualStudioIDEGenerator

super(WindowsPlatform, self).__init__()

self._vs_help = textwrap.dedent("""
Building Windows wheels for requires Microsoft Visual Studio 2017 or 2019:
https://visualstudio.microsoft.com/vs/
""").strip()

supported_vs_years = [("2019", "v141"), ("2017", "v141")]
for vs_year, vs_toolset in supported_vs_years:
self.default_generators.extend([
CMakeVisualStudioCommandLineGenerator("Ninja", vs_year, vs_toolset),
CMakeVisualStudioIDEGenerator(vs_year, vs_toolset),
CMakeVisualStudioCommandLineGenerator("NMake Makefiles", vs_year, vs_toolset),
CMakeVisualStudioCommandLineGenerator("NMake Makefiles JOM", vs_year, vs_toolset)
])

import skbuild.platform_specifics.windows
skbuild.platform_specifics.windows.WindowsPlatform.__init__ = patched_WindowsPlatform_init


def find_version(*file_paths):
with io.open(os.path.join(os.path.dirname(__file__), "src", "version.h"), encoding='utf8') as f:
version_file = f.read()
Expand Down

0 comments on commit cfa2a4b

Please sign in to comment.