Skip to content

Commit a42d97e

Browse files
committed
Add support for GitHub Actions
Closes #159
1 parent 0375e92 commit a42d97e

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test cibuildwheel on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-18.04, windows-latest, macOS-10.14]
12+
steps:
13+
- uses: actions/checkout@v1
14+
- uses: actions/setup-python@v1
15+
name: Install Python ${{ matrix.python_version }}
16+
with:
17+
python-version: "3.7"
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install -r requirements-dev.txt
22+
- name: Install Visual C++ for Python 2.7
23+
if: startsWith(matrix.os, 'windows')
24+
run: |
25+
choco install vcpython27 -f -y
26+
- name: Test cibuildwheel
27+
run: |
28+
python ./bin/run_tests.py

cibuildwheel/__main__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ def main():
8383
platform = 'macos'
8484
elif os.environ['AGENT_OS'] == 'Windows_NT':
8585
platform = 'windows'
86+
elif 'GITHUB_WORKFLOW' in os.environ:
87+
if sys.platform.startswith('linux'):
88+
platform = 'linux'
89+
elif sys.platform.startswith('darwin'):
90+
platform = 'macos'
91+
else:
92+
platform = 'windows'
8693

8794
if platform is None:
8895
print('cibuildwheel: Unable to detect platform. cibuildwheel should run on your CI server, '

cibuildwheel/windows.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
from .util import prepare_command, get_build_verbosity_extra_flags
1717

1818

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

2223

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

55+
if IS_RUNNING_ON_GITHUB:
56+
python_configurations = [c for c in python_configurations if not c.version.startswith('3.5.')]
57+
5458
# skip builds as required
5559
python_configurations = [c for c in python_configurations if build_selector(c.identifier)]
5660

@@ -71,18 +75,17 @@ def download(url, dest):
7175
file.write(response.read())
7276
finally:
7377
response.close()
74-
if IS_RUNNING_ON_AZURE or IS_RUNNING_ON_TRAVIS:
75-
shell = simple_shell
76-
else:
78+
if IS_RUNNING_ON_APPVEYOR:
7779
run_with_env = os.path.abspath(os.path.join(os.path.dirname(__file__), 'resources', 'appveyor_run_with_env.cmd'))
78-
7980
# run_with_env is a cmd file that sets the right environment variables
8081
# to build on AppVeyor.
8182
def shell(args, env=None, cwd=None):
8283
# print the command executing for the logs
8384
print('+ ' + ' '.join(args))
8485
args = ['cmd', '/E:ON', '/V:ON', '/C', run_with_env] + args
8586
return subprocess.check_call(' '.join(args), env=env, cwd=cwd)
87+
else:
88+
shell = simple_shell
8689

8790
abs_project_dir = os.path.abspath(project_dir)
8891
temp_dir = tempfile.mkdtemp(prefix='cibuildwheel')

test/shared/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import subprocess, sys, os
88

9-
IS_WINDOWS_RUNNING_ON_AZURE = os.path.exists('C:\\hostedtoolcache')
9+
10+
IS_WINDOWS_RUNNING_ON_GITHUB = os.path.exists('C:\\hostedtoolcache') and os.environ.get('GITHUB_WORKFLOW', None) is not None
1011
IS_WINDOWS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'
1112

1213

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

106+
if IS_WINDOWS_RUNNING_ON_GITHUB:
107+
# Python 3.5 isn't supported on GitHub.
108+
templates = [t for t in templates if '-cp35-' not in t]
109+
105110
return [filename.format(package_name=package_name, package_version=package_version)
106111
for filename in templates]
107112

0 commit comments

Comments
 (0)