pyenv/plugins/pyenv-binary/bin/pyenv-binary
macayu17 6188e9efa9 pyenv-binary: add the generate-installer subcommand
* Relocation only implemented for Linux (requires patchelf + ldconfig -p)
* Shell-completing file name is not possible with current Pyenv completion logic:
  `pyenv-complete` does not pass info about the word being completed
* Fix `save`-produced tarball to be compatible with Python-Build fetch_tarball()
* Reuse test_helper from core

--

Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2026-07-16 10:39:50 +03:00

66 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Summary: Package an installed Python version as a relocatable binary (experimental)
#
# Usage: pyenv binary <command> [<args>]
#
# `pyenv binary` packages an already-installed Python version into a relocatable
# archive that can be installed on another machine. It is experimental and does
# not touch `pyenv install' or any other command.
#
# Run `pyenv binary' to list its commands, or `pyenv binary <command> --help'
# for command-specific help.
#
set -e
[ -n "$PYENV_DEBUG" ] && set -x
libexec="${BASH_SOURCE%/*}/../libexec"
# The pyenv launcher only puts a plugin's bin on PATH, but `pyenv-help' looks a
# command up there. Add our libexec so the subcommands, and the help text they
# print, can be found.
export PATH="${libexec}:${PATH}"
list_commands() {
local path
for path in "$libexec"/pyenv-binary-*; do
[ -e "$path" ] && echo "${path##*/pyenv-binary-}"
done
}
# Provide pyenv completions
if [ "$1" = "--complete" ]; then
shift
if [ -z "$1" ]; then
list_commands
else
command_path="${libexec}/pyenv-binary-$1"
shift
[ -x "$command_path" ] && exec "$command_path" --complete "$@"
fi
exit
fi
subcommand="$1"
if [ -z "$subcommand" ]; then
{ pyenv-help binary
echo
echo "Commands:"
list_commands | sed 's/^/ /'
} >&2
exit 1
fi
shift
command_path="${libexec}/pyenv-binary-${subcommand}"
if [ ! -x "$command_path" ]; then
echo "pyenv-binary: no such command \`${subcommand}'" >&2
exit 1
fi
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
exec pyenv-help "binary-${subcommand}"
fi
exec "$command_path" "$@"