From 17dfb245bf7ee5fad8491d56c36be8a79cc277ac Mon Sep 17 00:00:00 2001 From: edraft Date: Fri, 19 Sep 2025 21:54:08 +0200 Subject: [PATCH] Minor cleanup --- install.sh | 61 +++++++++++++++++++++++++++++ src/cpl-api/requirements.txt | 3 +- src/cpl-auth/requirements.txt | 2 +- src/cpl-core/requirements.txt | 1 - tests/custom/api/src/main.py | 2 +- tests/custom/api/src/routes/ping.py | 2 +- 6 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 00000000..c6d501fa --- /dev/null +++ b/install.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Find and combine requirements from src/cpl-*/requirements.txt, +# filtering out lines whose *package name* starts with "cpl-". +# Works with pinned versions, extras, markers, editable installs, and VCS refs. + +shopt -s nullglob + +req_files=(src/cpl-*/requirements.txt) +if ((${#req_files[@]} == 0)); then + echo "No requirements files found at src/cpl-*/requirements.txt" >&2 + exit 1 +fi + +tmp_combined="$(mktemp)" +trap 'rm -f "$tmp_combined"' EXIT + +# Concatenate, trim comments/whitespace, filter out cpl-* packages, dedupe. +# We keep non-package options/flags/constraints as-is. +awk ' + function trim(s){ sub(/^[[:space:]]+/,"",s); sub(/[[:space:]]+$/,"",s); return s } + + { + line=$0 + # drop full-line comments and strip inline comments + if (line ~ /^[[:space:]]*#/) next + sub(/#[^!].*$/,"",line) # strip trailing comment (simple heuristic) + line=trim(line) + if (line == "") next + + # Determine the package *name* even for "-e", extras, pins, markers, or VCS "@" + e = line + sub(/^-e[[:space:]]+/,"",e) # remove editable prefix + # Tokenize up to the first of these separators: space, [ < > = ! ~ ; @ + token = e + sub(/\[.*/,"",token) # remove extras quickly + n = split(token, a, /[<>=!~;@[:space:]]/) + name = tolower(a[1]) + + # If the first token (name) starts with "cpl-", skip this requirement + if (name ~ /^cpl-/) next + + print line + } +' "${req_files[@]}" | sort -u > "$tmp_combined" + +if ! [ -s "$tmp_combined" ]; then + echo "Nothing to install after filtering out cpl-* packages." >&2 + exit 0 +fi + +echo "Installing dependencies (excluding cpl-*) from:" +printf ' - %s\n' "${req_files[@]}" +echo +echo "Final set to install:" +cat "$tmp_combined" +echo + +# Use python -m pip for reliability; change to python3 if needed. +python -m pip install -r "$tmp_combined" diff --git a/src/cpl-api/requirements.txt b/src/cpl-api/requirements.txt index 51fbdaf0..e8af3127 100644 --- a/src/cpl-api/requirements.txt +++ b/src/cpl-api/requirements.txt @@ -3,4 +3,5 @@ cpl-application cpl-core cpl-dependency starlette==0.48.0 -python-multipart==0.0.20 \ No newline at end of file +python-multipart==0.0.20 +uvicorn==0.35.0 \ No newline at end of file diff --git a/src/cpl-auth/requirements.txt b/src/cpl-auth/requirements.txt index 9ea16469..71694ffd 100644 --- a/src/cpl-auth/requirements.txt +++ b/src/cpl-auth/requirements.txt @@ -1,4 +1,4 @@ cpl-core cpl-dependency cpl-database -python-keycloak-5.8.1 \ No newline at end of file +python-keycloak==5.8.1 \ No newline at end of file diff --git a/src/cpl-core/requirements.txt b/src/cpl-core/requirements.txt index 186be5c3..8b07c2b2 100644 --- a/src/cpl-core/requirements.txt +++ b/src/cpl-core/requirements.txt @@ -2,5 +2,4 @@ art==6.5 colorama==0.4.6 tabulate==0.9.0 termcolor==3.1.0 -mysql-connector-python==9.4.0 pynput==1.8.1 diff --git a/tests/custom/api/src/main.py b/tests/custom/api/src/main.py index d6b3bed1..54cb83c9 100644 --- a/tests/custom/api/src/main.py +++ b/tests/custom/api/src/main.py @@ -2,7 +2,7 @@ from starlette.responses import JSONResponse from cpl.api.web_app import WebApp from cpl.application import ApplicationBuilder -from custom.api.src.service import PingService +from service import PingService def main(): diff --git a/tests/custom/api/src/routes/ping.py b/tests/custom/api/src/routes/ping.py index ae47565e..68a79d1a 100644 --- a/tests/custom/api/src/routes/ping.py +++ b/tests/custom/api/src/routes/ping.py @@ -4,7 +4,7 @@ from starlette.responses import JSONResponse from cpl.api.router import Router from cpl.core.log import Logger -from custom.api.src.service import PingService +from service import PingService @Router.get(f"/ping")