From 481c3d39ffcc7e707ac5b07ba470f5433a8c2536 Mon Sep 17 00:00:00 2001 From: Bruno Sarlo Date: Fri, 12 Dec 2025 06:27:18 -0300 Subject: [PATCH] fix: Use venv Python for scripts, fix import order in figma-sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- scripts/dss-init.sh | 15 +++++++++++---- scripts/figma-sync.py | 9 +++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/dss-init.sh b/scripts/dss-init.sh index dc5038b..a10bf9d 100755 --- a/scripts/dss-init.sh +++ b/scripts/dss-init.sh @@ -17,6 +17,13 @@ set -e DSS_ROOT="$(cd "$(dirname "$0")/.." && pwd)" 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 RESET=false SKIP_ANALYSIS=false @@ -392,7 +399,7 @@ fi # Run validation if available if [ -f "scripts/validate-theme.py" ] && [ -f ".dss/schema/skin-contract.json" ]; then 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" done; then log_ok "All validations passed" @@ -421,7 +428,7 @@ if [ "$FIGMA_AVAILABLE" = true ] && [ "$TOKEN_STATUS" = "empty" ]; then log_info "File: $FIGMA_FILE_KEY" # 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" done; then 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 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" done; then 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 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" done; then STORY_COUNT=$(find admin-ui/src/stories -name "*.stories.js" 2>/dev/null | wc -l) diff --git a/scripts/figma-sync.py b/scripts/figma-sync.py index 75e9799..c25709e 100755 --- a/scripts/figma-sync.py +++ b/scripts/figma-sync.py @@ -16,15 +16,16 @@ import json import os import sys from pathlib import Path +from typing import Dict -from dss.ingest.base import TokenCollection -from dss.ingest.sources.figma import FigmaTokenSource - -# Ensure the project root is in the Python path +# Ensure the project root is in the Python path BEFORE importing dss modules DSS_ROOT = Path(__file__).parent.parent if str(DSS_ROOT) not in sys.path: sys.path.insert(0, str(DSS_ROOT)) +from dss.ingest.base import TokenCollection +from dss.ingest.sources.figma import FigmaTokenSource + # ============================================================================= # CONFIGURATION