diff --git a/setup_build_server.sh b/setup_build_server.sh index 646b26c..c61a7d5 100755 --- a/setup_build_server.sh +++ b/setup_build_server.sh @@ -66,48 +66,35 @@ pip install --upgrade pip # ----------------------------- # nDPI installieren (system lib + python bindings) # ----------------------------- +NDPIDIR="/tmp/nDPI" + if ! ldconfig -p | grep -q "libndpi"; then echo "==> Build and install nDPI library" - NDPIDIR="/tmp/nDPI" rm -rf "$NDPIDIR" git clone --depth 1 https://github.com/ntop/nDPI.git "$NDPIDIR" cd "$NDPIDIR" ./autogen.sh - ./configure --prefix=/usr + ./configure make -j"$(nproc)" make install ldconfig else echo "==> nDPI library already installed" + # Keep python bindings source in sync with official instructions. + if [ ! -d "$NDPIDIR/python" ]; then + rm -rf "$NDPIDIR" + git clone --depth 1 https://github.com/ntop/nDPI.git "$NDPIDIR" + fi fi -patch_ndpi_python_metadata() { - local py_dir="$1" - local patched=0 - if [ -f "$py_dir/pyproject.toml" ] && grep -q "PACK_ON" "$py_dir/pyproject.toml"; then - sed -i 's/PACK_ON/"0.0.0"/g' "$py_dir/pyproject.toml" - patched=1 - fi - if [ -f "$py_dir/setup.cfg" ] && grep -q "PACK_ON" "$py_dir/setup.cfg"; then - sed -i 's/PACK_ON/0.0.0/g' "$py_dir/setup.cfg" - patched=1 - fi - if [ -f "$py_dir/setup.py" ] && grep -q "PACK_ON" "$py_dir/setup.py"; then - sed -i "s/PACK_ON/'0.0.0'/g" "$py_dir/setup.py" - patched=1 - fi - if [ "$patched" -eq 1 ]; then - echo "==> Applied PACK_ON metadata workaround for nDPI python bindings" - fi -} - -if [ -d "/tmp/nDPI/python" ]; then +if [ -d "$NDPIDIR/python" ]; then echo "==> Install nDPI Python bindings" - patch_ndpi_python_metadata "/tmp/nDPI/python" - # nDPI bindings currently fail with newer build backends on some hosts - # (e.g. metadata parsing errors such as "cannot parse PACK_ON"). - pip install "setuptools<81" "packaging<25" wheel - if ! pip install --no-build-isolation /tmp/nDPI/python; then + cd "$NDPIDIR/python" + python3 -m pip install --upgrade pip + if ! python3 -m pip install -r dev_requirements.txt; then + echo "==> WARNING: failed to install nDPI python dev_requirements" + fi + if ! python3 -m pip install .; then echo "==> WARNING: nDPI Python bindings install failed, backend will run without DPI enrichment" else if python - <<'PY' @@ -129,6 +116,7 @@ PY echo "==> WARNING: nDPI installed but import failed in backend venv" fi fi + cd "$BACKEND_DIR" fi cd "$BACKEND_DIR" @@ -270,10 +258,16 @@ npm run build # Backend Dependencies cd $BACKEND_DIR source venv/bin/activate +NDPIDIR="/tmp/nDPI" +if [ ! -d "$NDPIDIR/python" ]; then + rm -rf "$NDPIDIR" + git clone --branch dev --depth 1 https://github.com/ntop/nDPI.git "$NDPIDIR" +fi if [ -d "/tmp/nDPI/python" ]; then - patch_ndpi_python_metadata "/tmp/nDPI/python" - pip install "setuptools<81" "packaging<25" wheel - if ! pip install --no-build-isolation /tmp/nDPI/python; then + cd "$NDPIDIR/python" + python3 -m pip install --upgrade pip + python3 -m pip install -r dev_requirements.txt || true + if ! python3 -m pip install .; then echo "WARNING: nDPI Python bindings install failed during runner build" else python - <<'PY' || echo "WARNING: nDPI import check failed during runner build" @@ -288,6 +282,7 @@ for name in ("ndpi", "pyndpi"): raise SystemExit(1) PY fi + cd $BACKEND_DIR fi pip install -r requirements.txt deactivate