Skip to content

Commit

Permalink
Add support for GitHub Actions
Browse files Browse the repository at this point in the history
Closes pypa#159
  • Loading branch information
mayeut committed Nov 10, 2019
1 parent 1e102b9 commit a7e24aa
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on: [push, pull_request]

jobs:
test:
name: Test cibuildwheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macOS-10.14]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
name: Install Python ${{ matrix.python_version }}
with:
python-version: "3.7"

- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
- name: Install Visual C++ for Python 2.7
if: startsWith(matrix.os, 'windows')
run: |
choco install vcpython27 -f -y
- name: Test cibuildwheel
run: |
python ./bin/run_tests.py
7 changes: 7 additions & 0 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ def main():
platform = 'macos'
elif os.environ['AGENT_OS'] == 'Windows_NT':
platform = 'windows'
elif 'GITHUB_WORKFLOW' in os.environ:
if sys.platform.startswith('linux'):
platform = 'linux'
elif sys.platform.startswith('darwin'):
platform = 'macos'
else:
platform = 'windows'

if platform is None:
print('cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server, '
Expand Down
13 changes: 8 additions & 5 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
from .util import prepare_command, get_build_verbosity_extra_flags


IS_RUNNING_ON_AZURE = os.path.exists('C:\\hostedtoolcache')
IS_RUNNING_ON_GITHUB = os.environ.get('GITHUB_WORKFLOW', None) is not None
IS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'
IS_RUNNING_ON_APPVEYOR = os.environ.get('APPVEYOR', 'false').lower() == 'true'


def get_python_path(config):
Expand Down Expand Up @@ -51,6 +52,9 @@ def get_python_configurations(build_selector):
# try with (and similar): msiexec /i VCForPython27.msi ALLUSERS=1 ACCEPT=YES /passive
python_configurations = [c for c in python_configurations if not c.version.startswith('2.7.')]

if IS_RUNNING_ON_GITHUB:
python_configurations = [c for c in python_configurations if not c.version.startswith('3.5.')]

# skip builds as required
python_configurations = [c for c in python_configurations if build_selector(c.identifier)]

Expand All @@ -74,18 +78,17 @@ def download(url, dest):
file.write(response.read())
finally:
response.close()
if IS_RUNNING_ON_AZURE or IS_RUNNING_ON_TRAVIS:
shell = simple_shell
else:
if IS_RUNNING_ON_APPVEYOR:
run_with_env = os.path.abspath(os.path.join(os.path.dirname(__file__), 'resources', 'appveyor_run_with_env.cmd'))

# run_with_env is a cmd file that sets the right environment variables
# to build on AppVeyor.
def shell(args, env=None, cwd=None):
# print the command executing for the logs
print('+ ' + ' '.join(args))
args = ['cmd', '/E:ON', '/V:ON', '/C', run_with_env] + args
return subprocess.check_call(' '.join(args), env=env, cwd=cwd)
else:
shell = simple_shell

abs_project_dir = os.path.abspath(project_dir)
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')
Expand Down
7 changes: 6 additions & 1 deletion test/shared/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import subprocess, sys, os

IS_WINDOWS_RUNNING_ON_AZURE = os.path.exists('C:\\hostedtoolcache')

IS_WINDOWS_RUNNING_ON_GITHUB = os.path.exists('C:\\hostedtoolcache') and os.environ.get('GITHUB_WORKFLOW', None) is not None
IS_WINDOWS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'


Expand Down Expand Up @@ -102,6 +103,10 @@ def expected_wheels(package_name, package_version):
# Python 2.7 isn't supported on Travis.
templates = [t for t in templates if '-cp27-' not in t]

if IS_WINDOWS_RUNNING_ON_GITHUB:
# Python 3.5 isn't supported on GitHub.
templates = [t for t in templates if '-cp35-' not in t]

return [filename.format(package_name=package_name, package_version=package_version)
for filename in templates]

Expand Down

0 comments on commit a7e24aa

Please sign in to comment.