fix: Use venv Python for scripts, fix import order in figma-sync
Some checks failed
DSS Project Analysis / dss-context-update (push) Has been cancelled

- Move sys.path modification before dss imports in figma-sync.py
- Add missing Dict type hint import
- Add PYTHON variable to dss-init.sh using venv if available
- Update script calls to use $PYTHON instead of python3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-12 06:27:18 -03:00
parent db5be5ce37
commit 481c3d39ff
2 changed files with 16 additions and 8 deletions

View File

@@ -17,6 +17,13 @@ set -e
DSS_ROOT="$(cd "$(dirname "$0")/.." && pwd)" DSS_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$DSS_ROOT" cd "$DSS_ROOT"
# Use venv Python if available
if [ -f "$DSS_ROOT/.venv/bin/python3" ]; then
PYTHON="$DSS_ROOT/.venv/bin/python3"
else
PYTHON="python3"
fi
# Parse arguments # Parse arguments
RESET=false RESET=false
SKIP_ANALYSIS=false SKIP_ANALYSIS=false
@@ -392,7 +399,7 @@ fi
# Run validation if available # Run validation if available
if [ -f "scripts/validate-theme.py" ] && [ -f ".dss/schema/skin-contract.json" ]; then if [ -f "scripts/validate-theme.py" ] && [ -f ".dss/schema/skin-contract.json" ]; then
log_info "Running theme/skin validation..." log_info "Running theme/skin validation..."
if python3 scripts/validate-theme.py --validate-skin --quiet 2>&1 | while read line; do if $PYTHON scripts/validate-theme.py --validate-skin --quiet 2>&1 | while read line; do
echo " $line" echo " $line"
done; then done; then
log_ok "All validations passed" log_ok "All validations passed"
@@ -421,7 +428,7 @@ if [ "$FIGMA_AVAILABLE" = true ] && [ "$TOKEN_STATUS" = "empty" ]; then
log_info "File: $FIGMA_FILE_KEY" log_info "File: $FIGMA_FILE_KEY"
# Run Figma sync script # Run Figma sync script
if python3 "$DSS_ROOT/scripts/figma-sync.py" --file-key "$FIGMA_FILE_KEY" 2>&1 | while read line; do if $PYTHON "$DSS_ROOT/scripts/figma-sync.py" --file-key "$FIGMA_FILE_KEY" 2>&1 | while read line; do
echo " $line" echo " $line"
done; then done; then
log_ok "Figma sync complete" log_ok "Figma sync complete"
@@ -450,7 +457,7 @@ HAS_SKINS=$([ -d ".dss/skins/shadcn" ] && echo "yes" || echo "no")
if [ "$HAS_PRIMITIVES" = "yes" ] && [ "$HAS_SKINS" = "yes" ]; then if [ "$HAS_PRIMITIVES" = "yes" ] && [ "$HAS_SKINS" = "yes" ]; then
log_info "Resolving: Core → Skin → Theme" log_info "Resolving: Core → Skin → Theme"
if python3 scripts/resolve-tokens.py 2>&1 | while read line; do if $PYTHON scripts/resolve-tokens.py 2>&1 | while read line; do
echo " $line" echo " $line"
done; then done; then
log_ok "Token cascade resolved" log_ok "Token cascade resolved"
@@ -523,7 +530,7 @@ log_step "11. Generating Storybook stories..."
if [ "$HAS_TOKENS" = "yes" ] && [ -f "scripts/generate-storybook.py" ]; then if [ "$HAS_TOKENS" = "yes" ] && [ -f "scripts/generate-storybook.py" ]; then
log_info "Building stories from tokens..." log_info "Building stories from tokens..."
if python3 scripts/generate-storybook.py 2>&1 | while read line; do if $PYTHON scripts/generate-storybook.py 2>&1 | while read line; do
echo " $line" echo " $line"
done; then done; then
STORY_COUNT=$(find admin-ui/src/stories -name "*.stories.js" 2>/dev/null | wc -l) STORY_COUNT=$(find admin-ui/src/stories -name "*.stories.js" 2>/dev/null | wc -l)

View File

@@ -16,15 +16,16 @@ import json
import os import os
import sys import sys
from pathlib import Path from pathlib import Path
from typing import Dict
from dss.ingest.base import TokenCollection # Ensure the project root is in the Python path BEFORE importing dss modules
from dss.ingest.sources.figma import FigmaTokenSource
# Ensure the project root is in the Python path
DSS_ROOT = Path(__file__).parent.parent DSS_ROOT = Path(__file__).parent.parent
if str(DSS_ROOT) not in sys.path: if str(DSS_ROOT) not in sys.path:
sys.path.insert(0, str(DSS_ROOT)) sys.path.insert(0, str(DSS_ROOT))
from dss.ingest.base import TokenCollection
from dss.ingest.sources.figma import FigmaTokenSource
# ============================================================================= # =============================================================================
# CONFIGURATION # CONFIGURATION