xonsh/news/vox-respect-prompt.rst
Oliver Bestwalter 81c8fe6bb9
make env_name aware of prompt in pyvenv.cfg (#4673)
* make env_name aware of prompt in pyvenv.cfg

prompt.env.env_name is now aware of the "prompt" key in pyvenv.cfg - search order from first to last is: $VIRTUAL_ENV_PROMPT, pyvenv.cfg, $VIRTUAL_ENV.

fixes #4670

* make env_name aware of prompt in pyvenv.cfg

prompt.env.env_name is now aware of the "prompt" key in pyvenv.cfg - search order from first to last is: $VIRTUAL_ENV_PROMPT, pyvenv.cfg, $VIRTUAL_ENV.

As the env_name is generated every time the prompt is generated, caching is used to only calculate it once for every venv path.

This introduces the possibility that the user will not get a correct env_name, when they change the cfg file or replace the whole venv and use different prompt settings the second time around. Although this is annoying and potentially confusing, it is still better than the situation before, where the prompt setting was simply ignored, although it is part of venv since python3.6 - so or now this might be seen as acceptable trade-off between speed and correctness.

fixes #4670

* make env_name aware of prompt in pyvenv.cfg

prompt.env.env_name is now aware of the "prompt" key in pyvenv.cfg - search order from first to last is: $VIRTUAL_ENV_PROMPT, pyvenv.cfg, $VIRTUAL_ENV.

As the env_name is generated every time the prompt is generated, caching is used to only calculate it once for every venv path.

This introduces the possibility that the user will not get a correct env_name, when they change the cfg file or replace the whole venv and use different prompt settings the second time around. Although this is annoying and potentially confusing, it is still better than the situation before, where the prompt setting was simply ignored, although it is part of venv since python3.6 - so or now this might be seen as acceptable trade-off between speed and correctness.

fixes #4670

* add type annotations

* always return str

This is more consistent and might also deal with a mypy error only observed on Ubuntu Linux python3.9

* remove unnecessary import

* adapt code to not break the documented API

When restructuring the code, I did not know that this was part of a documented API. This restores the API functions and updates the doc strings. New helper functions have been made private.
2022-02-21 23:39:07 +05:30

23 lines
356 B
ReStructuredText

**Added:**
* ``prompt.env.env_name`` is now aware of the "prompt" key in ``pyvenv.cfg`` - search order from first to last is: ``$VIRTUAL_ENV_PROMPT``, ``pyvenv.cfg``, ``$VIRTUAL_ENV``, $``CONDA_DEFAULT_ENV``
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>