mise icon indicating copy to clipboard operation
mise copied to clipboard

mise python plugin always try to compile python...

Open lmignon opened this issue 10 months ago • 13 comments

Describe the bug When I try to use a python version, mise always try to compile python from sources even if the 'python_compile' setting is set to false

To Reproduce

mise use -g [email protected]

> Downloading Python-3.11.9.tar.xz...
> -> https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tar.xz
> Installing Python-3.11.9...
> mise [email protected] Running python-build    
 ...

Expected behavior

python should be installed from pre-compiled binaries.

mise doctor output

version: 2024.4.0 linux-x64 (bcd3592 2024-04-02)
activated: yes
shims_on_path: no

build_info: 
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Tue, 2 Apr 2024 01:29:57 +0000
  Rust Version: rustc 1.77.1 (7cf61ebde 2024-03-27)
  Profile: release

shell: 
  /bin/bash
  GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
  Copyright (C) 2020 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

  This is free software; you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

dirs: 
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/.cache/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files: 
  ~/.config/mise/config.toml

plugins: 
  bun     (core)
  deno    (core)
  go      (core)
  java    (core)
  node    (core)
  python  (core)
  ruby    (core)

toolset: 
  [email protected]  (missing)

env_vars: 
  MISE_SHELL=bash

settings: 
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_tools = []
  experimental = false
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_compile = false
  python_default_packages_file = "/home/lmi/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = false
  yes = false
  ci = false
  debug = false
  trace = false
  log_level = "info"
  python_venv_auto_create = false

  [status]
  missing_tools = "if_other_versions_installed"
  show_env = false
  show_tools = false

No problems found

Additional context On ubuntu 22.04.

lmignon avatar Apr 04 '24 15:04 lmignon

are you running alpine or nixos? https://github.com/jdx/mise/blob/9138e2e6ec09a36c7791c9a6b4e5f7ab138fcb63/src/config/settings.rs#L178

jdx avatar Apr 06 '24 17:04 jdx

are you running alpine or nixos?

https://github.com/jdx/mise/blob/9138e2e6ec09a36c7791c9a6b4e5f7ab138fcb63/src/config/settings.rs#L178

Ubuntu 22.04.4 LTS AKA jammy

image

lmignon avatar Apr 08 '24 06:04 lmignon

Running the following rust program:

use sys_info;

fn linux_distro() -> Option<String> {
    match sys_info::linux_os_release() {
        Ok(release) => Some(release.id?),
        _ => None,
    }
}

fn main() {
    match linux_distro() {
        Some(distro) => println!("The Linux distribution is: {}", distro),
        None => println!("Could not determine the Linux distribution"),
    }
}

give: The Linux distribution is: ubuntu

lmignon avatar Apr 08 '24 07:04 lmignon

Hi,

I'm also experiencing this issue, have this nice docker one liner that reproduces the problem:

docker run -it --rm debian:12 bash -c "apt update && apt install -y git curl && curl -L --fail https://github.com/jdx/mise/releases/download/v2024.4.1/mise-v2024.4.1-linux-x64 -o mise && chmod u+x mise && ./mise -v use [email protected]"

Output truncated for brevity

