Skip to content

Commit

Permalink
added env._.python.venv directive
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 24, 2024
1 parent 1f359a6 commit 086179f
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 89 deletions.
3 changes: 2 additions & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ min_version = "2024.1.1"
[env]
_.file = [".env"]
_.path = ["./target/debug"]
_.python.venv = "{{env.HOME}}/.cache/venv"
FOO = "bar"
FOO_NUM = 1
THIS_PROJECT = "{{config_root}}-{{cwd}}"
Expand All @@ -13,7 +14,7 @@ THIS_PROJECT = "{{config_root}}-{{cwd}}"
"cargo:eza" = "0.17.0"
tiny = { version = "1", foo = "bar" }
golang = { version = "prefix:1.21", foo = "bar" }
python = { version = "latest", virtualenv = "{{env.HOME}}/.cache/venv" }
python = "latest"
ruby = "3.1"

[plugins]
Expand Down
6 changes: 4 additions & 2 deletions e2e/test_python
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ export MISE_EXPERIMENTAL=1
export MISE_PYTHON_DEFAULT_PACKAGES_FILE="$ROOT/e2e/.default-python-packages"

cat >.e2e.mise.toml <<EOF
[env._.python]
venv = {path = "{{env.MISE_DATA_DIR}}/venv", create=true}
[tools]
python = {version = "{{exec(command='echo 3.12.0')}}", virtualenv="{{env.MISE_DATA_DIR}}/venv"}
python = "{{exec(command='echo 3.12.0')}}"
EOF

mise i
mise x -- python -m venv "$MISE_DATA_DIR/venv"
#mise x -- python -m venv "$MISE_DATA_DIR/venv"
assert_contains "mise x [email protected] -- python --version" "Python 3.12.0"
assert_contains "mise env -s bash | grep VIRTUAL_ENV" "$MISE_DATA_DIR/venv"
assert "mise x -- which python" "$MISE_DATA_DIR/venv/bin/python"
Expand Down
27 changes: 27 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@
}
}
]
},
"python": {
"type": "object",
"description": "python environment",
"properties": {
"venv": {
"oneOf": [
{"description": "path to python virtual environment to use", "type": "string"},
{
"description": "virtualenv options",
"type": "object",
"required": ["path"],
"properties": {
"path": {
"description": "path to python virtual environment to use",
"type": "string"
},
"create": {
"description": "create a new virtual environment if one does not exist",
"type": "boolean",
"default": false
}
}
}
]
}
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/cli/settings/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ mod tests {
python_compile = false
python_default_packages_file = "~/.default-python-packages"
python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
python_venv_auto_create = false
quiet = false
raw = false
trusted_config_paths = []
Expand Down Expand Up @@ -129,7 +128,6 @@ mod tests {
python_compile
python_default_packages_file
python_pyenv_repo
python_venv_auto_create
quiet
raw
status
Expand Down
1 change: 0 additions & 1 deletion src/cli/settings/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ pub mod tests {
python_compile = false
python_default_packages_file = "~/.default-python-packages"
python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
python_venv_auto_create = false
quiet = false
raw = false
trusted_config_paths = []
Expand Down
1 change: 0 additions & 1 deletion src/cli/settings/unset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ mod tests {
python_compile = false
python_default_packages_file = "~/.default-python-packages"
python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
python_venv_auto_create = false
quiet = false
raw = false
trusted_config_paths = []
Expand Down
Loading

0 comments on commit 086179f

Please sign in to comment.