Skip to content

Commit 39dd3c8

Browse files
committed
fix: python environment, working around fastcrc and msgspec on mingw
1 parent 88c6b08 commit 39dd3c8

2 files changed

Lines changed: 41 additions & 5 deletions

File tree

tools/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ yowasp-yosys
44
yowasp-nextpnr-ice40
55
yowasp-nextpnr-ecp5
66
yowasp-nextpnr-himbaechel-gowin
7-
yowasp-nextpnr-himbaechel-gatemate
7+
# yowasp-nextpnr-himbaechel-gatemate # TODO: enable when available

tools/setup-python-env.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,48 @@ set -euo pipefail
99
VENV_DIR="$HOME/.local/share/silice/.venv"
1010
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
1111
REQ_FILE="$SCRIPT_DIR/requirements.txt"
12-
# Create environment director
12+
13+
# Detect MinGW
14+
IS_MINGW=false
15+
case "${MSYSTEM:-}" in
16+
MINGW32|MINGW64|MSYS|CLANG32|CLANG64|CLANGARM64|UCRT64)
17+
IS_MINGW=true
18+
;;
19+
esac
20+
if [ "$IS_MINGW" = false ]; then
21+
case "$(uname -s 2>/dev/null)" in
22+
MINGW*|MSYS*|CYGWIN*)
23+
IS_MINGW=true
24+
;;
25+
esac
26+
fi
27+
28+
# Create environment directory
1329
mkdir -p "$(dirname "$VENV_DIR")"
30+
1431
# Create the python environment
1532
if [ ! -d "$VENV_DIR" ]; then
16-
echo "Creating venv at $VENV_DIR"
33+
echo "Creating and setting up venv at $VENV_DIR, this can take a few minutes"
1734
python3 -m venv "$VENV_DIR"
1835
fi
19-
# Install
20-
"$VENV_DIR/bin/pip" install --quiet -r "$REQ_FILE"
36+
37+
PIP="$VENV_DIR/bin/pip"
38+
39+
if [ "$IS_MINGW" = true ]; then
40+
echo "MinGW environment detected — using apycula install workaround to avoid fastcrc and msgspec"
41+
42+
TMP_REQ="$(mktemp /tmp/silice-req-XXXXXX.txt)"
43+
grep -v -iE '^(apycula|yowasp-nextpnr-himbaechel-gowin)' "$REQ_FILE" > "$TMP_REQ" || true
44+
"$PIP" install --quiet -r "$TMP_REQ"
45+
rm -f "$TMP_REQ"
46+
47+
# Pure-Python replacements for the C extensions apycula would normally pull
48+
"$PIP" install --quiet numpy msgpack cattrs
49+
# Install the two packages without dependency resolution so pip never
50+
# attempts to build fastcrc or msgspec from source
51+
"$PIP" install --quiet --no-deps apycula
52+
"$PIP" install --quiet --no-deps yowasp-nextpnr-himbaechel-gowin
53+
else
54+
# Normal install
55+
"$PIP" install --quiet -r "$REQ_FILE"
56+
fi

0 commit comments

Comments
 (0)