forked from openai/codex-universal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_universal.sh
More file actions
62 lines (52 loc) · 2.38 KB
/
setup_universal.sh
File metadata and controls
62 lines (52 loc) · 2.38 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
#!/bin/bash --login
set -euo pipefail
CODEX_ENV_PYTHON_VERSION=${CODEX_ENV_PYTHON_VERSION:-}
CODEX_ENV_NODE_VERSION=${CODEX_ENV_NODE_VERSION:-}
CODEX_ENV_RUST_VERSION=${CODEX_ENV_RUST_VERSION:-}
CODEX_ENV_GO_VERSION=${CODEX_ENV_GO_VERSION:-}
CODEX_ENV_SWIFT_VERSION=${CODEX_ENV_SWIFT_VERSION:-}
echo "Configuring language runtimes..."
# For Python and Node, always run the install commands so we can install
# global libraries for linting and formatting. This just switches the version.
# For others (e.g. rust), to save some time on bootup we only install other language toolchains
# if the versions differ.
if [ -n "${CODEX_ENV_PYTHON_VERSION}" ]; then
echo "# Python: ${CODEX_ENV_PYTHON_VERSION}"
pyenv global "${CODEX_ENV_PYTHON_VERSION}"
fi
if [ -n "${CODEX_ENV_NODE_VERSION}" ]; then
echo "# Node.js: ${CODEX_ENV_NODE_VERSION}"
nvm alias default "${CODEX_ENV_NODE_VERSION}"
nvm use "${CODEX_ENV_NODE_VERSION}"
corepack enable
corepack install -g yarn pnpm npm
fi
if [ -n "${CODEX_ENV_RUST_VERSION}" ]; then
current=$(rustc --version | awk '{print $2}') # ==> 1.86.0
echo "# Rust: ${CODEX_ENV_RUST_VERSION} (default: ${current})"
if [ "${current}" != "${CODEX_ENV_RUST_VERSION}" ]; then
rustup toolchain install --no-self-update "${CODEX_ENV_RUST_VERSION}"
rustup default "${CODEX_ENV_RUST_VERSION}"
# Pre-install common linters/formatters
# clippy is already installed
fi
fi
if [ -n "${CODEX_ENV_GO_VERSION}" ]; then
current=$(go version | awk '{print $3}') # ==> go1.23.8
echo "# Go: go${CODEX_ENV_GO_VERSION} (default: ${current})"
if [ "${current}" != "go${CODEX_ENV_GO_VERSION}" ]; then
go install "golang.org/dl/go${CODEX_ENV_GO_VERSION}@latest"
"go${CODEX_ENV_GO_VERSION}" download
# Place new go first in PATH
echo "export PATH=$("go${CODEX_ENV_GO_VERSION}" env GOROOT)/bin:\$PATH" >> /etc/profile
# Pre-install common linters/formatters
golangci-lint --version # Already installed in base image, save us some bootup time
fi
fi
if [ -n "${CODEX_ENV_SWIFT_VERSION}" ]; then
current=$(swift --version | awk -F'version ' '{print $2}' | awk '{print $1}') # ==> 6.1
echo "# Swift: ${CODEX_ENV_SWIFT_VERSION} (default: ${current})"
if [ "${current}" != "${CODEX_ENV_SWIFT_VERSION}" ]; then
swiftly install --use "${CODEX_ENV_SWIFT_VERSION}"
fi
fi