mirror of https://github.com/pypa/pip
Configuration - Documentation updates (#4556)
This commit is contained in:
parent
a24c59fc27
commit
49abd55fe5
|
@ -3,4 +3,4 @@
|
|||
Configuration
|
||||
=============
|
||||
|
||||
This content is now covered in the :doc:`User Guide <user_guide>`
|
||||
This content is now covered in the :ref:`Configuration` section of the :doc:`User Guide <user_guide>`.
|
||||
|
|
|
@ -14,5 +14,6 @@ Reference Guide
|
|||
pip_show
|
||||
pip_search
|
||||
pip_check
|
||||
pip_config
|
||||
pip_wheel
|
||||
pip_hash
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
.. _`pip config`:
|
||||
|
||||
pip config
|
||||
------------
|
||||
|
||||
.. contents::
|
||||
|
||||
Usage
|
||||
*****
|
||||
|
||||
.. pip-command-usage:: config
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
.. pip-command-description:: config
|
||||
|
||||
Options
|
||||
*******
|
||||
|
||||
.. pip-command-options:: config
|
|
@ -424,7 +424,7 @@ Examples:
|
|||
|
||||
|
||||
Command Completion
|
||||
------------------
|
||||
******************
|
||||
|
||||
pip comes with support for command line completion in bash, zsh and fish.
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Misc changes related to configuration
|
|
@ -52,8 +52,8 @@ class ConfigurationCommand(Command):
|
|||
action='store',
|
||||
default=None,
|
||||
help=(
|
||||
'Editor to use to edit the file. Uses '
|
||||
'$EDITOR if not passed.'
|
||||
'Editor to use to edit the file. Uses VISUAL or EDITOR '
|
||||
'environment variables if not provided.'
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -83,6 +83,8 @@ class Configuration(object):
|
|||
kinds.GLOBAL, kinds.USER, kinds.VENV, kinds.ENV, kinds.ENV_VAR
|
||||
]
|
||||
|
||||
self._ignore_env_names = ["version", "help"]
|
||||
|
||||
# Because we keep track of where we got the data from
|
||||
self._parsers = {variant: [] for variant in self._override_order}
|
||||
self._config = {variant: {} for variant in self._override_order}
|
||||
|
@ -275,7 +277,11 @@ class Configuration(object):
|
|||
def _get_environ_vars(self):
|
||||
"""Returns a generator with all environmental vars with prefix PIP_"""
|
||||
for key, val in os.environ.items():
|
||||
if key.startswith("PIP_"):
|
||||
should_be_yielded = (
|
||||
key.startswith("PIP_") and
|
||||
key[4:].lower() not in self._ignore_env_names
|
||||
)
|
||||
if should_be_yielded:
|
||||
yield key[4:].lower(), val
|
||||
|
||||
# XXX: This is patched in the tests.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from mock import MagicMock
|
||||
|
||||
from pip.exceptions import ConfigurationError
|
||||
|
@ -49,6 +50,22 @@ class TestConfigurationLoading(ConfigurationMixin):
|
|||
self.configuration.load()
|
||||
assert self.configuration.get_value(":env:.hello") == "5"
|
||||
|
||||
@pytest.mark.skipif("sys.platform == 'win32'")
|
||||
def test_environment_var_does_not_load_lowercase(self):
|
||||
os.environ["pip_hello"] = "5"
|
||||
|
||||
self.configuration.load()
|
||||
with pytest.raises(ConfigurationError):
|
||||
self.configuration.get_value(":env:.hello")
|
||||
|
||||
def test_environment_var_does_not_load_version(self):
|
||||
os.environ["PIP_VERSION"] = "True"
|
||||
|
||||
self.configuration.load()
|
||||
|
||||
with pytest.raises(ConfigurationError):
|
||||
self.configuration.get_value(":env:.version")
|
||||
|
||||
|
||||
class TestConfigurationPrecedence(ConfigurationMixin):
|
||||
# Tests for methods to that determine the order of precedence of
|
||||
|
|
Loading…
Reference in New Issue