Skip to content

Commit

Permalink
add support a new env var to auto activate poetry (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
verte-zerg authored Dec 11, 2024
1 parent 46c5d79 commit c285853
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ poetry = {version='latest', pyproject='pyproject.toml'}
python = '3.11' # must be after poetry so the poetry bin is first in PATH
```

You can also set `MISE_POETRY_VENV_AUTO=1` to automatically activate the virtualenv if the
project contains both `pyproject.toml` and `poetry.lock` files.

Set `MISE_POETRY_AUTO_INSTALL=1` to automatically run `poetry install` to create the virtualenv.

## License
Expand Down
8 changes: 7 additions & 1 deletion bin/utils.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ poetry_bin() {
poetry_venv() {
local pyproject
pyproject="$(eval "echo ${MISE_TOOL_OPTS__PYPROJECT-}")"
if [ "$pyproject" = "" ]; then
if [[ "${MISE_POETRY_VENV_AUTO:-}" != "true" ]] && [[ "${MISE_POETRY_VENV_AUTO:-}" != "1" ]]; then
if [ "$pyproject" = "" ]; then
return 1
fi
elif [[ ! -f "poetry.lock" ]] | [[ ! -f "pyproject.toml" ]]; then
return 1
else
pyproject="pyproject.toml"
fi
if [[ $pyproject != /* ]] && [[ -n ${MISE_PROJECT_ROOT-} ]]; then
pyproject="${MISE_PROJECT_ROOT-}/$pyproject"
Expand Down

0 comments on commit c285853

Please sign in to comment.