mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-16 07:23:51 -05:00
Compare commits
2 Commits
master
...
abaeb2af6c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abaeb2af6c | ||
|
|
5d7894d189 |
3
.github/workflows/tests.yml
vendored
3
.github/workflows/tests.yml
vendored
@@ -6,9 +6,8 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-24.04
|
|
||||||
- ubuntu-22.04
|
- ubuntu-22.04
|
||||||
- macos-15
|
- ubuntu-20.04
|
||||||
- macos-14
|
- macos-14
|
||||||
- macos-13
|
- macos-13
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2025 Yamashita, Yuu
|
Copyright (c) 2015 Yamashita, Yuu
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ From inside that directory you can:
|
|||||||
- Get the latest development release by running `git pull` to download the
|
- Get the latest development release by running `git pull` to download the
|
||||||
latest changes.
|
latest changes.
|
||||||
|
|
||||||
💡 **WSL note:** If you're using WSL, we recommend setting Git to use Unix-style line endings to prevent script execution errors:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git config --global core.autocrlf input
|
|
||||||
```
|
|
||||||
|
|
||||||
1. **Check out pyenv-virtualenv into plugin directory**
|
1. **Check out pyenv-virtualenv into plugin directory**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -88,7 +82,7 @@ brew install --HEAD pyenv-virtualenv
|
|||||||
```
|
```
|
||||||
|
|
||||||
After installation, you'll still need to do
|
After installation, you'll still need to do
|
||||||
[Pyenv shell setup steps](https://github.com/pyenv/pyenv#b-set-up-your-shell-environment-for-pyenv)
|
[Pyenv shell setup steps](https://github.com/pyenv/pyenv#basic-github-checkout)
|
||||||
then add
|
then add
|
||||||
```sh
|
```sh
|
||||||
eval "$(pyenv virtualenv-init -)"
|
eval "$(pyenv virtualenv-init -)"
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ fi
|
|||||||
|
|
||||||
{ printf "\x1B[31;1m"
|
{ printf "\x1B[31;1m"
|
||||||
echo
|
echo
|
||||||
echo "\`pyenv activate' requires Pyenv and Pyenv-Virtualenv to be loaded into your shell."
|
echo "Failed to activate virtualenv."
|
||||||
echo "Check your shell configuration and Pyenv and Pyenv-Virtualenv installation instructions."
|
echo
|
||||||
|
echo "Perhaps pyenv-virtualenv has not been loaded into your shell properly."
|
||||||
|
echo "Please restart current shell and try again."
|
||||||
echo
|
echo
|
||||||
printf "\x1B[0m"
|
printf "\x1B[0m"
|
||||||
} 1>&2
|
} 1>&2
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ set -e
|
|||||||
|
|
||||||
{ printf "\x1B[31;1m"
|
{ printf "\x1B[31;1m"
|
||||||
echo
|
echo
|
||||||
echo "\`pyenv deactivate' requires Pyenv and Pyenv-Virtualenv to be loaded into your shell."
|
echo "Failed to deactivate virtualenv."
|
||||||
echo "Check your shell configuration and Pyenv and Pyenv-Virtualenv installation instructions."
|
echo
|
||||||
|
echo "Perhaps pyenv-virtualenv has not been loaded into your shell properly."
|
||||||
|
echo "Please restart current shell and try again."
|
||||||
echo
|
echo
|
||||||
printf "\x1B[0m"
|
printf "\x1B[0m"
|
||||||
} 1>&2
|
} 1>&2
|
||||||
|
|||||||
@@ -605,13 +605,7 @@ STATUS=0
|
|||||||
mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}"
|
mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}"
|
||||||
cd "${PYENV_VIRTUALENV_CACHE_PATH}"
|
cd "${PYENV_VIRTUALENV_CACHE_PATH}"
|
||||||
if [ -n "${USE_CONDA}" ]; then
|
if [ -n "${USE_CONDA}" ]; then
|
||||||
if [ -z "$VIRTUALENV_PYTHON" ]; then
|
pyenv-exec conda create $QUIET $VERBOSE --name "${VIRTUALENV_PATH##*/}" --yes "${VIRTUALENV_OPTIONS[@]}" python || STATUS="$?"
|
||||||
#process substitution doesn't seem to work unless it's directly inserted to the command line
|
|
||||||
#if we add it to VIRTUALENV_OPTIONS instead, "broken pipe" happens
|
|
||||||
pyenv-exec conda create $QUIET $VERBOSE --name "${VIRTUALENV_PATH##*/}" --yes "${VIRTUALENV_OPTIONS[@]}" --file <(pyenv-exec conda list python --full-name --export) || STATUS="$?"
|
|
||||||
else
|
|
||||||
pyenv-exec conda create $QUIET $VERBOSE --name "${VIRTUALENV_PATH##*/}" --yes "${VIRTUALENV_OPTIONS[@]}" || STATUS="$?"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [ -n "${USE_M_VENV}" ]; then
|
if [ -n "${USE_M_VENV}" ]; then
|
||||||
pyenv-exec "${M_VENV_PYTHON_BIN:-python}" -m venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"
|
pyenv-exec "${M_VENV_PYTHON_BIN:-python}" -m venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"
|
||||||
@@ -631,8 +625,7 @@ fi
|
|||||||
|
|
||||||
## Create symlink in the `versions` directory for backward compatibility
|
## Create symlink in the `versions` directory for backward compatibility
|
||||||
if [ -d "${VIRTUALENV_PATH}" ] && [ -n "${COMPAT_VIRTUALENV_PATH}" ]; then
|
if [ -d "${VIRTUALENV_PATH}" ] && [ -n "${COMPAT_VIRTUALENV_PATH}" ]; then
|
||||||
# Overwrite an existing link, can happen if running with -f
|
ln -fs "${VIRTUALENV_PATH}" "${COMPAT_VIRTUALENV_PATH}"
|
||||||
ln -fsn "${VIRTUALENV_PATH}" "${COMPAT_VIRTUALENV_PATH}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "${VIRTUALENV_PATH}/bin/pydoc" ]; then
|
if [ ! -e "${VIRTUALENV_PATH}/bin/pydoc" ]; then
|
||||||
|
|||||||
@@ -95,8 +95,10 @@ EOS
|
|||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
|
if [[ ":$PATH:" != *"${PYENV_VIRTUALENV_ROOT:-${PYENV_VIRTUALENV_INSTALL_PREFIX}}/shims"* ]]; then
|
||||||
export PATH="${PYENV_VIRTUALENV_ROOT:-${PYENV_VIRTUALENV_INSTALL_PREFIX}}/shims:\${PATH}";
|
export PATH="${PYENV_VIRTUALENV_ROOT:-${PYENV_VIRTUALENV_INSTALL_PREFIX}}/shims:\${PATH}";
|
||||||
export PYENV_VIRTUALENV_INIT=1;
|
export PYENV_VIRTUALENV_INIT=1;
|
||||||
|
fi
|
||||||
EOS
|
EOS
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ unstub_pyenv() {
|
|||||||
run pyenv-virtualenv venv
|
run pyenv-virtualenv venv
|
||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output_wildcards <<OUT
|
assert_output <<OUT
|
||||||
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes --file /dev/fd/*
|
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python
|
||||||
rehashed
|
rehashed
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ OUT
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python=3.5
|
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python=3.5 python
|
||||||
rehashed
|
rehashed
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ OUT
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python=3.5
|
PYENV_VERSION=miniconda3-3.16.0 conda create --name venv --yes python=3.5 python
|
||||||
rehashed
|
rehashed
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,10 @@ load test_helper
|
|||||||
run pyenv-virtualenv-init - bash
|
run pyenv-virtualenv-init - bash
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
|
if [[ ":$PATH:" != *"${TMP}/pyenv/plugins/pyenv-virtualenv/shims"* ]]; then
|
||||||
export PATH="${TMP}/pyenv/plugins/pyenv-virtualenv/shims:\${PATH}";
|
export PATH="${TMP}/pyenv/plugins/pyenv-virtualenv/shims:\${PATH}";
|
||||||
export PYENV_VIRTUALENV_INIT=1;
|
export PYENV_VIRTUALENV_INIT=1;
|
||||||
|
fi
|
||||||
_pyenv_virtualenv_hook() {
|
_pyenv_virtualenv_hook() {
|
||||||
local ret=\$?
|
local ret=\$?
|
||||||
if [ -n "\${VIRTUAL_ENV-}" ]; then
|
if [ -n "\${VIRTUAL_ENV-}" ]; then
|
||||||
@@ -93,8 +95,10 @@ EOS
|
|||||||
run pyenv-virtualenv-init - zsh
|
run pyenv-virtualenv-init - zsh
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
|
if [[ ":$PATH:" != *"${TMP}/pyenv/plugins/pyenv-virtualenv/shims"* ]]; then
|
||||||
export PATH="${TMP}/pyenv/plugins/pyenv-virtualenv/shims:\${PATH}";
|
export PATH="${TMP}/pyenv/plugins/pyenv-virtualenv/shims:\${PATH}";
|
||||||
export PYENV_VIRTUALENV_INIT=1;
|
export PYENV_VIRTUALENV_INIT=1;
|
||||||
|
fi
|
||||||
_pyenv_virtualenv_hook() {
|
_pyenv_virtualenv_hook() {
|
||||||
local ret=\$?
|
local ret=\$?
|
||||||
if [ -n "\${VIRTUAL_ENV-}" ]; then
|
if [ -n "\${VIRTUAL_ENV-}" ]; then
|
||||||
|
|||||||
@@ -83,16 +83,6 @@ assert_equal() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_equal_wildcards() {
|
|
||||||
if [[ $1 != $2 ]]; then
|
|
||||||
{ echo "expected:"
|
|
||||||
echo "$2"
|
|
||||||
echo "actual:"
|
|
||||||
echo "$1"
|
|
||||||
} | flunk
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_output() {
|
assert_output() {
|
||||||
local expected
|
local expected
|
||||||
if [ $# -eq 0 ]; then expected="$(cat -)"
|
if [ $# -eq 0 ]; then expected="$(cat -)"
|
||||||
@@ -101,14 +91,6 @@ assert_output() {
|
|||||||
assert_equal "$expected" "$output"
|
assert_equal "$expected" "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_output_wildcards() {
|
|
||||||
local expected
|
|
||||||
if [ $# -eq 0 ]; then expected="$(cat -)"
|
|
||||||
else expected="$1"
|
|
||||||
fi
|
|
||||||
assert_equal_wildcards "$output" "$expected"
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_output_contains() {
|
assert_output_contains() {
|
||||||
local expected="$1"
|
local expected="$1"
|
||||||
echo "$output" | grep -F "$expected" >/dev/null || {
|
echo "$output" | grep -F "$expected" >/dev/null || {
|
||||||
|
|||||||
Reference in New Issue
Block a user