Skip to content

Commit adae7c1

Browse files
author
zach
authored
chore: add prepare script (#6)
1 parent 48e0b84 commit adae7c1

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
template-suffix: ejs
22
dependencies:
33
- extism-py
4+
- uv
45

56
available-feature-flags:
67
- name: stub-with-code-samples

template/prepare.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Function to check if a command exists
4+
command_exists () {
5+
command -v "$1" >/dev/null 2>&1
6+
}
7+
8+
missing_deps=0
9+
10+
# Check for uv
11+
if ! (command_exists uv); then
12+
missing_deps=1
13+
echo "❌ uv is not installed."
14+
echo ""
15+
echo "To install uv, visit the official download page:"
16+
echo "👉 https://docs.astral.sh/uv/getting-started/installation/"
17+
echo ""
18+
fi
19+
20+
# Exit with a bad exit code if any dependencies are missing
21+
if [ "$missing_deps" -ne 0 ]; then
22+
echo "Install the missing dependencies and ensure they are on your path. Then run this command again."
23+
# TODO: remove sleep when cli bug is fixed
24+
sleep 2
25+
exit 1
26+
fi
27+
28+
# Check for extism-js
29+
if ! command_exists extism-py; then
30+
echo "❌ extism-py is not installed."
31+
echo ""
32+
echo "extism-py is needed to compile the plug-in. You can find the instructions to install it here: https://github.com/extism/python-pdk"
33+
echo ""
34+
echo "Alternatively, you can use an install script."
35+
echo ""
36+
echo "🔹 Mac / Linux:"
37+
echo "curl -L https://raw.githubusercontent.com/extism/python-pdk/main/install.sh | bash"
38+
echo ""
39+
# TODO: remove sleep when cli bug is fixed
40+
sleep 2
41+
exit 1
42+
fi
43+
44+

template/xtp.toml.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ build = "PYTHONPATH=./plugin extism-py -o plugin.wasm plugin/__init__.py"
1414
format = "uv run ruff format plugin/*.py"
1515

1616
# xtp plugin init runs this script before running the format script
17-
prepare = "uv sync"
17+
prepare = "bash prepare.sh && uv sync"

0 commit comments

Comments
 (0)