diff --git a/docs/configuration.rst b/docs/configuration.rst index 3af24de3b..c0831fd70 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3,4 +3,4 @@ Configuration ============= -This content is now covered in the :doc:`User Guide ` +This content is now covered in the :ref:`Configuration` section of the :doc:`User Guide `. diff --git a/docs/reference/index.rst b/docs/reference/index.rst index 44b040a86..f25568bfb 100644 --- a/docs/reference/index.rst +++ b/docs/reference/index.rst @@ -14,5 +14,6 @@ Reference Guide pip_show pip_search pip_check + pip_config pip_wheel pip_hash diff --git a/docs/reference/pip_config.rst b/docs/reference/pip_config.rst new file mode 100644 index 000000000..0f92f5714 --- /dev/null +++ b/docs/reference/pip_config.rst @@ -0,0 +1,22 @@ + +.. _`pip config`: + +pip config +------------ + +.. contents:: + +Usage +***** + +.. pip-command-usage:: config + +Description +*********** + +.. pip-command-description:: config + +Options +******* + +.. pip-command-options:: config diff --git a/docs/user_guide.rst b/docs/user_guide.rst index daff8a3e2..13daabc73 100644 --- a/docs/user_guide.rst +++ b/docs/user_guide.rst @@ -424,7 +424,7 @@ Examples: Command Completion ------------------- +****************** pip comes with support for command line completion in bash, zsh and fish. diff --git a/news/4556.trivial b/news/4556.trivial new file mode 100644 index 000000000..3275226cb --- /dev/null +++ b/news/4556.trivial @@ -0,0 +1 @@ +Misc changes related to configuration diff --git a/pip/commands/configuration.py b/pip/commands/configuration.py index 22a00e867..071f08b9c 100644 --- a/pip/commands/configuration.py +++ b/pip/commands/configuration.py @@ -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.' ) ) diff --git a/pip/configuration.py b/pip/configuration.py index 8e1bbb1b8..400d2a644 100644 --- a/pip/configuration.py +++ b/pip/configuration.py @@ -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. diff --git a/tests/unit/test_configuration.py b/tests/unit/test_configuration.py index 941cf0926..33f075861 100644 --- a/tests/unit/test_configuration.py +++ b/tests/unit/test_configuration.py @@ -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