Skip to content

Commit c39458a

Browse files
Better project and target structure; bump version: 0.1.6
1 parent 1ae72df commit c39458a

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

bin/ppmc

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,38 @@ while [ -L "$SOURCE" ]; do
4141
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE
4242
done
4343

44-
# Get the script directory and the package root (2 levels up)
44+
# Get the script directory
4545
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
46-
PACKAGE_ROOT=$( cd -P "$SCRIPT_DIR/../.." >/dev/null 2>&1 && pwd )
47-
4846
echo "Script directory: $SCRIPT_DIR"
49-
echo "Package root directory: $PACKAGE_ROOT"
5047

51-
# Set up Python environment
52-
# If running from installed package:
48+
# Check if the package is installed
5349
if python -c "import platform_problem_monitoring_core" &>/dev/null; then
5450
echo "Running from installed package"
5551
PYTHON_CMD="python"
5652
else
57-
# If running from source, create and use virtual environment
58-
echo "Running from source, setting up virtual environment"
59-
cd "$PACKAGE_ROOT"
53+
# If running from source, detect package root and create/use virtual environment
54+
# When running from source, the script should be in bin/ which is at the root of the project
55+
PACKAGE_ROOT=$( cd -P "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd )
6056

61-
if [ ! -d "venv" ]; then
62-
echo "Creating virtual environment"
63-
python3 -m venv venv
64-
fi
57+
# Verify this looks like our project directory
58+
if [ -f "$PACKAGE_ROOT/pyproject.toml" ]; then
59+
echo "Running from source, package root directory: $PACKAGE_ROOT"
60+
echo "Setting up virtual environment"
61+
cd "$PACKAGE_ROOT"
62+
63+
if [ ! -d "venv" ]; then
64+
echo "Creating virtual environment"
65+
python3 -m venv venv
66+
fi
6567

66-
source venv/bin/activate
67-
pip install --upgrade pip
68-
pip install -e . -q
68+
source venv/bin/activate
69+
pip install --upgrade pip
70+
pip install -e . -q
71+
else
72+
echo "Error: Cannot determine package root directory"
73+
echo "Neither running from installed package nor from recognizable source directory"
74+
exit 1
75+
fi
6976
PYTHON_CMD="python"
7077
fi
7178

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "platform_problem_monitoring_core"
7-
version = "0.1.5"
7+
version = "0.1.6"
88
description = "A tool for monitoring platform problems using Elasticsearch logs"
99
authors = [
1010
{name = "Platform Team"}

0 commit comments

Comments
 (0)