Merge pull request #102 from OrfeoTerkuci/feature/introduce-uv-for-project-management

Setup UV for project management
This commit is contained in:
Shadowbroker
2026-03-24 17:56:58 -06:00
committed by GitHub
12 changed files with 1827 additions and 50 deletions
+13 -8
View File
@@ -26,14 +26,19 @@ jobs:
backend:
name: Backend Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.11"
- run: pip install -r requirements.txt
- run: python -c "from services.fetchers.retry import with_retry; from services.env_check import validate_env; print('Module imports OK')"
- run: python -m pytest tests/ -v --tb=short || echo "No pytest tests found (OK)"
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"
- name: Install dependencies
run: uv sync --group test
- run: uv run --directory backend python -c "from services.fetchers.retry import with_retry; from services.env_check import validate_env; print('Module imports OK')"
- name: Run tests
run: uv run --directory backend pytest tests -v --tb=short
+1 -1
View File
@@ -171,7 +171,7 @@ jobs:
id: build
uses: docker/build-push-action@v5.0.0
with:
context: ./backend
context: .
platforms: ${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
+1
View File
@@ -0,0 +1 @@
3.10
+18 -8
View File
@@ -9,19 +9,29 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt \
&& playwright install --with-deps chromium
# Install UV for Python dependency management
ADD https://astral.sh/uv/install.sh /uv-installer.sh
RUN sh /uv-installer.sh && rm /uv-installer.sh
ENV PATH="/root/.local/bin/:$PATH"
# Set environment variable for UV to install dependencies in the system Python environment
# By default UV creates a new venv and installs dependencies there
ENV UV_PROJECT_ENVIRONMENT=/usr/local
# Copy pyproject.toml from root for dependency management
COPY pyproject.toml .
# Copy lock file for reproducible builds
COPY uv.lock .
# Copy source code
COPY backend/ .
# Install Python dependencies using UV (this will use the lock file for reproducibility)
RUN uv sync --frozen
RUN uv run playwright install --with-deps chromium
# Install Node.js dependencies (ws module for AIS WebSocket proxy)
# Copy manifests first so this layer is cached unless deps change
COPY package*.json ./
COPY backend/package*.json ./
RUN npm ci --omit=dev
# Copy source code
COPY . .
# Create a non-root user for security
# Grant write access to /app so the auto-updater can extract files
RUN adduser --system --uid 1001 backenduser \
+27
View File
@@ -0,0 +1,27 @@
[project]
name = "backend"
version = "0.9.5"
requires-python = ">=3.10"
dependencies = [
"apscheduler==3.10.3",
"cachetools==5.5.2",
"cloudscraper==1.2.71",
"fastapi==0.115.12",
"feedparser==6.0.10",
"httpx==0.28.1",
"playwright==1.50.0",
"playwright-stealth==1.0.6",
"pydantic==2.11.1",
"pydantic-settings==2.8.1",
"pystac-client==0.8.6",
"python-dotenv==1.0.1",
"requests==2.31.0",
"reverse-geocoder==1.5.1",
"sgp4==2.23",
"slowapi==0.1.9",
"uvicorn==0.34.0",
"yfinance==0.2.54",
]
[dependency-groups]
test = ["pytest>=8.3.4", "pytest-asyncio==0.25.0"]
-3
View File
@@ -1,3 +0,0 @@
-r requirements.txt
pytest==8.3.4
httpx==0.28.1
-25
View File
@@ -1,25 +0,0 @@
fastapi==0.115.12
uvicorn==0.34.0
yfinance==0.2.54
feedparser==6.0.10
legacy-cgi==2.6.2
requests==2.31.0
apscheduler==3.10.3
pydantic==2.11.1
pydantic-settings==2.8.1
playwright==1.50.0
playwright-stealth==1.0.6
beautifulsoup4==4.13.3
cachetools==5.5.2
slowapi==0.1.9
cloudscraper==1.2.71
python-dotenv==1.0.1
lxml==5.3.1
reverse_geocoder==1.5.1
sgp4==2.23
geopy==2.4.1
pytz==2024.2
pystac-client==0.8.6
pytest==8.3.4
pytest-asyncio==0.25.0
httpx==0.28.1
+2 -1
View File
@@ -1,7 +1,8 @@
services:
backend:
build:
context: ./backend
context: .
dockerfile: ./backend/Dockerfile
container_name: shadowbroker-backend
ports:
- "8000:8000"
+12
View File
@@ -0,0 +1,12 @@
[project]
name = "shadowbroker"
version = "0.9.5"
readme = "README.md"
requires-python = ">=3.10"
dependencies = []
[dependency-groups]
test = []
[tool.uv.workspace]
members = ["backend"]
+2 -2
View File
@@ -45,7 +45,7 @@ echo [*] Setting up backend...
cd backend
if not exist "venv\" (
echo [*] Creating Python virtual environment...
python -m venv venv
uv venv
if %errorlevel% neq 0 (
echo [!] ERROR: Failed to create virtual environment.
pause
@@ -54,7 +54,7 @@ if not exist "venv\" (
)
call venv\Scripts\activate.bat
echo [*] Installing Python dependencies (this may take a minute)...
pip install -q -r requirements.txt
uv sync --frozen
if %errorlevel% neq 0 (
echo.
echo [!] ERROR: pip install failed. See errors above.
+13 -2
View File
@@ -36,6 +36,17 @@ if [ "$PY_MINOR" -ge 13 ] 2>/dev/null; then
echo ""
fi
# Setup UV (Python package manager)
if ! command -v uv &> /dev/null; then
echo "[*] UV not found. Installing UV (Python package manager)..."
curl -LsSf https://astral.sh/uv/install.sh | sh
if [ $? -ne 0 ]; then
echo "[!] ERROR: Failed to install UV."
exit 1
fi
export PATH="$HOME/.local/bin:$PATH"
echo "[*] UV installed successfully."
# Get the directory where this script lives
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -44,7 +55,7 @@ echo "[*] Setting up backend..."
cd "$SCRIPT_DIR/backend"
if [ ! -d "venv" ]; then
echo "[*] Creating Python virtual environment..."
$PYTHON_CMD -m venv venv
uv venv
if [ $? -ne 0 ]; then
echo "[!] ERROR: Failed to create virtual environment."
exit 1
@@ -53,7 +64,7 @@ fi
source venv/bin/activate
echo "[*] Installing Python dependencies (this may take a minute)..."
pip install -q -r requirements.txt
uv sync --frozen
if [ $? -ne 0 ]; then
echo ""
echo "[!] ERROR: pip install failed. See errors above."
Generated
+1738
View File
File diff suppressed because it is too large Load Diff