mirror of
https://github.com/drmext/MonkeyBusiness.git
synced 2024-11-14 10:37:38 +01:00
Make venv portable
This commit is contained in:
parent
1a3216a5fe
commit
7aca29993e
48
start.bat
48
start.bat
@ -4,8 +4,9 @@ cd /d %~dp0
|
||||
|
||||
if exist .venv\Lib\site-packages\ujson*.pyd (
|
||||
(
|
||||
.venv\Scripts\activate.bat
|
||||
python pyeamu.py
|
||||
goto :make_venv_portable
|
||||
:start_server
|
||||
.venv\Scripts\activate.bat && python pyeamu.py
|
||||
)
|
||||
) else (
|
||||
(
|
||||
@ -22,3 +23,46 @@ echo https://www.python.org/ftp/python/3.11.1/python-3.11.1-amd64.exe
|
||||
echo:
|
||||
|
||||
pause
|
||||
|
||||
goto :eof
|
||||
|
||||
:make_venv_portable
|
||||
set pyvenv="%~dp0.venv\pyvenv.cfg"
|
||||
set pyvenvtemp="%~dp0.venv\pyvenv.tmp"
|
||||
for /f "tokens=*" %%i in ('python -V') do set pyver=%%i
|
||||
for /f %%i in ('where python') do set pypath=%%i
|
||||
set v=home version executable command
|
||||
for %%a in (%v%) do for /f "tokens=*" %%i in ('findstr /b %%a %pyvenv%') do set %%a=%%i
|
||||
if exist %pyvenvtemp% del %pyvenvtemp%
|
||||
setlocal enabledelayedexpansion
|
||||
(
|
||||
for /f "tokens=1* delims=:" %%a in ('findstr /n "^" %pyvenv%') do (
|
||||
set "line=%%b"
|
||||
if "!line!"=="%home%" (set line=home = %pypath:~0,-11%)
|
||||
if "!line!"=="%version%" (set line=version = %pyver:~7%)
|
||||
if "!line!"=="%executable%" (set line=executable = %pypath%)
|
||||
if "!line!"=="%command%" (set line=command = %pypath% -m venv %~dp0.venv)
|
||||
echo(!line!
|
||||
)
|
||||
) > %pyvenvtemp%
|
||||
endlocal
|
||||
del %pyvenv%
|
||||
rename %pyvenvtemp% pyvenv.cfg
|
||||
|
||||
set activate="%~dp0.venv\Scripts\activate.bat"
|
||||
set activatetemp="%~dp0.venv\Scripts\activate.tmp"
|
||||
for /f "tokens=*" %%i in ('findstr "VIRTUAL_ENV=" %activate%') do set virtual=%%i
|
||||
if exist %activatetemp% del %activatetemp%
|
||||
setlocal enabledelayedexpansion
|
||||
(
|
||||
for /f "tokens=1* delims=:" %%a in ('findstr /n "^" %activate%') do (
|
||||
set "line=%%b"
|
||||
if "!line!"=="%virtual%" (set line=set VIRTUAL_ENV=%~dp0.venv)
|
||||
if "!line!"=="END" (set line=:END)
|
||||
echo(!line!
|
||||
)
|
||||
) > %activatetemp%
|
||||
endlocal
|
||||
del %activate%
|
||||
rename "%activatetemp%" activate.bat
|
||||
goto :start_server
|
||||
|
Loading…
Reference in New Issue
Block a user