Skip to content

Commit 96fabfa

Browse files
feat: Add Python virtual environment setup and requirements installation to process_custom_data.sh
1 parent 2fedc88 commit 96fabfa

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

infra/scripts/process_custom_data.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,42 @@ if [ $? -ne 0 ]; then
507507
exit 1
508508
fi
509509

510+
# Determine the correct Python command
511+
if command -v python3 &> /dev/null; then
512+
PYTHON_CMD="python3"
513+
elif command -v python &> /dev/null; then
514+
PYTHON_CMD="python"
515+
else
516+
echo "Python is not installed on this system. Or it is not added in the PATH."
517+
exit 1
518+
fi
519+
520+
pythonScriptPath="infra/scripts/index_scripts/"
521+
# create virtual environment
522+
# Check if the virtual environment already exists
523+
if [ -d $pythonScriptPath"scriptenv" ]; then
524+
echo "Virtual environment already exists. Skipping creation."
525+
else
526+
echo "Creating virtual environment"
527+
$PYTHON_CMD -m venv $pythonScriptPath"scriptenv"
528+
fi
529+
530+
# Activate the virtual environment
531+
if [ -f $pythonScriptPath"scriptenv/bin/activate" ]; then
532+
echo "Activating virtual environment (Linux/macOS)"
533+
source $pythonScriptPath"scriptenv/bin/activate"
534+
elif [ -f $pythonScriptPath"scriptenv/Scripts/activate" ]; then
535+
echo "Activating virtual environment (Windows)"
536+
source $pythonScriptPath"scriptenv/Scripts/activate"
537+
else
538+
echo "Error activating virtual environment. Requirements may be installed globally."
539+
fi
540+
541+
# Install the requirements
542+
echo "Installing requirements"
543+
pip install --quiet -r ${pythonScriptPath}requirements.txt
544+
echo "Requirements installed"
545+
510546
# Create Content Understanding analyzers
511547
echo "Creating Content Understanding analyzer templates..."
512548
echo "Running 02_create_cu_template_text.py"

0 commit comments

Comments
 (0)