diff --git a/build-python b/build-python index 4ec8e4d..7eb9703 100755 --- a/build-python +++ b/build-python @@ -1,6 +1,6 @@ #!/bin/bash set -eu -./update-translations +#./update-translations .venv/bin/python3 -m build (cd services/open-webui; .venv/bin/python3 -m build) diff --git a/package-common b/package-common new file mode 100644 index 0000000..36fe6af --- /dev/null +++ b/package-common @@ -0,0 +1,133 @@ +#!/bin/bash +set -eu + +BUNDLE_NAME=learn2rag-$(echo $CARGO_BUILD_TARGET |cut -d '-' -f 3) + +./build-python +VERSION=$(uv version --short) + +# https://github.com/cross-rs/cross/wiki/FAQ#glibc-version-error +CARGO_TARGET_DIR=target/build/"${CARGO_BUILD_TARGET}" + +BUNDLE_DIR=~/.cache/learn2rag-dist +BUNDLE=$BUNDLE_DIR/$BUNDLE_NAME +rm -rf $BUNDLE +rm -f $BUNDLE.zip + +mkdir -p $BUNDLE +mkdir -p $BUNDLE/services + +export PYAPP_DISTRIBUTION_EMBED=true +export PYAPP_FULL_ISOLATION=false +export PYAPP_EXPOSE_ALL_COMMANDS=true + +echo "Clearing Cargo cache..." +(cd pyapp && cross clean) + +# Bake the relative offline path directly into the binaries +OFFLINE_ARGS="--no-index --find-links=./services/wheels" + +cp dist/learn2rag-$VERSION-py3-none-any.whl pyapp +(cd pyapp; \ + PYAPP_PYTHON_VERSION=3.13 \ + PYAPP_PROJECT_NAME=learn2rag \ + PYAPP_PROJECT_PATH=learn2rag-$VERSION-py3-none-any.whl \ + PYAPP_PIP_EXTRA_ARGS="$OFFLINE_ARGS" \ + PYAPP_DISTRIBUTION_EMBED=true \ + PYAPP_FULL_ISOLATION=false \ + PYAPP_EXPOSE_ALL_COMMANDS=true \ + cross build --release --target $CARGO_BUILD_TARGET) +cp pyapp/target/$CARGO_BUILD_TARGET/release/pyapp$BIN_SUFFIX $BUNDLE/configurator$BIN_SUFFIX + +cp services/open-webui/dist/open_webui-0.8.12-py3-none-any.whl pyapp +touch pyapp/Cargo.toml +touch pyapp/src/main.rs 2>/dev/null || true +(cd pyapp; \ + PYAPP_PYTHON_VERSION=3.11 \ + PYAPP_PROJECT_NAME=open-webui \ + PYAPP_PROJECT_PATH=open_webui-0.8.12-py3-none-any.whl \ + PYAPP_EXEC_SPEC=open_webui:app \ + PYAPP_PIP_EXTRA_ARGS="$OFFLINE_ARGS" \ + cross build --release --target $CARGO_BUILD_TARGET) +cp pyapp/target/$CARGO_BUILD_TARGET/release/pyapp$BIN_SUFFIX $BUNDLE/services/start-open-webui$BIN_SUFFIX + +while read -u 100 file; do + mkdir -p $BUNDLE/$(dirname $file) + cp -r $file $BUNDLE/$file +done 100 $BUNDLE_DIR/req-webui.in + echo "dist/learn2rag-$VERSION-py3-none-any.whl" > $BUNDLE_DIR/req-learn2rag.in + uv pip compile $BUNDLE_DIR/req-webui.in \ + --python-version 3.11 \ + --python-platform windows \ + -o $BUNDLE_DIR/win-webui-reqs.txt + + uv pip compile $BUNDLE_DIR/req-learn2rag.in \ + --python-version 3.13.5 \ + --python-platform windows \ + -o $BUNDLE_DIR/win-l2r-reqs.txt + + echo "Downloading locked dependencies for Windows target..." + + # 2. Download the exact packages from the lockfiles + # (--no-deps stops pip from re-evaluating the tree and crashing) + $BUNDLE_DIR/venv311/bin/python -m pip download \ + --platform win_amd64 --python-version 3.11 --implementation cp --abi cp311 \ + --no-deps --find-links $WHEELS_DIR \ + -r $BUNDLE_DIR/win-webui-reqs.txt -d $WHEELS_DIR + + $BUNDLE_DIR/venv313/bin/python -m pip download \ + --platform win_amd64 --python-version 3.13.5 --implementation cp --abi cp313 \ + --no-deps --find-links $WHEELS_DIR \ + -r $BUNDLE_DIR/win-l2r-reqs.txt -d $WHEELS_DIR + + $BUNDLE_DIR/venv311/bin/python -m pip download \ + --platform win_amd64 --python-version 3.11 --implementation cp --abi cp311 \ + --no-deps wheel setuptools -d $WHEELS_DIR +else + echo "Downloading dependencies for Native Linux target..." + + $BUNDLE_DIR/venv311/bin/python -m pip download wheel setuptools -d $WHEELS_DIR + + $BUNDLE_DIR/venv313/bin/python -m pip download \ + --find-links $WHEELS_DIR \ + dist/learn2rag-$VERSION-py3-none-any.whl -d $WHEELS_DIR + + $BUNDLE_DIR/venv311/bin/python -m pip download \ + --find-links $WHEELS_DIR \ + services/open-webui/dist/open_webui-0.8.12-py3-none-any.whl -d $WHEELS_DIR +fi + +rm -rf $BUNDLE_DIR/venv313 $BUNDLE_DIR/venv311 \ No newline at end of file diff --git a/package-linux b/package-linux index 68a8d52..c11c21e 100755 --- a/package-linux +++ b/package-linux @@ -1,41 +1,16 @@ #!/bin/bash set -eu -./build-python - -VERSION=$(uv version --short) - # 64-bit Linux (kernel 3.2+, glibc 2.17+) # https://doc.rust-lang.org/rustc/platform-support.html#tier-1-with-host-tools # https://github.com/cross-rs/cross#supported-targets # See also: pyapp/Cross.toml CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu -# https://github.com/cross-rs/cross/wiki/FAQ#glibc-version-error -CARGO_TARGET_DIR=target/build/"${CARGO_BUILD_TARGET}" - -BUNDLE_DIR=~/.cache/learn2rag-dist -BUNDLE_NAME=learn2rag-linux -BUNDLE=$BUNDLE_DIR/$BUNDLE_NAME - -mkdir -p $BUNDLE -mkdir -p $BUNDLE/services - -PYAPP_DISTRIBUTION_EMBED=true -PYAPP_FULL_ISOLATION=true -PYAPP_EXPOSE_ALL_COMMANDS=true - -cp dist/learn2rag-$VERSION.tar.gz pyapp -(cd pyapp; PYAPP_PYTHON_VERSION=3.13 PYAPP_PROJECT_NAME=learn2rag PYAPP_PROJECT_PATH=learn2rag-$VERSION.tar.gz cross build --release --target $CARGO_BUILD_TARGET) -cp pyapp/target/$CARGO_BUILD_TARGET/release/pyapp $BUNDLE/configurator - -cp services/open-webui/dist/open_webui-0.8.12.tar.gz pyapp -(cd pyapp; PYAPP_PYTHON_VERSION=3.11 PYAPP_PROJECT_NAME=open-webui PYAPP_PROJECT_PATH=open_webui-0.8.12.tar.gz PYAPP_EXEC_SPEC=open_webui:app cross build --release --target $CARGO_BUILD_TARGET) -cp pyapp/target/$CARGO_BUILD_TARGET/release/pyapp $BUNDLE/services/start-open-webui +BIN_SUFFIX="" -while read -u 100 file; do - mkdir -p $BUNDLE/$(dirname $file) - cp -r $file $BUNDLE/$file -done 100