Skip to content

Commit 9850864

Browse files
committed
Rename 'environ' to 'env'
1 parent 56359fb commit 9850864

File tree

5 files changed

+37
-39
lines changed

5 files changed

+37
-39
lines changed

cibuildwheel/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def build_in_directory(args: CommandLineArguments) -> None:
231231
)
232232
sys.exit(2)
233233

234-
options = compute_options(platform=platform, command_line_arguments=args, environ=os.environ)
234+
options = compute_options(platform=platform, command_line_arguments=args, env=os.environ)
235235

236236
package_dir = options.globals.package_dir
237237
package_files = {"setup.py", "setup.cfg", "pyproject.toml"}

cibuildwheel/options.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ def __init__(
192192
config_file_path: Path | None = None,
193193
*,
194194
platform: PlatformName,
195-
environ: Mapping[str, str],
195+
env: Mapping[str, str],
196196
disallow: dict[str, set[str]] | None = None,
197197
) -> None:
198198
self.platform = platform
199-
self.environ = environ
199+
self.env = env
200200
self.disallow = disallow or {}
201201

202202
# Open defaults.toml, loading both global and platform sections
@@ -337,8 +337,8 @@ def get(
337337
# get the option from the environment, then the config file, then finally the default.
338338
# platform-specific options are preferred, if they're allowed.
339339
result = _dig_first(
340-
(self.environ if env_plat else {}, plat_envvar),
341-
(self.environ, envvar),
340+
(self.env if env_plat else {}, plat_envvar),
341+
(self.env, envvar),
342342
*[(o.options, name) for o in active_config_overrides],
343343
(self.config_platform_options, name),
344344
(self.config_options, name),
@@ -384,17 +384,17 @@ def __init__(
384384
self,
385385
platform: PlatformName,
386386
command_line_arguments: CommandLineArguments,
387-
environ: Mapping[str, str],
387+
env: Mapping[str, str],
388388
read_config_file: bool = True,
389389
):
390390
self.platform = platform
391391
self.command_line_arguments = command_line_arguments
392-
self.environ = environ
392+
self.env = env
393393

394394
self.reader = OptionsReader(
395395
self.config_file_path if read_config_file else None,
396396
platform=platform,
397-
environ=environ,
397+
env=env,
398398
disallow=DISALLOWED_OPTIONS,
399399
)
400400

@@ -428,13 +428,13 @@ def globals(self) -> GlobalOptions:
428428
test_skip = self.reader.get("test-skip", env_plat=False, sep=" ")
429429

430430
prerelease_pythons = args.prerelease_pythons or strtobool(
431-
self.environ.get("CIBW_PRERELEASE_PYTHONS", "0")
431+
self.env.get("CIBW_PRERELEASE_PYTHONS", "0")
432432
)
433433

434434
# This is not supported in tool.cibuildwheel, as it comes from a standard location.
435435
# Passing this in as an environment variable will override pyproject.toml, setup.cfg, or setup.py
436436
requires_python_str: str | None = (
437-
self.environ.get("CIBW_PROJECT_REQUIRES_PYTHON") or self.package_requires_python_str
437+
self.env.get("CIBW_PROJECT_REQUIRES_PYTHON") or self.package_requires_python_str
438438
)
439439
requires_python = None if requires_python_str is None else SpecifierSet(requires_python_str)
440440

@@ -523,7 +523,7 @@ def build_options(self, identifier: str | None) -> BuildOptions:
523523
if self.platform == "linux":
524524
for env_var_name in environment_pass:
525525
with contextlib.suppress(KeyError):
526-
environment.add(env_var_name, self.environ[env_var_name])
526+
environment.add(env_var_name, self.env[env_var_name])
527527

528528
if dependency_versions == "pinned":
529529
dependency_constraints: None | (
@@ -625,7 +625,7 @@ def defaults(self) -> Options:
625625
return Options(
626626
platform=self.platform,
627627
command_line_arguments=CommandLineArguments.defaults(),
628-
environ={},
628+
env={},
629629
read_config_file=False,
630630
)
631631

@@ -730,11 +730,9 @@ def option_summary_value(self, option_value: Any) -> str:
730730
def compute_options(
731731
platform: PlatformName,
732732
command_line_arguments: CommandLineArguments,
733-
environ: Mapping[str, str],
733+
env: Mapping[str, str],
734734
) -> Options:
735-
options = Options(
736-
platform=platform, command_line_arguments=command_line_arguments, environ=environ
737-
)
735+
options = Options(platform=platform, command_line_arguments=command_line_arguments, env=env)
738736
options.check_for_deprecated_options()
739737
return options
740738

unit_test/linux_build_steps_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_linux_container_split(tmp_path: Path, monkeypatch):
4040
)
4141

4242
monkeypatch.chdir(tmp_path)
43-
options = Options("linux", command_line_arguments=args, environ={})
43+
options = Options("linux", command_line_arguments=args, env={})
4444

4545
python_configurations = cibuildwheel.linux.get_python_configurations(
4646
options.globals.build_selector, options.globals.architectures

unit_test/options_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_options_1(tmp_path, monkeypatch):
4747

4848
monkeypatch.setattr(platform_module, "machine", lambda: "x86_64")
4949

50-
options = Options(platform="linux", command_line_arguments=args, environ={})
50+
options = Options(platform="linux", command_line_arguments=args, env={})
5151

5252
identifiers = get_build_identifiers(
5353
platform="linux",
@@ -89,7 +89,7 @@ def test_passthrough(tmp_path, monkeypatch):
8989

9090
monkeypatch.setattr(platform_module, "machine", lambda: "x86_64")
9191

92-
options = Options(platform="linux", command_line_arguments=args, environ={"EXAMPLE_ENV": "ONE"})
92+
options = Options(platform="linux", command_line_arguments=args, env={"EXAMPLE_ENV": "ONE"})
9393

9494
default_build_options = options.build_options(identifier=None)
9595

@@ -118,7 +118,7 @@ def test_passthrough_evil(tmp_path, monkeypatch, env_var_value):
118118
options = Options(
119119
platform="linux",
120120
command_line_arguments=args,
121-
environ={"CIBW_ENVIRONMENT_PASS_LINUX": "ENV_VAR", "ENV_VAR": env_var_value},
121+
env={"CIBW_ENVIRONMENT_PASS_LINUX": "ENV_VAR", "ENV_VAR": env_var_value},
122122
)
123123

124124
parsed_environment = options.build_options(identifier=None).environment
@@ -153,7 +153,7 @@ def test_toml_environment_evil(tmp_path, monkeypatch, env_var_value):
153153
)
154154
)
155155

156-
options = Options(platform="linux", command_line_arguments=args, environ={})
156+
options = Options(platform="linux", command_line_arguments=args, env={})
157157
parsed_environment = options.build_options(identifier=None).environment
158158
assert parsed_environment.as_dictionary(prev_environment={}) == {"EXAMPLE": env_var_value}
159159

@@ -189,7 +189,7 @@ def test_toml_environment_quoting(tmp_path: Path, toml_assignment, result_value)
189189
)
190190
)
191191

