Skip to content

Commit

Permalink
Add env and env var values
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshks committed May 31, 2020
1 parent 664555b commit 39432a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/pip/_internal/commands/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def unset_name(self, options, args):

def list_config_values(self, options, args):
self._get_n_args(args, "debug", n=0)
self.print_env_var_values()
for variant, files in sorted(self.configuration.iter_config_files()):
write_output("%s:", variant)
for fname in files:
Expand All @@ -211,6 +212,13 @@ def print_config_file_values(self, variant):
with indent_log():
write_output("%s: %s ", name, value)

def print_env_var_values(self):
write_output("%s:", 'env_var')
with indent_log():
for key, value in self.configuration.get_environ_vars():
env_var = 'PIP_{}'.format(key.upper())
write_output("%s=%r", env_var, value)

def open_in_editor(self, options, args):
editor = self._determine_editor(options)

Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def _load_environment_vars(self):
"""Loads configuration from environment variables
"""
self._config[kinds.ENV_VAR].update(
self._normalized_keys(":env:", self._get_environ_vars())
self._normalized_keys(":env:", self.get_environ_vars())
)

def _normalized_keys(self, section, items):
Expand All @@ -358,7 +358,7 @@ def _normalized_keys(self, section, items):
normalized[key] = val
return normalized

def _get_environ_vars(self):
def get_environ_vars(self):
# type: () -> Iterable[Tuple[str, str]]
"""Returns a generator with all environmental vars with prefix PIP_"""
for key, val in os.environ.items():
Expand Down

0 comments on commit 39432a6

Please sign in to comment.