Files
wsa-webdav/setup_python.bat

105 lines
3.1 KiB
Batchfile

@echo off
REM ============================================================================
REM Windows Build Helper for WSA WebDAV Server
REM ============================================================================
REM This script helps prepare the embedded Python for the APK on Windows.
REM For full CPython cross-compilation, use Linux or WSL.
REM ============================================================================
setlocal enabledelayedexpansion
set PROJECT_DIR=%~dp0..
set PYTHON_BUILD_DIR=%PROJECT_DIR%\python_build
set OUTPUT_DIR=%PYTHON_BUILD_DIR%\output
set ASSETS_DIR=%PROJECT_DIR%\app\src\main\assets\python
echo ============================================
echo WSA WebDAV - Embedded Python Setup
echo ============================================
echo.
REM Check for Python
python --version >nul 2>&1
if errorlevel 1 (
echo ERROR: Python not found. Please install Python 3.8+
echo Download from: https://www.python.org/downloads/
exit /b 1
)
REM Check for required tools
echo Checking prerequisites...
python -c "import urllib.request" >nul 2>&1
if errorlevel 1 (
echo ERROR: urllib not available
exit /b 1
)
echo.
echo Choose setup method:
echo 1. Download pre-built Python binaries (Recommended)
echo 2. Create minimal bootstrap (requires system Python on device)
echo 3. Build from source (requires Linux/WSL)
echo.
set /p choice="Enter choice (1-3): "
if "%choice%"=="1" (
echo.
echo Downloading pre-built Python binaries...
python "%PYTHON_BUILD_DIR%\scripts\download_python.py" --output "%OUTPUT_DIR%"
if errorlevel 1 (
echo.
echo Download failed. Trying minimal bootstrap...
python "%PYTHON_BUILD_DIR%\scripts\download_python.py" --output "%OUTPUT_DIR%" --minimal
)
) else if "%choice%"=="2" (
echo.
echo Creating minimal Python bootstrap...
python "%PYTHON_BUILD_DIR%\scripts\download_python.py" --output "%OUTPUT_DIR%" --minimal
) else if "%choice%"=="3" (
echo.
echo For source compilation, please use Linux or WSL.
echo See: python_build\README.md
echo.
echo Alternatively, run the Docker build:
echo cd %PYTHON_BUILD_DIR%
echo docker build -t cpython-android .
echo docker run -v %OUTPUT_DIR%:/output cpython-android
exit /b 0
) else (
echo Invalid choice
exit /b 1
)
REM Copy to assets
echo.
echo Copying Python to APK assets...
if exist "%ASSETS_DIR%" (
rmdir /s /q "%ASSETS_DIR%"
)
mkdir "%ASSETS_DIR%" 2>nul
if exist "%OUTPUT_DIR%\arm64-v8a" (
echo Copying arm64-v8a...
xcopy /E /I /Y "%OUTPUT_DIR%\arm64-v8a" "%ASSETS_DIR%\arm64-v8a"
)
if exist "%OUTPUT_DIR%\x86_64" (
echo Copying x86_64...
xcopy /E /I /Y "%OUTPUT_DIR%\x86_64" "%ASSETS_DIR%\x86_64"
)
echo.
echo ============================================
echo Setup Complete!
echo ============================================
echo.
echo Next steps:
echo 1. Open project in Android Studio
echo 2. Build APK: Build > Build Bundle(s) / APK(s)
echo 3. Install APK on WSA device
echo.
echo APK output will be at:
echo app\build\outputs\apk\debug\app-debug.apk
echo.
pause