test: add test cases for venv templates (#3683)

Fixes #3661
This commit is contained in:
jdx 2024-12-18 10:42:55 -06:00 committed by GitHub
parent 2e62fbe05a
commit 1cf5b49b4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 12 deletions

View File

@ -56,14 +56,14 @@ variable.
## Precompiled python binaries
By default, mise will
download [precompiled binaries](https://github.com/indygreg/python-build-standalone)
download [precompiled binaries](https://github.com/astral-sh/python-build-standalone)
for python instead of compiling them with python-build. This makes installing python much faster.
In addition to being faster, it also means you don't have to install all of the system dependencies
either.
That said, there are
some [quirks](https://github.com/indygreg/python-build-standalone/blob/main/docs/quirks.rst)
some [quirks](https://github.com/astral-sh/python-build-standalone/blob/main/docs/quirks.rst)
with the precompiled binaries to be aware of.
If you'd like to disable these binaries, set `mise settings python.compile=1`.

View File

@ -4,15 +4,15 @@ export MISE_PYTHON_DEFAULT_PACKAGES_FILE="$HOME/.default-python-packages"
cat >.mise.toml <<EOF
[env._.python]
venv = {path = "my_venv", create=true}
venv = {path = "{{env.HOME}}/my_venv", create=true}
[tools]
python = "3.12.3"
EOF
mise i
assert "mise x -- python --version" "Python 3.12.3"
assert "mise env -s bash | grep VIRTUAL_ENV" "export VIRTUAL_ENV=$PWD/my_venv"
assert "mise x -- which python" "$PWD/my_venv/bin/python"
assert "mise env -s bash | grep VIRTUAL_ENV" "export VIRTUAL_ENV=$HOME/my_venv"
assert "mise x -- which python" "$HOME/my_venv/bin/python"
# verify nested virtualenv is used
mkdir -p subdir

15
e2e/env/test_env_file vendored
View File

@ -1,23 +1,21 @@
#!/usr/bin/env bash
cat <<'EOF' >mise.toml
cat <<EOF >mise.toml
[env]
mise.file = ['.test-env']
EOF
echo FOO_FROM_FILE=foo_from_file >.test-env
echo TEST_ENV2=foo >.test-env2
assert "mise x -- env | grep FOO_FROM_FILE" "FOO_FROM_FILE=foo_from_file"
assert "MISE_ENV_FILE=.test-env2 mise x -- env | grep TEST_ENV2" "TEST_ENV2=foo"
cat <<'EOF' >mise.toml
cat <<EOF >mise.toml
[env]
_.file = 'not_present'
EOF
assert "mise env" # does not error
cat <<'EOF' >mise.toml
cat <<EOF >mise.toml
[env]
_.file = ['a', 'b.json']
EOF
@ -25,3 +23,10 @@ echo 'export A=1' >a
echo '{"B": 2}' >b.json
assert "mise env | grep -v PATH" "export A=1
export B=2"
cat <<EOF >mise.toml
[env]
mise.file = ['{{env.HOME}}/.home-test-env']
EOF
echo FOO_FROM_FILE=foo_from_file_home >~/.home-test-env
assert "mise x -- env | grep FOO_FROM_FILE" "FOO_FROM_FILE=foo_from_file_home"

View File

@ -173,14 +173,14 @@ impl PythonPlugin {
if cfg!(unix) {
hint!(
"python_precompiled",
"installing precompiled python from indygreg/python-build-standalone\n\
"installing precompiled python from astral-sh/python-build-standalone\n\
if you experience issues with this python (e.g.: running poetry), switch to python-build by running",
"mise settings python.compile=1"
);
}
let url = format!(
"https://github.com/indygreg/python-build-standalone/releases/download/{tag}/{filename}"
"https://github.com/astral-sh/python-build-standalone/releases/download/{tag}/{filename}"
);
let filename = url.split('/').last().unwrap();
let install = tv.install_path();