diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 59cf7d4b..c9930c81 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,8 +8,8 @@ jobs: os: - ubuntu-22.04 - ubuntu-20.04 - - macos-12 - - macos-11 + - macos-14 + - macos-13 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index b5976747..70280cfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Version History +#### 1.2.4 +* Fix failing to detect `-m venv` when "python" is not provided by the distro by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/479 +* README: Remove dollar signs from commands that are meant to be copied by @galonsky in https://github.com/pyenv/pyenv-virtualenv/pull/481 +* Reflect pyenv-latest switch change in 2.4.8 by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/484 + #### 1.2.3 * Fix: add `colorize` helper by @silverjam in https://github.com/pyenv/pyenv-virtualenv/pull/470 * Bump pyenv-virtualenv reporting version to match release by @ushuz in https://github.com/pyenv/pyenv-virtualenv/pull/471 diff --git a/README.md b/README.md index 66829808..d5338880 100644 --- a/README.md +++ b/README.md @@ -31,19 +31,19 @@ From inside that directory you can: 1. **Check out pyenv-virtualenv into plugin directory** ```sh - $ git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv + git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv ``` For the Fish shell: ```sh - $ git clone https://github.com/pyenv/pyenv-virtualenv.git (pyenv root)/plugins/pyenv-virtualenv + git clone https://github.com/pyenv/pyenv-virtualenv.git (pyenv root)/plugins/pyenv-virtualenv ``` 2. (OPTIONAL) **Add `pyenv virtualenv-init` to your shell** to enable auto-activation of virtualenvs. This is entirely optional but pretty useful. See "Activate virtualenv" below. ```sh - $ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc + echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc ``` **Fish shell note**: Add this to your `~/.config/fish/config.fish` @@ -57,7 +57,7 @@ From inside that directory you can: 3. **Restart your shell to enable pyenv-virtualenv** ```sh - $ exec "$SHELL" + exec "$SHELL" ``` @@ -72,13 +72,13 @@ installed, you will also be able to use the `pyenv virtualenv` command. with Homebrew.* ```sh -$ brew install pyenv-virtualenv +brew install pyenv-virtualenv ``` Or, if you would like to install the latest development release: ```sh -$ brew install --HEAD pyenv-virtualenv +brew install --HEAD pyenv-virtualenv ``` After installation, you'll still need to do @@ -99,7 +99,7 @@ To create a virtualenv for the Python version used with pyenv, run of the virtualenv directory. For example, ```sh -$ pyenv virtualenv 2.7.10 my-virtual-env-2.7.10 +pyenv virtualenv 2.7.10 my-virtual-env-2.7.10 ``` will create a virtualenv based on Python 2.7.10 under `$(pyenv root)/versions` in a diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index 83164228..f3b0f1b2 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -13,7 +13,7 @@ # -u/--upgrade Imply --force # -PYENV_VIRTUALENV_VERSION="1.2.3" +PYENV_VIRTUALENV_VERSION="1.2.4" set -e [ -n "$PYENV_DEBUG" ] && set -x @@ -155,9 +155,17 @@ detect_venv() { if [ -x "${prefix}/bin/virtualenv" ]; then HAS_VIRTUALENV=1 fi - # Prefer `python3.x` executable if available (#206, #282) local python - for python in "python${PYENV_VERSION%.*}" "python${PYENV_VERSION%%.*}" "python"; do + local -a pythons + if [[ $PYENV_VERSION == "system" ]]; then + # Prefer `python3.x` executable if available (#206, #282) + pythons=("python3" "python" "python2") + else + # as per PEP 394, custom activated Python environments should provide the "python" command + # this includes Pyenv-provided installations + pythons=("python") + fi + for python in "${pythons[@]}"; do if pyenv-exec "${python}" -m venv --help 1>/dev/null 2>&1; then HAS_M_VENV=1 M_VENV_PYTHON_BIN="${python}" @@ -317,7 +325,7 @@ else fi if [[ -n "${VERSION_NAME}" ]] && command -v pyenv-latest >/dev/null; then - VERSION_NAME="$(pyenv-latest -q "${VERSION_NAME}" || echo "${VERSION_NAME}")" + VERSION_NAME="$(pyenv-latest -f "${VERSION_NAME}")" fi if [ -z "${VERSION_NAME}" ] || [ -z "${VIRTUALENV_NAME}" ]; then diff --git a/test/envs.bats b/test/envs.bats index 93bc114c..325aa336 100644 --- a/test/envs.bats +++ b/test/envs.bats @@ -25,15 +25,15 @@ unstub_pyenv() { stub pyenv-version-name "echo '${PYENV_VERSION}'" stub pyenv-prefix " : echo '${PYENV_ROOT}/versions/${PYENV_VERSION}'" stub pyenv-virtualenv-prefix " : false" - stub pyenv-exec "python3.5 -m venv --help : true" - stub pyenv-exec "python3.5 -m venv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";mkdir -p \${PYENV_ROOT}/versions/3.5.1/envs/venv/bin" + stub pyenv-exec "python -m venv --help : true" + stub pyenv-exec "python -m venv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";mkdir -p \${PYENV_ROOT}/versions/3.5.1/envs/venv/bin" stub pyenv-exec "python -s -m ensurepip : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";touch \${PYENV_ROOT}/versions/3.5.1/envs/venv/bin/pip" run pyenv-virtualenv venv assert_success assert_output <