Adding CIBW_BUILD option and changing util.BuildSkipper to util.BuildSelector
This commit is contained in:
@@ -4,7 +4,7 @@ import argparse, os, subprocess, sys, textwrap
|
|||||||
import cibuildwheel
|
import cibuildwheel
|
||||||
import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos
|
import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos
|
||||||
from cibuildwheel.environment import parse_environment, EnvironmentParseError
|
from cibuildwheel.environment import parse_environment, EnvironmentParseError
|
||||||
from cibuildwheel.util import BuildSkipper, Unbuffered
|
from cibuildwheel.util import BuildSelector, Unbuffered
|
||||||
|
|
||||||
def get_option_from_environment(option_name, platform=None, default=None):
|
def get_option_from_environment(option_name, platform=None, default=None):
|
||||||
'''
|
'''
|
||||||
@@ -83,7 +83,7 @@ def main():
|
|||||||
project_dir = args.project_dir
|
project_dir = args.project_dir
|
||||||
before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform)
|
before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform)
|
||||||
build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform, default='')
|
build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform, default='')
|
||||||
skip_config = os.environ.get('CIBW_SKIP', '')
|
build_config, skip_config = os.environ.get('CIBW_BUILD', '*'), os.environ.get('CIBW_SKIP', '')
|
||||||
environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform, default='')
|
environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform, default='')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -99,7 +99,7 @@ def main():
|
|||||||
traceback.print_exc(None, sys.stderr)
|
traceback.print_exc(None, sys.stderr)
|
||||||
exit(2)
|
exit(2)
|
||||||
|
|
||||||
skip = BuildSkipper(skip_config)
|
selection = BuildSelector(build_config, skip_config)
|
||||||
|
|
||||||
# Add CIBUILDWHEEL environment variable
|
# Add CIBUILDWHEEL environment variable
|
||||||
# This needs to be passed on to the docker container in linux.py
|
# This needs to be passed on to the docker container in linux.py
|
||||||
@@ -134,7 +134,7 @@ def main():
|
|||||||
test_requires=test_requires,
|
test_requires=test_requires,
|
||||||
before_build=before_build,
|
before_build=before_build,
|
||||||
build_verbosity=build_verbosity,
|
build_verbosity=build_verbosity,
|
||||||
skip=skip,
|
selection=selection,
|
||||||
environment=environment,
|
environment=environment,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ except ImportError:
|
|||||||
from pipes import quote as shlex_quote
|
from pipes import quote as shlex_quote
|
||||||
|
|
||||||
|
|
||||||
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, skip, environment, manylinux1_images):
|
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, selection, environment, manylinux1_images):
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['docker', '--version'])
|
subprocess.check_call(['docker', '--version'])
|
||||||
except:
|
except:
|
||||||
@@ -36,7 +36,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
]
|
]
|
||||||
|
|
||||||
# skip builds as required
|
# skip builds as required
|
||||||
python_configurations = [c for c in python_configurations if not skip(c.identifier)]
|
python_configurations = [c for c in python_configurations if selection(c.identifier)]
|
||||||
|
|
||||||
platforms = [
|
platforms = [
|
||||||
('manylinux1_x86_64', manylinux1_images.get('x86_64') or 'quay.io/pypa/manylinux1_x86_64'),
|
('manylinux1_x86_64', manylinux1_images.get('x86_64') or 'quay.io/pypa/manylinux1_x86_64'),
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ except ImportError:
|
|||||||
from .util import prepare_command, get_build_verbosity_extra_flags
|
from .util import prepare_command, get_build_verbosity_extra_flags
|
||||||
|
|
||||||
|
|
||||||
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, skip, environment):
|
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, selection, environment):
|
||||||
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url'])
|
PythonConfiguration = namedtuple('PythonConfiguration', ['version', 'identifier', 'url'])
|
||||||
python_configurations = [
|
python_configurations = [
|
||||||
PythonConfiguration(version='2.7', identifier='cp27-macosx_10_6_intel', url='https://www.python.org/ftp/python/2.7.15/python-2.7.15-macosx10.6.pkg'),
|
PythonConfiguration(version='2.7', identifier='cp27-macosx_10_6_intel', url='https://www.python.org/ftp/python/2.7.15/python-2.7.15-macosx10.6.pkg'),
|
||||||
@@ -42,7 +42,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
call(['curl', '-L', '-o', get_pip_script, get_pip_url])
|
call(['curl', '-L', '-o', get_pip_script, get_pip_url])
|
||||||
|
|
||||||
for config in python_configurations:
|
for config in python_configurations:
|
||||||
if skip(config.identifier):
|
if not selection(config.identifier):
|
||||||
print('cibuildwheel: Skipping build %s' % config.identifier, file=sys.stderr)
|
print('cibuildwheel: Skipping build %s' % config.identifier, file=sys.stderr)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,18 @@ def get_build_verbosity_extra_flags(level):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
class BuildSkipper(object):
|
class BuildSelector(object):
|
||||||
def __init__(self, skip_config):
|
def __init__(self, build_config, skip_config):
|
||||||
self.patterns = skip_config.split()
|
self.build_patterns = build_config.split()
|
||||||
|
self.skip_patterns = skip_config.split()
|
||||||
|
|
||||||
def __call__(self, build_id):
|
def __call__(self, build_id):
|
||||||
return any(fnmatch(build_id, pattern) for pattern in self.patterns)
|
def match_any(patterns):
|
||||||
|
return any(fnmatch(build_id, pattern) for pattern in patterns)
|
||||||
|
return match_any(self.build_patterns) and not match_any(self.skip_patterns)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'BuildSkipper(%r)' % ' '.join(self.patterns)
|
return 'BuildSelector({!r} - {!r})'.format(' '.join(self.build_patterns), ' '.join(self.skip_patterns))
|
||||||
|
|
||||||
|
|
||||||
# Taken from https://stackoverflow.com/a/107717
|
# Taken from https://stackoverflow.com/a/107717
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from glob import glob
|
|||||||
from .util import prepare_command, get_build_verbosity_extra_flags
|
from .util import prepare_command, get_build_verbosity_extra_flags
|
||||||
|
|
||||||
|
|
||||||
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, skip, environment):
|
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, build_verbosity, selection, environment):
|
||||||
# run_with_env is a cmd file that sets the right environment variables to
|
# run_with_env is a cmd file that sets the right environment variables to
|
||||||
run_with_env = os.path.join(tempfile.gettempdir(), 'appveyor_run_with_env.cmd')
|
run_with_env = os.path.join(tempfile.gettempdir(), 'appveyor_run_with_env.cmd')
|
||||||
if not os.path.exists(run_with_env):
|
if not os.path.exists(run_with_env):
|
||||||
@@ -45,7 +45,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
|||||||
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
|
built_wheel_dir = os.path.join(temp_dir, 'built_wheel')
|
||||||
|
|
||||||
for config in python_configurations:
|
for config in python_configurations:
|
||||||
if skip(config.identifier):
|
if not selection(config.identifier):
|
||||||
print('cibuildwheel: Skipping build %s' % config.identifier, file=sys.stderr)
|
print('cibuildwheel: Skipping build %s' % config.identifier, file=sys.stderr)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user