Repository navigation
Expand file tree
/
Copy pathgetsprite
More file actions
executable file
·97 lines (89 loc) · 3.03 KB
/
Copy pathgetsprite
File metadata and controls
executable file
·97 lines (89 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
# Install Sprite with uv; this file also works when piped into sh.
interactive=0
set -eu
usage() {
cat <<'USAGE'
Usage: sh getsprite [--dry-run] [--help]
sh getsprite-i [--dry-run] [--help]
Install or upgrade Sprite in your home directory, with its own Python.
--dry-run Print the plan without running commands or asking for confirmation.
GETSPRITE_FIND_LINKS Directory or URL of wheels, passed to uv as --find-links.
USAGE
}
dry_run=0
for arg do
case "$arg" in
--dry-run) dry_run=1 ;;
-h|--help) usage; exit 0 ;;
*) printf 'Unknown option: %s\n' "$arg" >&2; usage >&2; exit 2 ;;
esac
done
plan() {
cat <<'PLAN'
1. If uv is absent, install it in $HOME/.local/bin with the official installer:
curl -LsSf https://astral.sh/uv/install.sh | sh
(UV_INSTALL_DIR=$HOME/.local/bin; UV_NO_MODIFY_PATH=1)
2. Install or upgrade curry and its dependency curry-frontend in an isolated
tool environment in your home directory. Download managed CPython 3.11.4
or newer, below 3.16, if needed; leave the system Python alone:
uv tool install --upgrade --managed-python --python 'cpython>=3.11.4,<3.16' --no-build --with-executables-from curry-frontend curry
(UV_TOOL_BIN_DIR=$HOME/.local/bin)
PLAN
if [ -n "${GETSPRITE_FIND_LINKS:-}" ]; then
printf ' Additional wheel location (--find-links): %s\n' "$GETSPRITE_FIND_LINKS"
fi
cat <<'PLAN'
3. Add the commands sprite-exec and sprite-make to your PATH for this shell
and put this line in your shell startup file:
export PATH="$HOME/.local/bin:$PATH"
A C++ compiler (g++) is optional; without it new modules run interpreted.
PLAN
}
confirm() {
if [ "$interactive" = 1 ]; then
printf '%s [y/N] ' "$1"
# The script may arrive on stdin from curl; answers come from the terminal.
answer=
if [ -t 0 ]; then
read -r answer || answer=
else
read -r answer </dev/tty || answer=
fi
case "$answer" in
y|Y|yes|YES) ;;
*) printf '\nInstallation cancelled.\n'; exit 1 ;;
esac
fi
}
plan
if [ "$dry_run" = 1 ]; then
exit 0
fi
# Keep command installation in the user's home and leave shell files untouched.
UV_TOOL_BIN_DIR=$HOME/.local/bin
export UV_TOOL_BIN_DIR
if command -v uv >/dev/null 2>&1; then
uv=$(command -v uv)
elif [ -x "$HOME/.local/bin/uv" ]; then
uv=$HOME/.local/bin/uv
else
confirm 'Install uv?'
UV_INSTALL_DIR=$HOME/.local/bin
UV_NO_MODIFY_PATH=1
export UV_INSTALL_DIR UV_NO_MODIFY_PATH
curl -LsSf https://astral.sh/uv/install.sh | sh
uv=$HOME/.local/bin/uv
if [ ! -x "$uv" ]; then
printf 'The uv installer did not install uv in $HOME/.local/bin.\n' >&2
exit 1
fi
fi
confirm 'Install or upgrade Sprite and its managed Python with uv?'
set -- tool install --upgrade --managed-python --python 'cpython>=3.11.4,<3.16' --no-build --with-executables-from curry-frontend curry
if [ -n "${GETSPRITE_FIND_LINKS:-}" ]; then
set -- "$@" --find-links "$GETSPRITE_FIND_LINKS"
fi
"$uv" "$@"
printf '\nSprite installed. To use sprite-exec and sprite-make, run:\n'
printf ' export PATH="$HOME/.local/bin:$PATH"\n'