#!/usr/bin/env bash # # Summary: Package an installed Python version as a relocatable binary (experimental) # # Usage: pyenv binary [] # # `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 --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" "$@"