mkpyproject funktioniert jetzt auch ohne python interpreter
This commit is contained in:
+76
-33
@@ -4,44 +4,87 @@ REM mkpyproject.bat - Standard Python Projekt Template erstellen
|
||||
REM ================================================================
|
||||
REM Verwendung: mkpyproject.bat <projektname> [zielverzeichnis]
|
||||
REM ================================================================
|
||||
setlocal enableextensions
|
||||
|
||||
REM Umgebung laden
|
||||
call "%~dp0setenv.bat"
|
||||
|
||||
REM Pruefen ob Umgebung gesetzt wurde
|
||||
if not defined PV_LIB (
|
||||
echo.
|
||||
echo FEHLER: Umgebung konnte nicht geladen werden!
|
||||
echo setenv.bat hat die Variablen nicht gesetzt.
|
||||
echo.
|
||||
set "PROJECT_NAME=%~1"
|
||||
set "TARGET_BASE=%~2"
|
||||
|
||||
if "%PROJECT_NAME%"=="" (
|
||||
echo FEHLER: Kein Projektname angegeben.
|
||||
echo Verwendung: mkpyproject.bat ^<projektname^> [zielverzeichnis]
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Pruefen ob Python verfuegbar ist
|
||||
py --version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
python --version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo ================================================================
|
||||
echo FEHLER: Kein Python-Interpreter gefunden!
|
||||
echo ================================================================
|
||||
echo.
|
||||
echo Weder 'py' noch 'python' konnten ausgefuehrt werden.
|
||||
echo.
|
||||
echo Bitte sicherstellen, dass Python installiert ist und der
|
||||
echo Pfad zur python.exe in der PATH-Umgebungsvariable enthalten ist.
|
||||
echo.
|
||||
echo 1. Python installieren: https://www.python.org/downloads/
|
||||
echo 2. Bei der Installation "Add Python to PATH" aktivieren
|
||||
echo 3. Oder manuell den Pfad hinzufuegen:
|
||||
echo set PATH=%%PATH%%;C:\Python312
|
||||
echo.
|
||||
echo ================================================================
|
||||
exit /b 1
|
||||
)
|
||||
python "%PV_LIB%\mkpyproject.py" %*
|
||||
goto :eof
|
||||
if "%TARGET_BASE%"=="" set "TARGET_BASE=."
|
||||
|
||||
REM Grossbuchstaben via PowerShell
|
||||
for /f "delims=" %%i in ('powershell -NoProfile -Command "'%PROJECT_NAME%'.ToUpper()"') do set "PROJECT_UPPER=%%i"
|
||||
|
||||
set "TARGET_DIR=%TARGET_BASE%\%PROJECT_NAME%"
|
||||
set "TMPL_DIR=%TOOLS_TEMPLATES%\mkpyproject"
|
||||
|
||||
if exist "%TARGET_DIR%" (
|
||||
echo FEHLER: Verzeichnis '%TARGET_DIR%' existiert bereits.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
py "%PV_LIB%\mkpyproject.py" %*
|
||||
echo ================================================================
|
||||
echo Erstelle Python-Projekt: %PROJECT_NAME%
|
||||
echo Zielverzeichnis: %TARGET_DIR%
|
||||
echo ================================================================
|
||||
|
||||
REM --- Verzeichnisse ---
|
||||
for %%d in (bin cfg data doc examples lib log results tests) do (
|
||||
mkdir "%TARGET_DIR%\%%d"
|
||||
)
|
||||
echo [OK] Verzeichnisse angelegt
|
||||
|
||||
REM --- Umgebungsvariablen fuer PowerShell ---
|
||||
set "MKP_NAME=%PROJECT_NAME%"
|
||||
set "MKP_UPPER=%PROJECT_UPPER%"
|
||||
set "MKP_TARGET=%TARGET_DIR%"
|
||||
set "MKP_TMPL=%TMPL_DIR%"
|
||||
for /f "delims=" %%y in ('powershell -NoProfile -Command "(Get-Date).Year"') do set "MKP_YEAR=%%y"
|
||||
|
||||
REM --- bin/ Skripte ---
|
||||
call :copy_tmpl "bin\setenv.bat"
|
||||
call :copy_tmpl "bin\setenv.sh"
|
||||
call :copy_tmpl "bin\install_py.bat"
|
||||
call :copy_tmpl "bin\install_py.sh"
|
||||
call :copy_tmpl "bin\activate_venv.bat"
|
||||
call :copy_tmpl "bin\activate_venv.sh"
|
||||
call :copy_tmpl "bin\get_cmd.bat"
|
||||
call :copy_tmpl "bin\get_cmd.sh"
|
||||
echo [OK] bin/ Skripte erstellt
|
||||
|
||||
call :copy_tmpl ".gitignore"
|
||||
echo [OK] .gitignore erstellt
|
||||
|
||||
call :copy_tmpl "LICENSE"
|
||||
echo [OK] LICENSE erstellt
|
||||
|
||||
call :copy_tmpl "README.md"
|
||||
echo [OK] README.md erstellt
|
||||
|
||||
call :copy_tmpl "requirements.txt"
|
||||
echo [OK] requirements.txt erstellt
|
||||
|
||||
echo.
|
||||
echo ================================================================
|
||||
echo FERTIG! Projekt '%PROJECT_NAME%' wurde erstellt.
|
||||
echo ================================================================
|
||||
echo.
|
||||
echo Naechste Schritte:
|
||||
echo Windows: bin\install_py.bat
|
||||
echo Linux: bash bin/install_py.sh
|
||||
echo.
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
:copy_tmpl
|
||||
REM %~1 = relative Pfad (z.B. "bin\setenv.bat")
|
||||
set "MKP_REL=%~1"
|
||||
powershell -NoProfile -Command "$s=Join-Path $env:MKP_TMPL $env:MKP_REL; $d=Join-Path $env:MKP_TARGET $env:MKP_REL; $c=Get-Content $s -Raw -Encoding UTF8; $c=$c -replace '__PROJECT_NAME__',$env:MKP_NAME; $c=$c -replace '__PROJECT_UPPER__',$env:MKP_UPPER; $c=$c -replace '__YEAR__',$env:MKP_YEAR; Set-Content -Path $d -Value $c -NoNewline -Encoding UTF8"
|
||||
exit /b 0
|
||||
|
||||
Reference in New Issue
Block a user