Commit graph

248 commits

Author SHA1 Message Date
Alex Hedges
02e1d4a293
Handle case where pyenv-commands --sh returns nothing (#2908)
In exceptional cases (custom installation, malfunctions elsewhere), `pyenv-commands --sh` may return nothing.
In non-Fish, this would cause "syntax error near unexpected token `)'" in `pyenv()`.

Bash does not allow to specify a `case` option that would never match.
This works around it by defaulting to `/`. Commands, being filenames, can never match it.
In Fish, nothing needs to be done: it apparently does interpret a `case` without argument as one that never matches.
2024-02-26 00:07:52 +03:00
native-api
dee8a9dbad
Fix intermittent "broken pipe" in version sort test (#2817) 2023-10-12 22:09:48 +03:00
native-api
20189ff06f
Fix not showing symlink contents for unselected versions in pyenv versions (#2675) 2023-04-08 01:12:09 +03:00
Ivan Pozdeev
9fe80f28e5 Add pyenv versions' option to skip envs for pyenv-latest' 2023-02-02 18:15:13 +03:00
native-api
9248255f70
Show symlink contents in non-bare `pyenv versions' (#2609)
* Change other tests to use the newly-created convenience function
2023-02-02 17:24:19 +03:00
native-api
368e04f3fa
Fix pyenv-latest to ignore virtualenvs (#2608)
* Add test, exclude alphas as well
2023-02-02 15:15:16 +03:00
native-api
c20fc7bd6a
Fix pyenv which to support auto-resolved prefixes (#2601)
* Resolve version name that hooks see
* Avoid a 2nd iteration over configured versions
2023-01-22 18:22:26 +03:00
Ian Chen
f897c50202
Fix non-bash output while detecting shell (#2561)
Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2022-12-25 02:35:03 +03:00
Isaac Levy
cc56f76733
Add --no-push-path option (#2526)
In some advanced shell setups, the order of custom-added PATH entries is important.
We disregard it by default, always pushing shims to the front of PATH,
to ensure that Pyenv works even in poorly maintained shell environments
and with minimal hassle for non-export users
(an attempt to do the opposite (#1898) has ended in a disaster).
Some advanced users are however ready and able to carefully maintain their environment
and deal with breakages and inconvenience. This option is for them.
2022-11-19 00:01:59 +03:00
native-api
ed1083ec27
Fix resolution of a name that's a prefix of another name (#2521) 2022-11-10 04:46:14 +03:00
native-api
a12f947cc3
Auto-resolve prefixes to the latest version (#2487) 2022-10-30 03:38:40 +03:00
James Stronz
47b0ce77c0
Re-allow paths in .python-version provided that they resolve to within the versions dir (#2442)
* Fixes #2430 while still preventing CVE-2022-35861
* Adds a skipped version message to stderr

Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2022-09-03 22:37:53 +03:00
James Stronz
22fa683571
CVE-2022-35861: Fixed relative path traversal due to using version string in path (#2412) 2022-07-17 01:01:04 +03:00
Pedro Fonini
fdaeaf1f97
Use version sort in pyenv versions if available (#2405) 2022-07-10 23:00:51 +03:00
Ivan Pozdeev
6d4365a696 Make pyenv init --path usable as a pyenv init - substitute
We're going to eliminate the need to mandatorily use `pyenv init --path`.
We can't delete it yet for backward compatibility.
Besides, there's one other use case for it: to enable shims but without
shell integration, e.g. for noninteractive shells.

To be a full-fledged replacement for `pyenv init -` however,
it needs to do rehashing.
2022-05-02 19:07:24 +03:00
Ivan Pozdeev
8439f8e187 Simplify init scheme; update & clarify the README
Now the setup is to add to both rc and profile:
1) set PYENV_ROOT
   (can do it unconditionally -- since if you change it,
   you need to update all places anyway since any of them can be run first)
2) Add `pyenv` to PATH if not already there
3) eval "$(pyenv init -)"

Not a breaking change, old setup will continue to work.
2022-05-02 19:07:24 +03:00
Ivan Pozdeev
32a86a84c0 Show output for assert_line() and refure_line()
Required for diagnostics
2022-05-02 04:46:00 +03:00
Ville Skyttä
a9e11ba164
Use command and type instead of which (#2144)
`which` has been deprecated in Debian's debianutils 5.0+
They suggest using `type` and `command` as replacements:
3a8dd10b45 ,
610a65c6ef
2021-11-11 21:08:12 +03:00
Ivan Pozdeev
c6c4e41eb9 Bats: show output on failed assertions 2021-09-21 05:07:17 +03:00
Ivan Pozdeev
f504b01818 consistent message 2021-09-21 05:07:12 +03:00
Ivan Pozdeev
876be1bb04 Bats: path_without: support multiple args 2021-09-21 05:07:12 +03:00
Ivan Pozdeev
6185bb55e6 allow for sys.executable to be different 2021-09-21 05:07:06 +03:00
Ivan Pozdeev
eb89256f59 Remove the sample code from pyenv init
since there proved to be to many cases to fit
2021-09-19 00:27:03 +03:00
Ivan Pozdeev
cabdc45181 fix possible side effect 2021-09-17 03:52:52 +03:00
Ivan Pozdeev
acc949c27b fix test 2021-09-15 20:42:41 +03:00
Ivan Pozdeev
26134d9b38 Allow system Python in sbin
Arch Linux has Python is sbin as well as bin
2021-09-15 19:07:00 +03:00
native-api
f7754ae6a4
Remove PATH warning (#2001)
* In some cases (Ubuntu), `pyenv init -` has to be run before `pyenv init --path`.
* The warning has served its purpose by now.
2021-07-03 09:48:13 +03:00
native-api
1706436fae
Use system Python3 for tests (#1979)
PEP 394 now doesn't require `python` presence or specify what it is.
Tests that invoke it use Py3-specific code.
2021-06-10 03:57:58 +03:00
Ivan Pozdeev
3e3f40fefc Warn users to add pyenv init --path to ~/.profile
To facilitate migration
2021-05-05 03:04:52 +03:00
Ivan Pozdeev
7838707595 Separate startup logic into PATH and the rest
PATH manipulation should be done in ~/.profile rather than ~/.*rc since .rc can be sourced multiple times
2021-05-05 03:04:51 +03:00
Ivan Pozdeev
b0b862ca64 Don't print actual PATH in test output 2021-05-05 01:29:18 +03:00
Anton Petrov
2924886a77
Merge pull request #1350 from maxbrunet/feature/versions/dotglob
List versions starting with a dot
2021-04-15 21:02:50 +03:00
Ville Skyttä
641916270b feat: support (skip) commented lines in version-file
Sometimes it is convenient to be able to temporarily disable something
in a version-file. Because these files often aren't necessarily tracked
in a SCM, especially when working with virtualenvs, the SCM diffs won't
help with showing removed lines which are currently the only way to
disable something.
2021-04-11 07:46:34 +03:00
Ville Skyttä
b5008ce74e test(init): remove misleading detect from parent shell case arg
The generated script does not take/use any arguments, so passing
/bin/zsh to it serves only to cause confusion.
2021-03-23 23:45:32 +02:00
Anton Petrov
afb14d2072
Merge pull request #1814 from native-api/rm_script_dir
Remove the "Using script's directory as PYENV_DIR if shim is invoked with a script argument" feature
2021-03-09 14:36:12 +03:00
Ville Skyttä
f06fb60b1f Make work in nounset (-u) mode 2021-02-23 22:29:56 +02:00
Ivan Pozdeev
e44490c639 Revert "add tests for PYENV_FILE_ARG"
This reverts commit 438e828eb5.

# Conflicts:
#	test/pyenv_ext.bats
2021-02-16 23:46:08 +03:00
cornfeedhobo
cadebd8e65
Search for plugins in PYENV_DIR and PYENV_ROOT (#1697) 2020-10-01 21:33:34 -04:00
M. Smits
71d2e4549e
Updated documentation pyenv init for fish shell comform to readme. (#1703) 2020-10-01 21:28:29 -04:00
Claudio Jolowicz
be595ededa
Fix duplicate test in prefix.bats due to bad merge (#1603)
The test "prefix for system in /" is duplicated in test/prefix.bats.
Both tests are completely identical. This commit removes the
duplication.

It appears that the culprit is this merge from rbenv/master, from 2016:

  cf1beda362

With the current development version of bats, this leads to the
following error when running `make test`:

  Error:
  Duplicate test name(s) in file
  "/home/travis/build/pyenv/pyenv/test/prefix.bats":
  test_prefix_for_system_in_-2f

Note that the development version is what pyenv's Makefile uses. With
the latest release of bats, the duplication only leads to a warning:

  bats warning:
  duplicate test name(s) in /src/test/prefix.bats:
  test_prefix_for_system_in_-2f
2020-05-01 13:46:49 -04:00
Brian Dowling
a8ca63fcc0
Update help docs to clarify multiple version(s) are allowed (#1197)
* Update help docs to clarify multiple version(s) are allowed

* Tweek version(s) help description
2020-03-19 17:35:46 -04:00
Daniel Hahler
ecd67c8223
pyenv-exec: no -a with exec to keep $PATH with system version (#1169)
Using `exec -a` caused Python to use $PATH to look up the full program name (for
`sys.executable`), which 314937d then tried to fix by changing $PATH
also for the system version.
This is not necessary anymore when not using the short name with `exec`.

This was rejected upstream
(https://github.com/rbenv/rbenv/pull/1089#issuecomment-394531896), since
it is not a problem with Ruby apparently.

Uses $PYENV_ROOT to check if system version is used.

Fixes https://github.com/pyenv/pyenv/issues/98.
Fixes https://github.com/pyenv/pyenv/issues/789.
2019-09-29 00:03:44 +02:00
Daniel Hahler
31b7e1c390
tests: remove "supports python -S <cmd>" (#1168)
This was imported semi-automatically in 0965577, but `ruby -S` is
different from `python -S`.

`ruby -S`: look for the script using PATH environment variable
`python -S`: don't imply 'import site' on initialization
2019-09-24 04:59:49 +02:00
Maxime Brunet
2b174ab69f List versions starting with a dot 2019-06-02 16:16:52 -04:00
Andrew Rabert
0f596d2504 Revert "Merge pull request #1153 from cmcginty/remove-sbang"
This reverts commit 070e1c859f, reversing
changes made to 3faeda67bb.
2019-04-23 10:23:33 -04:00
Christopher Hunt
070e1c859f
Merge pull request #1153 from cmcginty/remove-sbang
Remove shebang lines from scripts for performance
2019-04-22 20:13:19 -04:00
Casey McGinty
83e5459cfb Remove shebang lines from scripts for performance
All scripts in libexec/ (excluding pyenv) are called through pyenv,
therefore the shebang lines are not necessary. On some systems this
provides a measurable increase in performance of the shell prompt.

Related to pyenv/pyenv-virtualenv#259
2019-03-07 22:15:14 +01:00
Daniel Hahler
4f21d9a2ea Fix abs_dirname for relative symlinks in same directory
Ref (abs_dirname in bats): https://github.com/sstephenson/bats/pull/224
Ref: https://github.com/rbenv/rbenv/pull/868

Fixes https://github.com/pyenv/pyenv/issues/580
2018-09-19 10:18:07 +02:00
Yamashita, Yuu
1ec57a0c68 Add basic test for rehash wait 2018-04-24 00:42:47 +00:00
Yamashita, Yuu
7973e59473 Fix rehash test to give up sooner after lock file's presence 2018-04-24 00:38:01 +00:00