192-
options = Options(platform="linux", command_line_arguments=args, environ={})
192+
options = Options(platform="linux", command_line_arguments=args, env={})
193193
parsed_environment = options.build_options(identifier=None).environment
194194
environment_values = parsed_environment.as_dictionary(
195195
prev_environment={**os.environ, "PARAM": "spam"},

unit_test/options_toml_test.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_simple_settings(tmp_path, platform, fname):
3535
config_file_path: Path = tmp_path / fname
3636
config_file_path.write_text(PYPROJECT_1)
3737

38-
options_reader = OptionsReader(config_file_path, platform=platform, environ={})
38+
options_reader = OptionsReader(config_file_path, platform=platform, env={})
3939

4040
assert options_reader.get("build", env_plat=False, sep=" ") == "cp39*"
4141

@@ -78,7 +78,7 @@ def test_envvar_override(tmp_path, platform, monkeypatch):
7878
options_reader = OptionsReader(
7979
config_file_path,
8080
platform=platform,
81-
environ={
81+
env={
8282
"CIBW_BUILD": "cp38*",
8383
"CIBW_MANYLINUX_X86_64_IMAGE": "manylinux_2_24",
8484
"CIBW_TEST_COMMAND": "mytest",
@@ -108,13 +108,13 @@ def test_project_global_override_default_platform(tmp_path, platform):
108108
repair-wheel-command = "repair-project-global"
109109
"""
110110
)
111-
options_reader = OptionsReader(pyproject_toml, platform=platform, environ={})
111+
options_reader = OptionsReader(pyproject_toml, platform=platform, env={})
112112
assert options_reader.get("repair-wheel-command") == "repair-project-global"
113113

114114

115115
def test_env_global_override_default_platform(tmp_path, platform, monkeypatch):
116116
options_reader = OptionsReader(
117-
platform=platform, environ={"CIBW_REPAIR_WHEEL_COMMAND": "repair-env-global"}
117+
platform=platform, env={"CIBW_REPAIR_WHEEL_COMMAND": "repair-env-global"}
118118
)
119119
assert options_reader.get("repair-wheel-command") == "repair-env-global"
120120

@@ -134,7 +134,7 @@ def test_env_global_override_project_platform(tmp_path, platform, monkeypatch):
134134
options_reader = OptionsReader(
135135
pyproject_toml,
136136
platform=platform,
137-
environ={
137+
env={
138138
"CIBW_REPAIR_WHEEL_COMMAND": "repair-env-global",
139139
},
140140
)
@@ -155,7 +155,7 @@ def test_global_platform_order(tmp_path, platform):
155155
repair-wheel-command = "repair-project-global"
156156
"""
157157
)
158-
options_reader = OptionsReader(pyproject_toml, platform=platform, environ={})
158+
options_reader = OptionsReader(pyproject_toml, platform=platform, env={})
159159
assert options_reader.get("repair-wheel-command") == f"repair-project-{platform}"
160160

161161

@@ -171,7 +171,7 @@ def test_unexpected_key(tmp_path):
171171
)
172172

173173
with pytest.raises(ConfigOptionError) as excinfo:
174-
OptionsReader(pyproject_toml, platform="linux", environ={})
174+
OptionsReader(pyproject_toml, platform="linux", env={})
175175

176176
assert "repair-wheel-command" in str(excinfo.value)
177177

@@ -188,7 +188,7 @@ def test_underscores_in_key(tmp_path):
188188
)
189189

190190
with pytest.raises(ConfigOptionError) as excinfo:
191-
OptionsReader(pyproject_toml, platform="linux", environ={})
191+
OptionsReader(pyproject_toml, platform="linux", env={})
192192

193193
assert "repair-wheel-command" in str(excinfo.value)
194194

@@ -202,7 +202,7 @@ def test_unexpected_table(tmp_path):
202202
"""
203203
)
204204
with pytest.raises(ConfigOptionError):
205-
OptionsReader(pyproject_toml, platform="linux", environ={})
205+
OptionsReader(pyproject_toml, platform="linux", env={})
206206

207207

208208
def test_unsupported_join(tmp_path):
@@ -213,7 +213,7 @@ def test_unsupported_join(tmp_path):
213213
build = ["1", "2"]
214214
"""
215215
)
216-
options_reader = OptionsReader(pyproject_toml, platform="linux", environ={})
216+
options_reader = OptionsReader(pyproject_toml, platform="linux", env={})
217217

