Commit graph

571 commits

Author SHA1 Message Date
Sam Doran ba8598a25d
Add setup function for creating a mock system venv
Change the main setup to only set PYENV_ROOT. Each test now sets up the
required virtual environments. This results in some duplication but makes
it clearer what each test is doing.

An alternative approach would be to modify the venv created by create_m_venv to
make it look like a system venv, but two distinct functions make it much clearer
what they are doing even though there is some overlap between the functions.
2026-04-27 18:06:06 -04:00
Sam Doran 5e134e155c
Remove counter that is no longer used
This was only used by the warning code, which was removed.
2026-04-24 16:03:16 -04:00
Sam Doran 19efcdcd80
Show venvs created from system Python
Venvs created from system Python are directories, not sym links. The previous
code only displayed venvs that were a directory and a symlink. Now check for
directory existence and symlink status, or directory existence and the presence
of bin/activate within the directory.
2026-04-24 16:02:44 -04:00
Sam Doran 7e89747ae8
Change the interface of create_m_venv to match setup_m_venv
Also have create_m_venv call setup_m_venv.
2026-04-24 13:15:50 -04:00
Sam Doran a105a58a1b
Add a helper for creating virtual environments 2026-04-24 12:04:16 -04:00
Sam Doran b52417ea5e
Remove unnecessary test
The warning was removed, so testing no empty output doesn’t make much sense.
2026-04-24 11:28:26 -04:00
Ivan Pozdeev 6fb433cc6d
- dead code 2026-04-24 17:30:30 +03:00
Ivan Pozdeev 28a8b0fc55
fix test
in case of path with spaces
2026-04-24 16:51:08 +03:00
Ivan Pozdeev 3546afd705
Add a test for version resolution 2026-04-24 16:48:30 +03:00
Sam Doran d8c1a67ed0
Remove pyenv-prefix stubs from tests
This refelects how call changes have changed in the code.
2026-04-24 09:21:33 -04:00
Sam Doran c483e44cb4
Fix incorrect IFS handling
The echo "${VIRTUALENV_PREFIX_PATHS[*]}" statement at the end of the file
only worked by accident because IFS=: was set earlier in the file.

