forked from sbu-python-class/python-science
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
85 lines (73 loc) · 2.13 KB
/
Copy pathbuild.bat
File metadata and controls
85 lines (73 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
@echo off
REM Script para construir el libro localmente en Windows
echo ========================================
echo Build local del Jupyter Book
echo ========================================
echo.
REM Verificar si existe el directorio content
if not exist "content" (
echo ERROR: No se encuentra el directorio 'content'
exit /b 1
)
REM Limpiar build anterior si existe
echo [1/3] Limpiando builds anteriores...
if exist "content\_build" (
rmdir /s /q "content\_build"
echo Build anterior eliminado.
) else (
echo No hay build anterior para limpiar.
)
echo.
REM Verificar y activar el entorno conda si es necesario
set "CONDA_ENV_PATH=%CD%\.conda"
set "NEEDS_ACTIVATION=0"
REM Comprobar si estamos en el entorno correcto
if defined CONDA_PREFIX (
if /I "%CONDA_PREFIX%"=="%CONDA_ENV_PATH%" (
echo [INFO] Ya estas en el entorno conda local correcto
) else (
echo [INFO] Estas en otro entorno conda, cambiando al entorno local...
set "NEEDS_ACTIVATION=1"
)
) else (
echo [INFO] Activando entorno conda local...
set "NEEDS_ACTIVATION=1"
)
if "%NEEDS_ACTIVATION%"=="1" (
call conda activate .\.conda
if %ERRORLEVEL% neq 0 (
echo ERROR: No se pudo activar el entorno conda local
echo Verifica que el entorno existe en .conda
pause
exit /b 1
)
)
echo.
REM Construir el libro
echo [2/3] Construyendo el libro...
echo Esto puede tomar varios minutos debido a la ejecucion de notebooks...
echo.
jupyter-book build content
set "BUILD_ERROR=%ERRORLEVEL%"
REM Desactivar solo si lo activamos nosotros
if "%NEEDS_ACTIVATION%"=="1" (
call conda deactivate
)
REM Verificar si el build fue exitoso
if %BUILD_ERROR% neq 0 (
echo.
echo ERROR: El build fallo. Revisa los mensajes de error arriba.
exit /b %BUILD_ERROR%
)
echo.
echo [3/3] Build completado exitosamente!
echo.
echo ========================================
echo El libro esta listo en:
echo content\_build\html\index.html
echo ========================================
echo.
echo Para ver el libro, abre el archivo en tu navegador o ejecuta:
echo start content\_build\html\index.html
echo.
pause