Commit graph

239 commits

Author SHA1 Message Date
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
Yamashita, Yuu
83429344ea Rewrite some tests for pyenv which was recently imported from rbenv 2018-04-02 01:52:42 +00:00
Yamashita, Yuu
83f97ef2b3 Merge remote-tracking branch 'rbenv/master' into rbenv-20180402 2018-04-02 01:46:48 +00:00
Victor Lim
9daf81f16e Fix https://github.com/rbenv/rbenv/issues/1065
Command `rbenv version-name > .ruby-version` will create an empty `.ruby-version` file
before running `rbenv-version-file`. This causes `rbenv-version-file` to return empty
string which in turn causes `rbenv-version-name` to return `system`.

Ensure size of `.ruby-version` is non-zero as a workaround.
2018-02-26 16:49:37 +08:00
Marco Hinz
643023d98f
Add tests for shell integration 2017-12-07 02:32:35 +01:00
Daniel Hahler
a9ca72ab8e test/which.bats: do not export PATH
Otherwise `sed` might not be found later in bats/libexec/bats-exec-test,
in case `/usr/bin` gets removed.
2017-11-20 04:22:05 +01:00
Daniel Hahler
3fd23431af Merge remote-tracking branch 'rbenv/master'
Conflicts:
	README.md
	libexec/pyenv---version
	libexec/pyenv-init
	libexec/rbenv
	libexec/rbenv-sh-shell
	libexec/rbenv-which
	test/init.bats
	test/shell.bats
2017-06-05 15:18:44 +02:00
Jeff Kowalski
a81da8d864 Revert quoting change in previous commit; adjust test to match code
Revert back to original quoting style used before previous commit.
Adjust init.bats to reflect changes for successful tests.
2017-05-16 13:36:06 -07:00
Yamashita, Yuu
bec978d0f6 Workaround for CI failures with versions with multiple digits
https://travis-ci.org/pyenv/pyenv/jobs/215777826
2017-03-28 04:43:28 +00:00
Yamashita, Yuu
d01fa09a7d Migrate project URL to https://github.com/pyenv/pyenv 2017-03-06 04:31:48 +00:00