Skip to content

Commit 0fbca36

Browse files
committed
Remove merge_config_settings
1 parent ae23fc2 commit 0fbca36

File tree

4 files changed

+6
-126
lines changed

4 files changed

+6
-126
lines changed

src/pip/_internal/cli/req_command.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from pip._internal.req.req_install import InstallRequirement
3535
from pip._internal.resolution.base import BaseResolver
3636
from pip._internal.self_outdated_check import pip_self_version_check
37-
from pip._internal.utils.misc import merge_config_settings
3837
from pip._internal.utils.temp_dir import (
3938
TempDirectory,
4039
TempDirectoryTypeRegistry,
@@ -435,21 +434,14 @@ def get_requirements(
435434
for parsed_req in parse_requirements(
436435
filename, finder=finder, options=options, session=session
437436
):
438-
req_config_settings = (
439-
parsed_req.options.get("config_settings")
440-
if parsed_req.options
441-
else None
442-
)
443-
cli_config_settings = getattr(options, "config_settings", None)
444-
config_settings = merge_config_settings(
445-
req_config_settings, cli_config_settings
446-
)
447437
req_to_add = install_req_from_parsed_requirement(
448438
parsed_req,
449439
isolated=options.isolated_mode,
450440
use_pep517=options.use_pep517,
451441
user_supplied=True,
452-
config_settings=config_settings,
442+
config_settings=parsed_req.options.get("config_settings")
443+
if parsed_req.options
444+
else None,
453445
)
454446
requirements.append(req_to_add)
455447

src/pip/_internal/utils/misc.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"remove_auth_from_url",
6262
"check_externally_managed",
6363
"ConfiguredBuildBackendHookCaller",
64-
"merge_config_settings",
6564
]
6665

6766
logger = logging.getLogger(__name__)
@@ -729,31 +728,3 @@ def prepare_metadata_for_build_editable(
729728
config_settings=cs,
730729
_allow_fallback=_allow_fallback,
731730
)
732-
733-
734-
def merge_config_settings(
735-
reqs_settings: Optional[Dict[str, Union[str, List[str]]]],
736-
cli_settings: Optional[Dict[str, Union[str, List[str]]]],
737-
) -> Optional[Dict[str, Union[str, List[str]]]]:
738-
if not reqs_settings or not cli_settings:
739-
return reqs_settings or cli_settings
740-
741-
dd: Dict[str, Union[str, List[str]]] = {}
742-
for d in (reqs_settings, cli_settings):
743-
for k, v in d.items():
744-
if k in dd:
745-
value = dd[k]
746-
if isinstance(value, list):
747-
if isinstance(v, list):
748-
value.extend(v)
749-
else:
750-
value.append(v)
751-
else:
752-
if isinstance(v, str):
753-
value = [value, v]
754-
else:
755-
value = [value, *v]
756-
dd[k] = value
757-
else:
758-
dd[k] = v
759-
return dd

tests/functional/test_config_settings.py

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -174,68 +174,11 @@ def test_install_config_reqs(script: PipTestEnvironment) -> None:
174174
)
175175
script.scratch_path.joinpath("reqs.txt").write_text(
176176
'foo --config-settings "--build-option=--cffi" '
177-
'--config-settings "--build-option=--avx2"'
177+
'--config-settings "--build-option=--avx2" '
178+
"--config-settings FOO=BAR"
178179
)
179180
script.pip("install", "--no-index", "-f", str(a_sdist.parent), "-r", "reqs.txt")
180181
script.assert_installed(foo="1.0")
181182
config = script.site_packages_path / "config.json"
182183
with open(config, "rb") as f:
183-
assert json.load(f) == {"--build-option": ["--cffi", "--avx2"]}
184-
185-
186-
def test_merge_cli_reqs_config_settings(script: PipTestEnvironment) -> None:
187-
_, _, project_dir = make_project(script.scratch_path)
188-
a_sdist = create_basic_sdist_for_package(
189-
script,
190-
"foo",
191-
"1.0",
192-
{"pyproject.toml": PYPROJECT_TOML, "backend/dummy_backend.py": BACKEND_SRC},
193-
)
194-
script.scratch_path.joinpath("reqs.txt").write_text(
195-
'foo --config-settings "FOO=HELLO" --config-settings "FOO=BAR" '
196-
'--config-settings "BAZ=BAR"'
197-
)
198-
script.pip(
199-
"install",
200-
"--no-index",
201-
"-f",
202-
str(a_sdist.parent),
203-
"-r",
204-
"reqs.txt",
205-
"--config-settings",
206-
"FOO=FOOBAR",
207-
"--config-settings",
208-
"FOO=BARFOO",
209-
)
210-
script.assert_installed(foo="1.0")
211-
config = script.site_packages_path / "config.json"
212-
with open(config, "rb") as f:
213-
assert json.load(f) == {
214-
"FOO": ["HELLO", "BAR", "FOOBAR", "BARFOO"],
215-
"BAZ": "BAR",
216-
}
217-
218-
219-
def test_cli_config_settings_reqs(script: PipTestEnvironment) -> None:
220-
_, _, project_dir = make_project(script.scratch_path)
221-
a_sdist = create_basic_sdist_for_package(
222-
script,
223-
"foo",
224-
"1.0",
225-
{"pyproject.toml": PYPROJECT_TOML, "backend/dummy_backend.py": BACKEND_SRC},
226-
)
227-
script.scratch_path.joinpath("reqs.txt").write_text("foo")
228-
script.pip(
229-
"install",
230-
"--no-index",
231-
"-f",
232-
str(a_sdist.parent),
233-
"-r",
234-
"reqs.txt",
235-
"--config-settings",
236-
"FOO=BAR",
237-
)
238-
script.assert_installed(foo="1.0")
239-
config = script.site_packages_path / "config.json"
240-
with open(config, "rb") as f:
241-
assert json.load(f) == {"FOO": "BAR"}
184+
assert json.load(f) == {"--build-option": ["--cffi", "--avx2"], "FOO": "BAR"}

tests/unit/test_utils_misc.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)