|
| 1 | +#!/bin/bash |
| 2 | +# Exit on any error |
| 3 | +set -e |
| 4 | + |
| 5 | +# Find the venv directory |
| 6 | +if [ -d ".venv" ]; then |
| 7 | + VENV_DIR=".venv" |
| 8 | +elif [ -d "../.venv" ]; then |
| 9 | + VENV_DIR="../.venv" |
| 10 | +else |
| 11 | + echo "The virtual environment does not exist. Please run 'python -m venv .venv' to create it." >&2 |
| 12 | + exit 1 |
| 13 | +fi |
| 14 | + |
| 15 | +# Activate the virtual environment |
| 16 | +source $VENV_DIR/bin/activate |
| 17 | + |
| 18 | +# Install pybind11-stubgen |
| 19 | +if ! pip show pybind11-stubgen > /dev/null; then |
| 20 | + pip install pybind11-stubgen |
| 21 | +fi |
| 22 | + |
| 23 | +# Check if the virtual environment has the openfhe package installed |
| 24 | +if ! pip show openfhe > /dev/null; then |
| 25 | + echo "The openfhe package is not installed in the virtual environment. Please run 'pip install -e .' to install it." >&2 |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | + |
| 29 | +# Generate stub files using pybind11-stubgen |
| 30 | +echo "Generating stub files..." |
| 31 | +pybind11-stubgen openfhe |
| 32 | + |
| 33 | +# Check if stub generation was successful |
| 34 | +if [ $? -eq 0 ]; then |
| 35 | + echo "Stub files generated successfully." |
| 36 | +else |
| 37 | + echo "Stub generation failed." >&2 |
| 38 | + exit 1 |
| 39 | +fi |
| 40 | + |
| 41 | +# Move the generated stub files to the openfhe package directory |
| 42 | +echo "Moving the generated stub files to the openfhe package directory..." |
| 43 | +mv stubs/openfhe/* openfhe/ |
| 44 | +rm -r -d stubs |
| 45 | + |
| 46 | +# Build the source distribution and wheel distribution |
| 47 | +echo "Building the sdist and bdist_wheel..." |
| 48 | +python setup.py sdist bdist_wheel |
| 49 | + |
| 50 | +# Indicate where the distributions were saved |
| 51 | +echo "The distributions have been built and are located in the 'dist' directory. You can install the package using 'pip install dist/<distribution_file>'." |
0 commit comments