1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-11-01 03:51:12 +00:00
Commit Graph

88 Commits

Author SHA1 Message Date
Yutian Li
a79c3b4943 Remove Python module comment about completion
Local completion definition has been removed
2024-04-08 11:56:00 -05:00
Yutian Li
5ff938dff5 Update Python virtualenvwrapper documentation 2024-04-03 07:37:49 -05:00
John Britton
457ade4f01 python: Remove pyenv init woraround for pyenv >= 2.3.0
The startup logic and instructions have been updated for simplicity in
pyenv 2.3.0. The workaround for pyenv init is no longer necessary.

Signed-off-by: Indrajit Raychaudhuri <irc@indrajit.com>
2023-11-05 15:04:27 -06:00
Indrajit Raychaudhuri
8d00c51900 python: Remove pip completion from prezto local
pip completion is bundled with Zsh 5.9. Remove it from prezto local to
avoid shadowing the bundled completion.
2023-05-17 21:11:58 -05:00
Indrajit Raychaudhuri
8ee9d1bbfe general: Documentation update for zstyle based alias skipping support
Add documentation to surface the `zstyle` based alias skipping.
2023-05-17 02:39:09 -05:00
Indrajit Raychaudhuri
52bf42f887 python: Expand Python command pattern per convention
Use `(i)python[0-9.]#` as subscript for commands associative array,
following the convention [1] of detection python more exhaustively.

[1] 858b8de3d7/Completion/Unix/Command/_python (L1)
2023-04-27 19:11:42 -05:00
mattmc3
da87c79b3a Add zstyle to skip aliases for additional modules 2023-04-13 09:33:48 -07:00
Jeff Widman
e3a9583f33 Support virtualenvwrapper with / without pyenv virtualenv-init or virtualenvwrapper plugins
The desired logic is:

