You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
2.8 KiB
120 lines
2.8 KiB
#!/bin/bash |
|
# Build script for installing StormLib and PyStorm |
|
|
|
set -e |
|
|
|
echo "==================================" |
|
echo " PyStorm Installation Script" |
|
echo "==================================" |
|
echo "" |
|
|
|
# Detect OS |
|
OS="$(uname -s)" |
|
case "${OS}" in |
|
Linux*) MACHINE=Linux;; |
|
Darwin*) MACHINE=Mac;; |
|
CYGWIN*|MINGW*|MSYS*) MACHINE=Windows;; |
|
*) MACHINE="UNKNOWN:${OS}" |
|
esac |
|
|
|
echo "Detected OS: ${MACHINE}" |
|
echo "" |
|
|
|
# Check if StormLib is already installed |
|
echo "Checking for existing StormLib installation..." |
|
if ldconfig -p 2>/dev/null | grep -q libstorm || [ -f "/usr/local/lib/libstorm.so" ]; then |
|
echo "✓ StormLib appears to be installed" |
|
INSTALL_STORMLIB=false |
|
else |
|
echo "✗ StormLib not found" |
|
read -p "Do you want to build and install StormLib? (y/n) " -n 1 -r |
|
echo |
|
if [[ $REPLY =~ ^[Yy]$ ]]; then |
|
INSTALL_STORMLIB=true |
|
else |
|
INSTALL_STORMLIB=false |
|
echo "Warning: PyStorm requires StormLib to function properly" |
|
fi |
|
fi |
|
|
|
# Install StormLib if requested |
|
if [ "$INSTALL_STORMLIB" = true ]; then |
|
echo "" |
|
echo "=== Building and Installing StormLib ===" |
|
echo "" |
|
|
|
# Check for required tools |
|
if ! command -v git &> /dev/null; then |
|
echo "Error: git is required but not installed" |
|
exit 1 |
|
fi |
|
|
|
if ! command -v cmake &> /dev/null; then |
|
echo "Error: cmake is required but not installed" |
|
exit 1 |
|
fi |
|
|
|
# Clone StormLib |
|
TEMP_DIR=$(mktemp -d) |
|
cd "$TEMP_DIR" |
|
|
|
echo "Cloning StormLib repository..." |
|
git clone https://github.com/ladislav-zezula/StormLib.git |
|
cd StormLib |
|
|
|
# Build |
|
echo "Building StormLib..." |
|
mkdir build |
|
cd build |
|
cmake .. |
|
make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2) |
|
|
|
# Install |
|
echo "Installing StormLib (may require sudo)..." |
|
sudo make install |
|
|
|
# Update library cache (Linux only) |
|
if [ "$MACHINE" = "Linux" ]; then |
|
sudo ldconfig |
|
fi |
|
|
|
# Clean up |
|
cd / |
|
rm -rf "$TEMP_DIR" |
|
|
|
echo "✓ StormLib installed successfully" |
|
fi |
|
|
|
# Install PyStorm |
|
echo "" |
|
echo "=== Installing PyStorm ===" |
|
echo "" |
|
|
|
# Check for Python 3 |
|
if ! command -v python3 &> /dev/null; then |
|
echo "Error: Python 3 is required but not installed" |
|
exit 1 |
|
fi |
|
|
|
# Activate virtual environment if it exists |
|
if [ -d "venv" ]; then |
|
echo "Activating virtual environment..." |
|
source venv/bin/activate |
|
fi |
|
|
|
# Install PyStorm in development mode |
|
echo "Installing PyStorm..." |
|
python3 -m pip install -e . |
|
|
|
echo "" |
|
echo "==================================" |
|
echo " Installation Complete!" |
|
echo "==================================" |
|
echo "" |
|
echo "You can now use PyStorm:" |
|
echo " python3 -c 'import pystorm; print(pystorm.__version__)'" |
|
echo "" |
|
echo "Try the examples:" |
|
echo " cd examples" |
|
echo " python3 basic_operations.py" |
|
echo ""
|
|
|