Add a Linux implementation of environment
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from __future__ import print_function
|
||||
import argparse, os, subprocess, sys, textwrap
|
||||
import argparse, os, subprocess, sys, textwrap, shlex
|
||||
|
||||
import cibuildwheel
|
||||
import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos
|
||||
@@ -72,6 +72,16 @@ def main():
|
||||
project_dir = args.project_dir
|
||||
before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform)
|
||||
skip_config = os.environ.get('CIBW_SKIP', '')
|
||||
environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform) or ''
|
||||
|
||||
environment = {}
|
||||
for key_value in shlex.split(environment_config):
|
||||
try:
|
||||
key, value = key_value.split('=')
|
||||
environment[key] = value
|
||||
except:
|
||||
print('cibuildwheel: Malformed environment option "%s"' % key_value, file=sys.stderr)
|
||||
exit(2)
|
||||
|
||||
skip = BuildSkipper(skip_config)
|
||||
|
||||
@@ -103,6 +113,7 @@ def main():
|
||||
test_requires=test_requires,
|
||||
before_build=before_build,
|
||||
skip=skip,
|
||||
environment=environment,
|
||||
)
|
||||
|
||||
print_preamble(platform, build_options)
|
||||
|
||||
@@ -9,7 +9,7 @@ except ImportError:
|
||||
from pipes import quote as shlex_quote
|
||||
|
||||
|
||||
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip):
|
||||
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip, environment):
|
||||
try:
|
||||
subprocess.check_call(['docker', '--version'])
|
||||
except:
|
||||
@@ -52,6 +52,8 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
||||
set -o xtrace
|
||||
cd /project
|
||||
|
||||
{environment_exports}
|
||||
|
||||
for PYBIN in {pybin_paths}; do
|
||||
# Setup
|
||||
rm -rf /tmp/built_wheel
|
||||
@@ -106,6 +108,9 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be
|
||||
before_build=shlex_quote(
|
||||
prepare_command(before_build, python='python', pip='pip') if before_build else ''
|
||||
),
|
||||
environment_exports=' '.join(
|
||||
('export %s=%s\n' % (key, shlex_quote(value)) for key, value in environment.items())
|
||||
),
|
||||
)
|
||||
|
||||
docker_process = subprocess.Popen([
|
||||
|
||||
Reference in New Issue
Block a user