add environment evaluation
This commit is contained in:
+15
-1
@@ -135,7 +135,21 @@ def build(options: BuildOptions) -> None:
|
||||
|
||||
if options.before_all:
|
||||
before_all_prepared = prepare_command(options.before_all, project='/project', package=options.package_dir)
|
||||
call(['docker', 'exec', '-i', container_name] + shell_cmd, universal_newlines=True, input=before_all_prepared)
|
||||
task = """
|
||||
PS4=' + '
|
||||
|
||||
set -o errexit
|
||||
set -o xtrace
|
||||
|
||||
{environment_exports}
|
||||
|
||||
{before_all_prepared}
|
||||
|
||||
""".format(
|
||||
environment_exports='\n'.join(options.environment.as_shell_commands()),
|
||||
before_all_prepared=before_all_prepared
|
||||
)
|
||||
call(['docker', 'exec', '-i', container_name] + shell_cmd, universal_newlines=True, input=task)
|
||||
|
||||
for config in platform_configs:
|
||||
if options.dependency_constraints:
|
||||
|
||||
@@ -177,8 +177,9 @@ def build(options: BuildOptions) -> None:
|
||||
repaired_wheel_dir = temp_dir / 'repaired_wheel'
|
||||
|
||||
if options.before_all:
|
||||
env = options.environment.as_dictionary(prev_environment=os.environ)
|
||||
before_all_prepared = prepare_command(options.before_all, project='.', package=options.package_dir)
|
||||
call([before_all_prepared], shell=True)
|
||||
call([before_all_prepared], shell=True, env=env)
|
||||
|
||||
python_configurations = get_python_configurations(options.build_selector)
|
||||
|
||||
|
||||
@@ -163,8 +163,9 @@ def build(options: BuildOptions) -> None:
|
||||
download('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', nuget)
|
||||
|
||||
if options.before_all:
|
||||
env = options.environment.as_dictionary(prev_environment=os.environ)
|
||||
before_all_prepared = prepare_command(options.before_all, project='.', package=options.package_dir)
|
||||
shell([before_all_prepared])
|
||||
shell([before_all_prepared], env=env)
|
||||
|
||||
python_configurations = get_python_configurations(options.build_selector)
|
||||
for config in python_configurations:
|
||||
|
||||
@@ -198,6 +198,8 @@ This option is added mainly for linux build, because linux wheels are build in i
|
||||
|
||||
The placeholder `{package}` can be used here; it will be replaced by the path to the package being built by `cibuildwheel`.
|
||||
|
||||
For windows and macos `CIBW_BEFORE_ALL` python interpreter is same as `cibuildwheel` is run. For linux it is default interpreter for docker image.
|
||||
|
||||
Platform-specific variants also available:<br/>
|
||||
`CIBW_BEFORE_ALL_MACOS` | `CIBW_BEFORE_ALL_WINDOWS` | `CIBW_BEFORE_ALL_LINUX`
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ def test():
|
||||
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
|
||||
# write python version information to a temporary file, this is
|
||||
# checked in setup.py
|
||||
'CIBW_BEFORE_ALL': '''python -c "open('{project}/text_info.txt', 'w').write('sample text')"''',
|
||||
'CIBW_BEFORE_ALL': '''python -c "import os;open('{project}/text_info.txt', 'w').write('sample text '+os.environ.get('TEST_VAL', ''))"''',
|
||||
'CIBW_ENVIRONMENT': "TEST_VAL='123'"
|
||||
})
|
||||
|
||||
# also check that we got the right wheels
|
||||
|
||||
@@ -9,7 +9,7 @@ with open("text_info.txt") as f:
|
||||
stored_text = f.read()
|
||||
|
||||
print("## stored text: " + stored_text)
|
||||
assert stored_text == "sample text"
|
||||
assert stored_text == "sample text 123"
|
||||
|
||||
|
||||
setup(
|
||||
|
||||
Reference in New Issue
Block a user