diff --git a/scripts/unix/build.sh b/scripts/unix/build.sh new file mode 100644 index 0000000..3c3b8df --- /dev/null +++ b/scripts/unix/build.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Exit immediately if a command exits with a non-zero status +set -e + +# Run "maturin --help". If it fails, print an error message and exit. +if ! maturin --help > /dev/null 2>&1; then + echo "Failed to run maturin --help" >&2 + exit 1 +fi + +# Delete any existing build directory and create a new one. +rm -rf ./build +mkdir -p ./build + +# Copy ./src/msyrs.pyi to ./msyrs.pyi. +cp ./src/msyrs.pyi ./msyrs.pyi + +# Build using maturin. +maturin build --release --sdist --out ./build/ + +# Get the first wheel file found in the build directory. +whl_file=$(ls ./build/*.whl 2>/dev/null | head -n 1) +if [ -z "$whl_file" ]; then + echo "No wheel file found in ./build" >&2 + exit 1 +fi + +# Rename the wheel file from .whl to .zip. +base_name="${whl_file%.whl}" +mv "$whl_file" "${base_name}.zip" + +# Delete the temporary .pyi file. +rm ./msyrs.pyi diff --git a/scripts/unix/install.sh b/scripts/unix/install.sh new file mode 100644 index 0000000..0fe1ea3 --- /dev/null +++ b/scripts/unix/install.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +# Ensure maturin is installed. For example, you can install it via: +# pip install maturin + +# Run "maturin --help". If it fails, print an error message and exit. +if ! maturin --help > /dev/null 2>&1; then + echo "Failed to run maturin --help" >&2 + exit 1 +fi + +# Copy ./src/msyrs.pyi to the current directory as msyrs.pyi +cp ./src/msyrs.pyi ./msyrs.pyi + +# Run maturin develop in release mode. +maturin develop --release + +# Delete the temporary msyrs.pyi file. +rm ./msyrs.pyi