build_package.sh 1.5 KB

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