218218
assert "1, 2" == options_reader.get("build", sep=", ")
219219
with pytest.raises(ConfigOptionError):
@@ -229,9 +229,9 @@ def test_disallowed_a(tmp_path):
229229
"""
230230
)
231231
disallow = {"windows": {"manylinux-x86_64-image"}}
232-
OptionsReader(pyproject_toml, platform="linux", disallow=disallow, environ={})
232+
OptionsReader(pyproject_toml, platform="linux", disallow=disallow, env={})
233233
with pytest.raises(ConfigOptionError):
234-
OptionsReader(pyproject_toml, platform="windows", disallow=disallow, environ={})
234+
OptionsReader(pyproject_toml, platform="windows", disallow=disallow, env={})
235235

236236

237237
def test_environment_override_empty(tmp_path, monkeypatch):
@@ -247,7 +247,7 @@ def test_environment_override_empty(tmp_path, monkeypatch):
247247
options_reader = OptionsReader(
248248
pyproject_toml,
249249
platform="linux",
250-
environ={
250+
env={
251251
"CIBW_MANYLINUX_I686_IMAGE": "",
252252
"CIBW_MANYLINUX_AARCH64_IMAGE": "manylinux1",
253253
},
@@ -320,7 +320,7 @@ def test_pyproject_2(tmp_path, platform):
320320
pyproject_toml: Path = tmp_path / "pyproject.toml"
321321
pyproject_toml.write_text(PYPROJECT_2)
322322

323-
options_reader = OptionsReader(config_file_path=pyproject_toml, platform=platform, environ={})
323+
options_reader = OptionsReader(config_file_path=pyproject_toml, platform=platform, env={})
324324
assert options_reader.get("test-command") == "pyproject"
325325

326326
with options_reader.identifier("random"):
@@ -344,7 +344,7 @@ def test_overrides_not_a_list(tmp_path, platform):
344344
)
345345

346346
with pytest.raises(ConfigOptionError):
347-
OptionsReader(config_file_path=pyproject_toml, platform=platform, environ={})
347+
OptionsReader(config_file_path=pyproject_toml, platform=platform, env={})
348348

349349

350350
def test_config_settings(tmp_path):
@@ -357,7 +357,7 @@ def test_config_settings(tmp_path):
357357
"""
358358
)
359359

360-
options_reader = OptionsReader(config_file_path=pyproject_toml, platform="linux", environ={})
360+
options_reader = OptionsReader(config_file_path=pyproject_toml, platform="linux", env={})
361361
assert (
362362
options_reader.get("config-settings", table={"item": '{k}="{v}"', "sep": " "})
363363
== 'example="one" other="two" other="three"'
@@ -373,7 +373,7 @@ def test_pip_config_settings(tmp_path):
373373
"""
374374
)
375375

376-
options_reader = OptionsReader(config_file_path=pyproject_toml, platform="linux", environ={})
376+
options_reader = OptionsReader(config_file_path=pyproject_toml, platform="linux", env={})
377377
assert (
378378
options_reader.get(
379379
"config-settings", table={"item": "--config-settings='{k}=\"{v}\"'", "sep": " "}

0 commit comments

Comments
 (0)