Skip to content

Commit 7ba5a62

Browse files
committed
Revert "Merge pull request #11487 from pelson/feature/base-prefix-config"
This reverts commit 56e5fa3, reversing changes made to 2c09e9c.
1 parent 87678ee commit 7ba5a62

File tree

4 files changed

+11
-63
lines changed

4 files changed

+11
-63
lines changed

docs/html/topics/configuration.md

+5-16
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ and how they are related to pip's various command line options.
1919

2020
## Configuration Files
2121

22-
Configuration files can change the default values for command line options.
23-
They are written using standard INI style configuration files.
22+
Configuration files can change the default values for command line option.
23+
They are written using a standard INI style configuration files.
2424

25-
pip has 4 "levels" of configuration files:
25+
pip has 3 "levels" of configuration files:
2626

27-
- `global`: system-wide configuration file, shared across all users.
28-
- `user`: per-user configuration file, shared across all environments.
29-
- `base` : per-base environment configuration file, shared across all virtualenvs with the same base. (available since pip 23.0)
27+
- `global`: system-wide configuration file, shared across users.
28+
- `user`: per-user configuration file.
3029
- `site`: per-environment configuration file; i.e. per-virtualenv.
3130

3231
### Location
@@ -48,9 +47,6 @@ User
4847
4948
The legacy "per-user" configuration file is also loaded, if it exists: {file}`$HOME/.pip/pip.conf`.
5049
51-
Base
52-
: {file}`\{sys.base_prefix\}/pip.conf`
53-
5450
Site
5551
: {file}`$VIRTUAL_ENV/pip.conf`
5652
```
@@ -67,9 +63,6 @@ User
6763
6864
The legacy "per-user" configuration file is also loaded, if it exists: {file}`$HOME/.pip/pip.conf`.
6965
70-
Base
71-
: {file}`\{sys.base_prefix\}/pip.conf`
72-
7366
Site
7467
: {file}`$VIRTUAL_ENV/pip.conf`
7568
```
@@ -88,9 +81,6 @@ User
8881
8982
The legacy "per-user" configuration file is also loaded, if it exists: {file}`%HOME%\\pip\\pip.ini`
9083
91-
Base
92-
: {file}`\{sys.base_prefix\}\\pip.ini`
93-
9484
Site
9585
: {file}`%VIRTUAL_ENV%\\pip.ini`
9686
```
@@ -112,7 +102,6 @@ order:
112102
- `PIP_CONFIG_FILE`, if given.
113103
- Global
114104
- User
115-
- Base
116105
- Site
117106

118107
Each file read overrides any values read from previous files, so if the

src/pip/_internal/configuration.py

+3-15
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,12 @@
3636
kinds = enum(
3737
USER="user", # User Specific
3838
GLOBAL="global", # System Wide
39-
BASE="base", # Base environment specific (e.g. for all venvs with the same base)
40-
SITE="site", # Environment Specific (e.g. per venv)
39+
SITE="site", # [Virtual] Environment Specific
4140
ENV="env", # from PIP_CONFIG_FILE
4241
ENV_VAR="env-var", # from Environment Variables
4342
)
44-
OVERRIDE_ORDER = (
45-
kinds.GLOBAL,
46-
kinds.USER,
47-
kinds.BASE,
48-
kinds.SITE,
49-
kinds.ENV,
50-
kinds.ENV_VAR,
51-
)
52-
VALID_LOAD_ONLY = kinds.USER, kinds.GLOBAL, kinds.BASE, kinds.SITE
43+
OVERRIDE_ORDER = kinds.GLOBAL, kinds.USER, kinds.SITE, kinds.ENV, kinds.ENV_VAR
44+
VALID_LOAD_ONLY = kinds.USER, kinds.GLOBAL, kinds.SITE
5345

5446
logger = getLogger(__name__)
5547

@@ -78,7 +70,6 @@ def get_configuration_files() -> Dict[Kind, List[str]]:
7870
os.path.join(path, CONFIG_BASENAME) for path in appdirs.site_config_dirs("pip")
7971
]
8072

81-
base_config_file = os.path.join(sys.base_prefix, CONFIG_BASENAME)
8273
site_config_file = os.path.join(sys.prefix, CONFIG_BASENAME)
8374
legacy_config_file = os.path.join(
8475
os.path.expanduser("~"),
@@ -87,7 +78,6 @@ def get_configuration_files() -> Dict[Kind, List[str]]:
8778
)
8879
new_config_file = os.path.join(appdirs.user_config_dir("pip"), CONFIG_BASENAME)
8980
return {
90-
kinds.BASE: [base_config_file],
9181
kinds.GLOBAL: global_config_files,
9282
kinds.SITE: [site_config_file],
9383
kinds.USER: [legacy_config_file, new_config_file],
@@ -354,8 +344,6 @@ def iter_config_files(self) -> Iterable[Tuple[Kind, List[str]]]:
354344
# The legacy config file is overridden by the new config file
355345
yield kinds.USER, config_files[kinds.USER]
356346

357-
yield kinds.BASE, config_files[kinds.BASE]
358-
359347
# finally virtualenv configuration first trumping others
360348
yield kinds.SITE, config_files[kinds.SITE]
361349

tests/unit/test_configuration.py

+2-31
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,11 @@ def test_user_loading(self) -> None:
2424
self.configuration.load()
2525
assert self.configuration.get_value("test.hello") == "2"
2626

27-
def test_base_loading(self) -> None:
28-
self.patch_configuration(kinds.BASE, {"test.hello": "3"})
29-
30-
self.configuration.load()
31-
assert self.configuration.get_value("test.hello") == "3"
32-
3327
def test_site_loading(self) -> None:
34-
self.patch_configuration(kinds.SITE, {"test.hello": "4"})
28+
self.patch_configuration(kinds.SITE, {"test.hello": "3"})
3529

3630
self.configuration.load()
37-
assert self.configuration.get_value("test.hello") == "4"
31+
assert self.configuration.get_value("test.hello") == "3"
3832

3933
def test_environment_config_loading(self, monkeypatch: pytest.MonkeyPatch) -> None:
4034
contents = """
@@ -113,15 +107,6 @@ def test_no_such_key_error_message_missing_option(self) -> None:
113107
with pytest.raises(ConfigurationError, match=pat):
114108
self.configuration.get_value("global.index-url")
115109

116-
def test_overrides_normalization(self) -> None:
117-
# Check that normalized names are used in precedence calculations.
118-
# Reminder: USER has higher precedence than GLOBAL.
119-
self.patch_configuration(kinds.USER, {"test.hello-world": "1"})
120-
self.patch_configuration(kinds.GLOBAL, {"test.hello_world": "0"})
121-
self.configuration.load()
122-
123-
assert self.configuration.get_value("test.hello_world") == "1"
124-
125110

126111
class TestConfigurationPrecedence(ConfigurationMixin):
127112
# Tests for methods to that determine the order of precedence of
@@ -148,13 +133,6 @@ def test_env_overides_global(self) -> None:
148133

149134
assert self.configuration.get_value("test.hello") == "0"
150135

151-
def test_site_overides_base(self) -> None:
152-
self.patch_configuration(kinds.BASE, {"test.hello": "2"})
153-
self.patch_configuration(kinds.SITE, {"test.hello": "1"})
154-
self.configuration.load()
155-
156-
assert self.configuration.get_value("test.hello") == "1"
157-
158136
def test_site_overides_user(self) -> None:
159137
self.patch_configuration(kinds.USER, {"test.hello": "2"})
160138
self.patch_configuration(kinds.SITE, {"test.hello": "1"})
@@ -169,13 +147,6 @@ def test_site_overides_global(self) -> None:
169147

170148
assert self.configuration.get_value("test.hello") == "1"
171149

172-
def test_base_overides_user(self) -> None:
173-
self.patch_configuration(kinds.USER, {"test.hello": "2"})
174-
self.patch_configuration(kinds.BASE, {"test.hello": "1"})
175-
self.configuration.load()
176-
177-
assert self.configuration.get_value("test.hello") == "1"
178-
179150
def test_user_overides_global(self) -> None:
180151
self.patch_configuration(kinds.GLOBAL, {"test.hello": "3"})
181152
self.patch_configuration(kinds.USER, {"test.hello": "2"})

tests/unit/test_options.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ def test_venv_config_file_found(self, monkeypatch: pytest.MonkeyPatch) -> None:
587587
for _, val in cp.iter_config_files():
588588
files.extend(val)
589589

590-
assert len(files) == 5
590+
assert len(files) == 4
591591

592592
@pytest.mark.parametrize(
593593
"args, expect",

0 commit comments

Comments
 (0)