Properly set/unset IFS.
2026-04-23 18:02:22 -04:00
Sam Doran 5ac3b3a1d9
Check for existence of venv directory
Only call pyenv-prefix if the path doesn’t exist.
2026-04-23 17:30:06 -04:00
Sam Doran fed3b04d2f
Remove warning for no virtualenvs 2026-04-23 17:29:19 -04:00
Sam Doran 5fd4975150
Include aliases in completetions
While it looks a bit funny, it is valid to use an existing virtual
environment as the [version] when creating a new one.
2026-04-23 17:29:18 -04:00
Ivan Pozdeev 44c4090095
Refactor 2026-04-23 17:29:18 -04:00
Ivan Pozdeev 8444dad153
Revert activate completion hint change 2026-04-23 17:29:18 -04:00
Sam Doran f966c97adf
Update tests and add more test cases
Update the existing tests based on new behavior/output format.
Add additional tests to cover scenarios that were not previously tested.
2026-04-23 17:29:18 -04:00
Sam Doran f9d1686cfa
Correct test setup so aliases are properly symlinked 2026-04-23 17:29:18 -04:00
Sam Doran d7b3787188
Remove --only-aliases option for later discussion 2026-04-23 17:29:18 -04:00
Sam Doran 9ea8bb6546
Use the newer [[ command
https://mywiki.wooledge.org/BashFAQ/031
2026-04-23 17:29:18 -04:00
Sam Doran 4d2fd5dd3e
Remove unused code
The new implementation is not using realpath.
2026-04-23 17:29:17 -04:00
Sam Doran 36eb43ebad
Use conditional expressions
For consistency, use conditional expressions instead of
arithmetic evaluation when comparing bash versions.
2026-04-23 17:29:17 -04:00
Sam Doran 13b0d850d8
Add skip-aliases to complete output
This was removed by accident.
2026-04-23 17:29:17 -04:00
Sam Doran 6443dea0b9
Update tests 2026-04-23 17:29:17 -04:00
Sam Doran 39f35841f9
Only show aliases as completions for pyenv activate
This makes the suggested completetions cleaner.
2026-04-23 17:29:17 -04:00
Sam Doran ad14880ab2
Only show Python versions for completion when creating new virtual environments
Having the current virtual environments listed as options in the competion
is noisy since only bare Python versions, such as 3.11.1, make sense as
suggested completions for `pyenv virtualenv [version]`.
2026-04-23 17:29:17 -04:00
Sam Doran 6d2cb280f8
Add --only-aliases argument
This is useful for listing the “frinedly” virtualenv names instead of
the short path which includes the Python version.
2026-04-23 17:29:16 -04:00
Sam Doran 97e1333197
Shellcheck fixes, mostly quoting to avoid word splitting 2026-04-23 17:29:16 -04:00
Sam Doran 563bcff28e
Improve performance of pyenv-virtualenvs
Use the code from pyenv-versions for efficiency and consistent output.

The main performance problem was in the call to pyenv-virtualenv-prefix,
which called pyenv-prefix, which then enumerated every virtual environment.
This was done inside a loop, compounding the problem.

Simply the virtual environment listing so that it does not have to call
pyenv-virtualenv-prefix anymore.
2026-04-23 17:29:16 -04:00
Chris Caldwell 99d35f201c
Fix POSIX sh (dash) compatibility in pyenv-virtualenv-init (#526)
* Refactor cache code generation
* Don't generate prompt_command for non bash/zsh/fish

---------

Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2026-04-21 18:53:01 +03:00
Ivan Pozdeev 6a832cacbb
CI: use macos-26
the Github runner is out of beta
2026-04-17 22:54:31 +03:00
Ivan Pozdeev 90dfbcad93
1.3.0 2026-03-25 23:46:29 +03:00
Ivan Pozdeev f046752219
Reformat changelog to conform to Pyenv and Github release notes 2026-03-25 23:45:47 +03:00
Jake Lodwick 72cb35b2b4
Drastically speed up precommand hook by caching active version to skip redundant activate calls (#523) 2026-03-25 23:33:43 +03:00
native-api 38f3333f3a
Merge pull request #520 from native-api/prevent-deletion-of-contents-in-generic-prefix-env-var
CI: tests: use Bats 1.10; support concurrent, out-of-order and multiple-times execution of stub commands; fix race condition between concurrent stubs
2025-12-18 03:52:21 +03:00
Ivan Pozdeev 10c8ace3c3
Fix a race condition between concurrently executing stubs 2025-12-18 03:47:17 +03:00
Ivan Pozdeev 7d9840478c
stub: -unnecessary indirection 2025-12-18 03:47:16 +03:00
Ivan Pozdeev bf7d3b0584
stub, test_helper: support concurrent, out-of-order and multiple-times stub command execution 2025-12-18 03:46:38 +03:00
Ivan Pozdeev dd2ad3ee65
stub: dumping the plan vars is redundant
They proved to not be useful for diagnostics
2025-12-18 03:30:05 +03:00
Ivan Pozdeev 4785e89a3b
Use Bats v1.10.0 2025-12-18 03:06:38 +03:00
native-api b83e2c3c83
CI: - commented-out code; - macos-11 workaround (#521) 2025-12-18 00:41:30 +03:00
Ivan Pozdeev b5c88a7a15
1.2.6 2025-12-14 18:41:47 +03:00
SabriRamadanTNG 64233612fb
Prevent loss of data on virtualenv-delete -f if the env doesn't exist and the PREFIX envvar is set elsewhere (#518)
* Rename the PREFIX var just in case as too generic

Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2025-12-13 20:05:26 +03:00
native-api 4d37a6e477
Convert issue template to new Github format (#519)
* Convert issue template to new Github format

the old format seems to be dropped altogether now

[no ci]
2025-12-13 17:19:41 +03:00
Ivan Pozdeev f5b2602597
CI: change macos-13 to macos-15-intel 2025-12-11 14:47:13 +03:00
Charlie (cshen.dev) 387f627464
docs: fix the link to Pyenv shell setup steps (#516) 2025-09-22 08:36:00 +03:00
Seokhee Park 4b3f5f8468
docs: add WSL note about core.autocrlf to prevent CRLF issues (#512) 2025-05-17 10:19:25 +03:00
Ivan Pozdeev 3057e1549b [CI] Update environments
ubuntu-20.04 is dropped, macos-15 is available
2025-05-06 19:14:54 +03:00
Jason N. White aa9b8e9a5a
Update LICENSE, fix license year (#499)
Some checks failed
tests / tests (ubuntu-22.04) (push) Failing after 1s
tests / tests (macos-13) (push) Has been cancelled
tests / tests (macos-14) (push) Has been cancelled
tests / tests (ubuntu-20.04) (push) Has been cancelled
Signed-off-by: JasonnnW3000 <sufssl04@gmail.com>
2025-01-01 20:46:21 +03:00
native-api e8c8fd9b84
Fix errorneously creating a symlink inside env directory if running with -f (#496)
Some checks failed
tests / tests (macos-13) (push) Has been cancelled
tests / tests (macos-14) (push) Has been cancelled
tests / tests (ubuntu-20.04) (push) Has been cancelled
tests / tests (ubuntu-22.04) (push) Failing after 0s
2024-12-08 23:30:27 +03:00