For the `pyenv` plugins `virtualenv-init` and `virtualenvwrapper`:
1. If either plugin is present, activate it
2. If `virtualenvwrapper` plugin is not present, then
   [fallback to standard
   `virtualenvwrapper`](https://github.com/sorin-ionescu/prezto/pull/1414#issuecomment-320306421).
3. If `virtualenvwrapper` plugin is present, then [don't fallback to
   standard `virtualenvwrapper`, regardless of whether `virtualenv-init`
   is
   present](https://github.com/sorin-ionescu/prezto/pull/1981#issue-1123766676).

Previously, if the `virtualenv` command was present but `pyenv` was
missing, then the fallback wouldn't be hit. This bug was introduced by
https://github.com/sorin-ionescu/prezto/pull/1981/ which ensured that
the `pyenv` `virtualenvwrapper` plugin was activated if present,
regardless of the presence of the `virtualenv-init` plugin.

As an optimization, the check for the `pyenv` plugins are skipped if
`pyenv` itself isn't found.

Since we only want to fallback if the `pyenv` `virtualenvwrapper` plugin
is missing, but that's buried within the `pyenv` logic and we also need
to handle when `pyenv` itself is missing, this switches to using a flag
variable.

I also renamed the `virtualenv_sources` var to
`virtualenvwrapper_sources` as `virtualenv` is distinct from
`virtualenvwrapper`, so using one name for a var that is really about
the other is confusing.

Looking at `git blame`, there's a _lot_ of prior art here around trying
to support all the permutations of `pyenv` and various plugins:
* https://github.com/sorin-ionescu/prezto/issues/1413
* https://github.com/sorin-ionescu/prezto/pull/1414
* https://github.com/sorin-ionescu/prezto/pull/1433
* https://github.com/sorin-ionescu/prezto/pull/1434

So we need to be extremely careful to continue to support all these
permutations.

Fix https://github.com/sorin-ionescu/prezto/issues/2022
2022-10-26 22:03:42 -07:00
Jeff Widman
ca9012c776 Set EXTENDED_GLOB in the python module
This is needed to find python. 

It is often already set because a user has the directory or completion module loaded before this, but that's not always true.

See extensive debugging / further explanation here: https://github.com/sorin-ionescu/prezto/issues/1949

This does not fully resolve that issue, as there's another enhancement that I'll put up as a separate PR.
2022-10-25 15:54:00 -07:00
zbirenbaum
d840f0fc7b Fix crash on open caused by incorrect conditional in python module 2022-02-03 22:08:36 -05:00
Thomas Blaschke
866d5dfccd Add conda to the list of requirements
If conda is not in the list of requirements, the scripts exit too early in case pyenv is not installed and the module is configured with:

 zstyle ':prezto:module:python' skip-virtualenvwrapper-init 'on' 
 zstyle ':prezto:module:python' conda-init 'on'

Tested on Amazon EC2 Linux for Deeplearning AMI 47.0 and MacOS 11.4
2021-06-23 23:22:09 -05:00
Indrajit Raychaudhuri
afe59b293b python: Update pyenv initialization flow per pyenv 2.0
In pyenv 2.0 onwards, it is not enough anymore to initialize pyenv in
shell by just calling `pyenv init -`. We also need to update `path` to
include pyenv shims by calling `pyenv init --path`.

Also, honor `$PYENV_ROOT` if set but, no need to set it explicitly if
not set. Instead, let the initialization script take care of that.
2021-06-01 14:29:39 -05:00
Indrajit Raychaudhuri
f0942e6dda python: Optimize completion for loading lazily on demand
Move `pip` to separate completion definition delegating to pip to do
all the completion work.

Since the completion is loaded lazily on-demand, it avoids the
performance overhead during Zsh initialization.

Implementation note:
The helper function `_pip_completion` implementation is based on the
official pip completion function (which can be generated with
`pip completion --zsh`) adhering to the newer compsys style.

See: 'man zshcompsys' for more details.
2021-06-01 14:29:39 -05:00
Indrajit Raychaudhuri
d686da3c03 python: Reformat and apply visual cleanup
Changes:
- Fallback to `virtualenvwrapper` without `pyenv` wrapper if `python` is
  available in path, regardless of whether `brew` is available.
- Look up for availability of `python2` and `python3`, not just `python`.
- Check for existence of path before adding to global `$path` array.
- Adhere to more idiomatic Zsh operation and minimize redundant syntaxes.
- Prefer looking up `$functions` for fully initialized `pyenv`.
2021-06-01 14:29:39 -05:00
Indrajit Raychaudhuri
1ff9421f7b general: Update documentation better qualifying runcom paths
Zsh and Prezto files don't always reside in `~/`. Instead, they have
a more spec compliant location (`${ZDOTDIR:-$HOME}/`). Make them
unambiguous in the documentation. Likewise, for `$GNUPGHOME`.

Further, add instruction for optionally setting up Prezto in
`$XDG_CONFIG_HOME`.

While at this, also add clarification on relative ordering of some of
the modules, apply more formatting tweaks and doc improvements.
2021-05-21 12:31:02 -05:00
Indrajit Raychaudhuri
d80e393f78 general: Reformat documentation with better formatting and wording
General purpose reformating and rewording in (a few places). This should
also make markdown linting happier.

Prefer back-ticks wherever useful and use `console` for code blocks to
be executed on terminal.

Also, update references links wherever possible (including update from
'http://' to 'https://').
2021-05-05 12:21:04 -05:00
Olaf Conradi
e9197234cf
Add check for empty WORKON_HOME (#1861)
When $WORKON_HOME is not set and $ENV_NAME is equal to
$PROJECT_ROOT/.venv which contains bin/activate then
the code wrongly assumes workon is available.

It should execute the second branch to source bin/activate.
2020-07-27 12:49:40 -07:00
Joost Cassee
2d3763380c
Ask pyenv whether pip exists if installed (#1848)
Pyenv will install shims for commands that exist in any interpreter, even if it is not the current one. This means that a command may technically exist, but when executed will tell the user to try a different interpreter. The original check for pip in the Python module can fail for this reason, in particular on Ubuntu 20.04.

This change checks with pyenv whether pip really exists in the current interpreter to work around this problem and fixes a bug in pip command detection.
2020-06-29 10:25:15 -07:00
Texas Toland
ff91c8d410
Make .zcomp* location configurable (#1842) 2020-06-04 13:53:44 -07:00
Charith Amarasinghe
d5bef142d4
Fix missing dependency on helper module for helpers added in #1793 (#1811)
PR #1793 introduced helper functions for OS detection in some modules.
These helpers require a module dependency on the 'helper' module.
2020-03-29 12:49:35 -07:00
Kaspar Vollenweider
f4ca9ebfc9 feat(helper): add os-type helper functions
Add the following functions:

- is-darwin
- is-linux
- is-bsd
- is-cygwin

And apply them everywhere I found code doing that what these functions do.
2020-03-19 11:49:11 -07:00
Kaleb Elwert
75b112bcd0 node, python, ruby: update docs about new envars 2019-09-10 09:10:31 -07:00
laggardkernel
f596d5d1d6 python: improve PYENV_ROOT detection 2019-09-10 09:00:11 -07:00
Indrajit Raychaudhuri
a338cba805 python: Use brace expansion for pip compctl match
Just use brace expansion only (and not a mix of brace expansion and
path expansion) to expand `sed` match for more variants of 'pip*' (pip,
pip2, pip3, pip2.7, pip3.7 etc.) in `compctl` assignment
2018-12-18 14:19:07 -06:00
Indrajit Raychaudhuri
9d3e2f0204
python: Expand compctl matches for pip variants
Expand `sed` match for more variants of 'pip*' (pip, pip2, pip3, pip2.7, 
pip3.7 etc.) for `compctl` assignment
2018-12-14 21:32:10 -06:00
Indrajit Raychaudhuri
a987c8bc8a
python: Fix pip compctl file match pattern
Make `sed` match more reliable while replacing the whole of 'pip*' with 
'pip pip2 pip3' for `compctl` assignment
2018-12-12 16:18:58 -06:00
Indrajit Raychaudhuri
e7fea3343f python: Use more apropriate filename for pip completion 2018-12-11 08:11:44 -06:00
Indrajit Raychaudhuri
53286ebbdb python: Make cached completion file mangling more reliable
While mangling cached completion file, we cannot just assume that
`$pip_command` would resolve to `pip` -- it might be `pip2` or `pip3`
depending on the relative position in zsh `$commands` array. Thus
replace the whole of 'pip*' with 'pip pip2 pip3' for compctl assignment.
2018-12-11 08:11:44 -06:00
Indrajit Raychaudhuri
992b9de505 doc: More copyediting and formatting for consistency 2018-10-12 12:04:49 -05:00
Kaleb Elwert
e9387a177e python: respect PYENV_ROOT if already set
Fixes #1578
2018-09-28 14:24:30 -07:00
Kaleb Elwert
ee885d42de python: use pure's magic value for VIRTUAL_ENV_DISABLE_PROMPT
Fixes #1627
2018-09-28 14:04:24 -07:00
Steven Loria
dacef14214 Improve startup time by skipping pyenv rehash
After profiling startup time, I found that "pyenv rehash" is
by far the slowest piece. This change skips rehashing on init.

See https://github.com/pyenv/pyenv/issues/784#issuecomment-404850327

Also pass the shell explicitly, as suggested in
https://github.com/pyenv/pyenv/issues/784#issuecomment-404944318,
which provides a modest improvement.

In total, this improves startup time from 1s to 0.3s on my machine.
Using the following command:
python -m timeit "__import__('subprocess').Popen(['zsh', '-i', '-c', 'echo']).communicate()"

Result before this change:
10 loops, best of 3: 1 sec per loop

Result after this change:
10 loops, best of 3: 334 msec per loop
2018-08-01 13:52:52 -04:00
Casey McGinty
2995b7d0c8 Update cache files when .zpreztorc file is modified
Fixes #1581
2018-05-06 13:22:22 -07:00
Casey McGinty
6e179f24ab Export VIRTUAL_ENV_DISABLE_PROMPT when enabling virutalenv
Adding `export` ensures the define is available in the shell so pyenv
or virtualenvwrapper do not duplicate the virtualenv name on the
prompt.
2018-05-01 08:53:16 -07:00
Ashish Gandhi
b6b43eb331 Rename "Mac OS X" to "macOS" in comments
This only changes references in text for human consumption. It leaves
out renaming paths because that can cause breaking changes.

Related issue https://github.com/sorin-ionescu/prezto/issues/1449.
2018-04-16 15:53:48 -07:00
bryndin
e00562e7cf python: autoload add-zsh-hook when needed (#1549)
Fixes #1550
2018-02-23 13:39:45 -08:00
Kaleb Elwert
83085e5231 python: remove zstyle setting in favor of third party environment variable
Refs #1519, #1520
2017-12-14 17:23:44 -08:00
Kaleb Elwert
4c31107e3b python: only override virtualenv python if not set
Fixes #1520
2017-12-14 17:11:06 -08:00
Kaleb Elwert
d8d6b4d70a python: only override virtualenvwrapper python when needed
Fixes #1519
2017-12-12 23:11:55 -08:00
Kaleb Elwert
e021adeb4a python: make a reasonable guess about virtualenvwrapper python location
Fixes #1416
2017-12-11 11:01:42 -08:00
Kaleb Elwert
3ab569ff78 python-info: add support for pyenv and only do extra work if the prompt needs it 2017-12-04 15:08:58 -08:00
Kaleb Elwert
64d57ec71f python-info: avoid setting python_info[version] if python is not on the PATH 2017-12-04 12:08:45 -08:00
Kaleb Elwert
b407ba0c3a python-info: provide python version info for theming
Closes #1173
Closes #958
2017-12-04 12:05:21 -08:00
ickc
96bbb31cc8 Added conda virtualenv support to python module. (#1505)
* Added conda virtualenv support to python module
* Added instructions for Python module options to README

Thanks to @egpbos for the original feature and @ickc for fixing the merge conflicts.
2017-11-12 16:20:52 -08:00
Kaleb Elwert
948d9b3aa5 Store cache files in a user-writable location
Fixes #1122
2017-11-10 11:37:14 -08:00
Jeff Widman
727f094b0f [python] cleanup readme formatting
Anyone want some backticks? :-)
2017-08-29 16:51:27 -07:00
Jeff Widman
8fa14ed72f Drop easy_install in docs, everyone now uses pip (#1436) 2017-08-29 16:04:44 -07:00
Greg Anders
9c528efa60 Explicitly set PYENV_ROOT 2017-08-26 16:21:45 -05:00
Indrajit Raychaudhuri
83ab314b77 [python] Refine pyenv based virtualenv management
Now that pyenv plugins availability is detected by directly probing
'pyenv', we need to rely on the same mechanism consistently.

Further, we perform available pyenv plugin scan with native zsh
techniques instead of relying on external commands.
2017-08-18 09:35:52 -05:00
Indrajit Raychaudhuri
5ffc8a07f1 [python] Ensure availability of virtualenvwrapper file before sourcing it 2017-08-18 07:56:10 -05:00