...
Running hooks in /etc/ca-certificates/update.d...
done.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 21.6M  100 21.6M    0     0  5929k      0  0:00:03  0:00:03 --:--:-- 7026k
[DEBUG] ARGS: ./mise -v use [email protected]
[DEBUG] Config {
    Config Files: [],
}
[DEBUG] Toolset:
[DEBUG] GET http://mise-versions.jdx.dev/python
[DEBUG] starting new connection: http://mise-versions.jdx.dev/
[DEBUG] GET http://mise-versions.jdx.dev/python 200 OK
[DEBUG] GET http://mise-versions.jdx.dev/python-precompiled
[DEBUG] GET http://mise-versions.jdx.dev/python-precompiled 200 OK
[DEBUG] Installing python-build to /root/.cache/mise/python/pyenv
[DEBUG] cloning https://github.com/pyenv/pyenv.git to /root/.cache/mise/python/pyenv
[DEBUG] $ git --version
[DEBUG] $ git clone -q --depth 1 https://github.com/pyenv/pyenv.git /root/.cache/mise/python/pyenv
Running python-build
[DEBUG] $ ~/.cache/mise/python/pyenv/plugins/python-build/bin/python-build 3.11.9 /root/.local/share/mise/installs/python/3.11.9 --verbose
Downloading Python-3.11.9.tar.gz...
-> https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz
/tmp/python-build.20240408140236.3197 /
Installing Python-3.11.9...
BUILD FAILED (Debian GNU/Linux 12 using python-build 2.4.0)
Inspect or clean up the working tree at /tmp/python-build.20240408140236.3197
Results logged to /tmp/python-build.20240408140236.3197.log
Last 10 log lines:
checking for pkg-config... no
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/python-build.20240408140236.3197/Python-3.11.9':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[ERROR] ~/.cache/mise/python/pyenv/plugins/python-build/bin/python-build failed
Error:
   0: ~/.cache/mise/python/pyenv/plugins/python-build/bin/python-build exited with non-zero status: exit code 1

Location:
   src/cmd.rs:372

Version:
   2024.4.1 linux-x64 (d3579eb 2024-04-08)

Suggestion: Run with --verbose or MISE_VERBOSE=1 for more information.

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

As you can see, it attempts to download the tgz and build python.

Let me know if I can provide any other information

nonell-viavi avatar Apr 08 '24 14:04 nonell-viavi

so the reason is pretty simple, indygreg just hasn't created a release with 3.11.9 yet: https://github.com/indygreg/python-build-standalone/releases

jdx avatar Apr 08 '24 16:04 jdx

so the reason is pretty simple, indygreg just hasn't created a release with 3.11.9 yet: https://github.com/indygreg/python-build-standalone/releases

Do you mean that I've to check which version is available on https://github.com/indygreg/python-build-standalone/releases and nerver use the command mise use [email protected] or mise use [email protected]? I must specify the exact version to use?

lmignon avatar Apr 08 '24 16:04 lmignon

if you specify mise use [email protected] it means to use the latest version of 3.11. If that is a version that has a precompiled binary available, the precompiled version will be used. If not, mise must compile in order to get the latest version.

Perhaps a setting could be added to use the latest precompiled version and never use compiled versions. Maybe MISE_PYTHON_COMPILE=never or something.

jdx avatar Apr 08 '24 16:04 jdx

Perhaps a setting could be added to use the latest precompiled version and never use compiled versions.

As long as you explicitly specify that you don't want to build python, shouldn't the default be to use the latest precompiled version available? For me, an additional flag wouldn't make much difference. Furthermore, the choice to set python_compile to false is justified in my case by the desire to avoid having to install the dev libs needed to compile python.

lmignon avatar Apr 08 '24 16:04 lmignon

Instead of an additional flag, wouldn't it be more interesting to simply inform the user that the latest precompiled version available is prior to the latest python release and inform him that if he wishes to obtain this version he must enable python compilation in his configuration. :thinking:

lmignon avatar Apr 08 '24 16:04 lmignon

I think it's more important to use the correct version than it is to always use precompiled binaries. This also matches how other languages and tools in this space behave. Precompilation is an optimization, not generally a requirement—though I'm willing to accept that being optional behavior.

jdx avatar Apr 08 '24 17:04 jdx

so the reason is pretty simple, indygreg just hasn't created a release with 3.11.9 yet: https://github.com/indygreg/python-build-standalone/releases

Doh, I didn't think of that 😅

mise use [email protected] does exactly what I expect it to do, we will pin the minor version in our repos.

Many thanks for the quick response!

nonell-viavi avatar Apr 08 '24 18:04 nonell-viavi

I think it's more important to use the correct version than it is to always use precompiled binaries. This also matches how other languages and tools in this space behave. Precompilation is an optimization, not generally a requirement—though I'm willing to accept that being optional behavior.

It makes sense. In such a case your proposal for an additional setting could cover both needs.

BTW thank you for this great tool!

lmignon avatar Apr 09 '24 07:04 lmignon

(maybe fold this into https://github.com/jdx/mise/issues/1684 ?)

egnor avatar Apr 11 '24 15:04 egnor