Skip to content

Commit ebf0460

Browse files
committed
feat: add one-line install script for Linux/macOS
Add scripts/install.sh, a POSIX sh installer invoked via curl -fsSL .../scripts/install.sh | sh. It installs Xinference as an isolated uv tool so it does not touch the system Python and avoids PEP 668 (externally-managed-environment) errors, bootstrapping uv first if needed. By default only the base package is installed; XINFERENCE_EXTRAS and XINFERENCE_VERSION allow opting into optional backends or pinning a version. Document the one-liner in the README quick start and the installation guide.
1 parent 6c98207 commit ebf0460

3 files changed

Lines changed: 133 additions & 1 deletion

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ For more customized installation methods on K8s, please refer to the [documentat
154154

155155
### Quick Start
156156

157-
Install Xinference by using pip as follows. (For more options, see [Installation page](https://inference.readthedocs.io/en/latest/getting_started/installation.html).)
157+
On Linux or macOS, install Xinference with a single command (installs it as an isolated [uv](https://docs.astral.sh/uv/) tool, no system Python changes):
158+
159+
```bash
160+
curl -fsSL https://raw.githubusercontent.com/xorbitsai/inference/main/scripts/install.sh | sh
161+
```
162+
163+
Or install with pip. (For more options, see [Installation page](https://inference.readthedocs.io/en/latest/getting_started/installation.html).)
158164

159165
```bash
160166
pip install "xinference[all]"

doc/source/getting_started/installation.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ Installation
55
============
66
Xinference can be installed with ``pip`` on Linux, Windows, and macOS. To run models using Xinference, you will need to install the backend corresponding to the type of model you intend to serve.
77

8+
One-line install (Linux/macOS)
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
On Linux or macOS you can install Xinference with a single command::
11+
12+
curl -fsSL https://raw.githubusercontent.com/xorbitsai/inference/main/scripts/install.sh | sh
13+
14+
This installs Xinference as an isolated `uv <https://docs.astral.sh/uv/>`_ tool, so it does not touch your
15+
system Python or run into ``externally-managed-environment`` (PEP 668) errors. It installs ``uv`` first if
16+
it is not already present.
17+
18+
By default it installs only the base package. To include optional backends, or to pin a version, set
19+
environment variables before running::
20+
21+
# Install with all backends (large; some extras require Linux + CUDA)
22+
curl -fsSL https://raw.githubusercontent.com/xorbitsai/inference/main/scripts/install.sh | XINFERENCE_EXTRAS=all sh
23+
24+
# Pin a specific version
25+
curl -fsSL https://raw.githubusercontent.com/xorbitsai/inference/main/scripts/install.sh | XINFERENCE_VERSION=1.8.1 sh
26+
27+
After installation, start the server with ``xinference-local`` and open the Web UI at ``http://127.0.0.1:9997``.
28+
29+
.. note::
30+
31+
Windows is not covered by the one-line installer. Install with ``pip`` in a virtualenv instead
32+
(see below).
33+
34+
Install with pip
35+
~~~~~~~~~~~~~~~~~
836
If you aim to serve all supported models, you can install all the necessary dependencies with a single command::
937

1038
pip install "xinference[all]"

scripts/install.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/sh
2+
# Xinference installer
3+
#
4+
# curl -fsSL https://raw.githubusercontent.com/xorbitsai/inference/main/scripts/install.sh | sh
5+
#
6+
# Installs the `xinference` package as an isolated uv tool, so nothing touches
7+
# your system Python and PEP 668 (externally-managed-environment) never bites.
8+
# On success the `xinference` / `xinference-local` commands are available; start
9+
# the server and open the Web UI.
10+
#
11+
# Options (environment variables):
12+
# XINFERENCE_VERSION pin a specific version, e.g. XINFERENCE_VERSION=1.8.1
13+
# XINFERENCE_EXTRAS install optional backends, e.g. XINFERENCE_EXTRAS=all
14+
# or XINFERENCE_EXTRAS=vllm,transformers (default: none).
15+
# Note: some extras (e.g. vllm) require Linux + CUDA and
16+
# may fail to install on macOS or CPU-only machines.
17+
#
18+
# Prefer not to pipe curl into sh? The equivalent manual install is:
19+
# uv tool install xinference # or, in a venv: pip install xinference
20+
set -eu
21+
22+
# The user's PATH before this script mutates it (below, when bootstrapping uv).
23+
# Used at the end to warn correctly about whether the parent shell will find the
24+
# installed command.
25+
ORIG_PATH="$PATH"
26+
27+
APP="xinference"
28+
# Command used to start the server locally (the `xinference` command itself is
29+
# the client CLI; `xinference-local` boots a standalone supervisor + worker).
30+
SERVE_CMD="xinference-local"
31+
PORT="9997"
32+
33+
info() { printf '\033[1;34m==>\033[0m %s\n' "$1"; }
34+
warn() { printf '\033[1;33mwarning:\033[0m %s\n' "$1" >&2; }
35+
err() {
36+
printf '\033[1;31merror:\033[0m %s\n' "$1" >&2
37+
exit 1
38+
}
39+
40+
# uv supports Linux and macOS. Windows users should use pip in a venv.
41+
os="$(uname -s)"
42+
case "$os" in
43+
Linux | Darwin) ;;
44+
*) err "Unsupported OS '$os'. On Windows, install with: pip install \"$APP[all]\" (in a virtualenv)." ;;
45+
esac
46+
47+
# Ensure uv is available (isolates the install; avoids system-Python/PEP 668).
48+
if ! command -v uv >/dev/null 2>&1; then
49+
info "Installing uv (Python tool manager)..."
50+
curl -LsSf https://astral.sh/uv/install.sh | sh
51+
# uv installs into ~/.local/bin (or ~/.cargo/bin on older installers); make it
52+
# visible to the rest of this script without requiring a new shell.
53+
for d in "$HOME/.local/bin" "$HOME/.cargo/bin"; do
54+
[ -d "$d" ] && PATH="$d:$PATH"
55+
done
56+
export PATH
57+
fi
58+
command -v uv >/dev/null 2>&1 || err "uv not found on PATH after install; open a new shell and re-run."
59+
60+
# Build the package spec: name[extras]==version, with each part optional.
61+
spec="$APP"
62+
if [ -n "${XINFERENCE_EXTRAS:-}" ]; then
63+
spec="$spec[$XINFERENCE_EXTRAS]"
64+
fi
65+
if [ -n "${XINFERENCE_VERSION:-}" ]; then
66+
# Strip a leading 'v' (e.g. v1.8.1 -> 1.8.1) so a git-tag-style value works.
67+
version="${XINFERENCE_VERSION#v}"
68+
[ -n "$version" ] || err "XINFERENCE_VERSION='$XINFERENCE_VERSION' is not a valid version."
69+
spec="$spec==$version"
70+
fi
71+
72+
info "Installing $spec ..."
73+
uv tool install --upgrade "$spec"
74+
75+
printf '\n'
76+
info "Installed. Next steps:"
77+
printf '\n'
78+
printf ' Start the server: %s\n' "$SERVE_CMD"
79+
printf ' Open the Web UI: http://127.0.0.1:%s\n' "$PORT"
80+
if [ -z "${XINFERENCE_EXTRAS:-}" ]; then
81+
printf '\n'
82+
printf ' This installed the base package. To add an inference backend later, e.g.:\n'
83+
printf ' uv tool install --upgrade "%s[transformers]" # PyTorch / transformers\n' "$APP"
84+
printf ' uv tool install --upgrade "%s[vllm]" # vLLM (Linux + CUDA)\n' "$APP"
85+
printf ' uv tool install --upgrade "%s[mlx]" # MLX (Apple silicon)\n' "$APP"
86+
printf ' Or reinstall everything with XINFERENCE_EXTRAS=all.\n'
87+
fi
88+
printf '\n'
89+
90+
if ! PATH="$ORIG_PATH" command -v "$SERVE_CMD" >/dev/null 2>&1; then
91+
warn "'$SERVE_CMD' is not on your PATH in this shell yet."
92+
if PATH="$ORIG_PATH" command -v uv >/dev/null 2>&1; then
93+
warn "Run 'uv tool update-shell' and open a new terminal, then run '$SERVE_CMD'."
94+
else
95+
# uv was just installed by this script and isn't on the parent shell's PATH.
96+
warn "Open a new terminal, or run: export PATH=\"\$HOME/.local/bin:\$PATH\""
97+
fi
98+
fi

0 commit comments

Comments
 (0)