-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyrun.bat
437 lines (383 loc) · 11.4 KB
/
pyrun.bat
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
@echo off && setlocal EnableDelayedExpansion
if "%~dp0" neq "!guid!\" (set "guid=%tmp%\crlf.%~nx0.%~z0" & set "cd=%~dp0" & (if not exist "!guid!\%~nx0" (mkdir "!guid!" 2>nul & find "" /v<"%~f0" >"!guid!\%~nx0")) & call "!guid!\%~nx0" %* & rmdir /s /q "!guid!" 2>nul & exit /b) else (if "%cd:~-1%"=="\" set "cd=%cd:~0,-1%")
rem Install Python environment variables and packages before running %~n0.py file, by wenuam 2022-2023
rem '%~n0.bat inst' : install packages (pip, ...)
rem '%~n0.bat cmd' : open cmd with Python env var
rem Save code page then set it to utf-8 (/!\ this file MUST be in utf-8)
for /f "tokens=2 delims=:." %%x in ('chcp') do set cp=%%x
chcp 65001>nul
rem Set "quiet" suffixes
set "quiet=1>nul 2>nul"
set "fquiet=/f /q 1>nul 2>nul"
rem Recompose 'pandoc' dependencies...
cd /d "%cd%\Tools\Pandoc"
if exist "pandoc.exe.001" (
copy /y /b "pandoc.exe.001"+"pandoc.exe.002"+"pandoc.exe.003" "pandoc.exe" %quiet%
del "pandoc.exe.0*" %fquiet%
)
cd /d "%cd%"
rem Python runner
rem (can be used for any project)
cls
echo Running "%~f0" :
rem === Setup PYTHON local path (maybe duplicates)
rem https://docs.python.org/3/using/cmdline.html#environment-variables
set "PYTHONROOT=%cd%\Python"
set "PYTHONPATH=%PYTHONROOT%;%PYTHONROOT%\DLLs;%PYTHONROOT%\Lib"
set "PYTHONSITE=%PYTHONROOT%\Lib\site-packages"
set "PATH=!PATH!;%PYTHONROOT%"
set "PATH=!PATH!;%PYTHONROOT%\Scripts"
echo cd=%cd%
rem Set PATH with tools
set "cset=set_path.txt"
if exist "%cset%" (
for /f "tokens=1* delims=?" %%i in (%cset%) do (
set "vset=%%~fi"
set "PATH=!PATH!;!vset!"
)
)
rem Clean PATH
set "PATH=!PATH:\\=\!"
set "PATH=!PATH:;;=;!"
set "PATH=!PATH: ;=;!"
set "PATH=!PATH:; =;!"
if "!PATH:~-1!"==";" set "PATH=!PATH:~0,-1!"
REM echo path=!PATH!
rem Additional path
set "PLANTUML_PATH=%cd%\Tools\plantuml\plantuml.jar"
rem Local constants
set "PIP_PATH="
set "PIP_OPTS=--no-cache-dir"
set "PIP_PROX=--proxy=^"http://gateway.schneider.zscaler.net:80^""
set "PIP_FILE=get-pip.py"
set "BOOTSTRAP_URL=https://bootstrap.pypa.io/%PIP_FILE%"
echo PIP_PROX=%PIP_PROX%
rem Installation : 'install' (default if 'get-pip.py' not present)
rem (could be quite long depending on the packages to install)
if "%1" == "inst" set "todo=inst"
if "%1" == "install" set "todo=inst"
if not exist "%PIP_FILE%" set "todo=inst"
if "%todo%" == "inst" (
call :py_install
echo;
echo Installation done...
)
rem Execution : 'run' or nothing (default)
if "%1" == "" set "todo=run"
if "%1" == "run" set "todo=run"
if "%todo%" == "run" (
if not "%2" == "" (
rem Run specified client (in '%PYTHONROOT%\Scripts')
echo Running specified "%2.exe"...
"%2"
) else (
rem Run default client (same name as batch file)
echo Running default "%~n0.py"...
"%PYTHONROOT%\python" "%~n0.py"
echo;
)
)
rem Command line : 'cmd'
rem (useful to launch commands by hand with a configured Python setup)
if "%1" == "cmd" set "todo=cmd"
if "%todo%" == "cmd" (
echo Opening pre-configured "cmd" console...
start "" /d "%cd%" "cmd" ""
)
rem Command line : 'inspect'
rem (useful to inspect installed packages, needs docutils-markdown-PyQt5)
if "%1" == "insp" set "todo=insp"
if "%1" == "inspect" set "todo=insp"
if "%todo%" == "insp" (
call :pip_check docutils
call :pip_check markdown
call :pip_check PyQt5
echo Opening the "inspector"...
start "" /d "%PYTHONROOT%" "python" "%cd%\Tools\pyspector\src\main.py"
)
rem Restore saved code page
chcp %cp%>nul
goto :eof
rem - - - Subroutines - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:py_install
rem === Remove fake links for Windows Store
del "%LOCALAPPDATA%\Microsoft\WindowsApps\Python*.exe" %quiet%
rem === Installing Python from command line
rem https://docs.python.org/3/using/windows.html#installing-without-ui
rem === Install and update PIP (https://pypi.org/project/pip/)
if not exist "%PIP_FILE%" (
curl "%BOOTSTRAP_URL%" >"%PIP_FILE%" && (
echo Installing "%BOOTSTRAP_URL%"...
"%PYTHONROOT%\python" "%PIP_FILE%"
) || (
echo Cannot get "%BOOTSTRAP_URL%"...
)
)
if not "1"=="" (
call :pip_install pip
REM pip cache dephell
REM pip cache dir
REM pip cache purge
)
rem === VENV and stuff (doesn't quite work as expected though)
if not ""=="" (
REM call :pip_install virtualenv
REM call :pip_install virtualenvwrapper-win
REM cd %USERPROFILE%\Envs
REM cd %WORKON_HOME%
)
rem === OpenAPI
if not ""=="" (
REM call :pip_install joey
REM call :pip_install datamodel-code-generator
call :pip_install openapi-fastapi-client
REM call :pip_install fastapi-code-generator
)
rem === Async
if not ""=="" (
REM call :pip_install curio
call :pip_install trio
)
rem === Format support
if not ""=="" (
call :pip_install PyYAML
call :pip_install yaplon
)
rem === Path and folder
if not ""=="" (
call :pip_install dictdatabase
call :pip_install itemdb
call :pip_install edict
call :pip_install "git+https://github.com/thejens/loren.git"
call :pip_install dict-path
call :pip_install path-dict
REM call :pip_install folder-dict
call :pip_install pyfolder
call :pip_install pyzip
REM call :pip_install remotezip
)
rem === Editor
if not ""=="" (
REM call :pip_install ash-editor
call :pip_install emerge-viz
REM call :pip_install "git+https://github.com/glato/emerge.git"
call :pip_install flake8
call :pip_install PyQt5
call :pip_install "git+https://github.com/andreikop/enki.git"
call :pip_install semgrep
call :pip_install suplemon
REM call :pip_install tui-editor
)
rem === Data structure
if not ""=="" (
call :pip_install bidict
)
rem === Documentation
if not ""=="" (
call :pip_install griffe
call :pip_install Sphinx
)
rem === Document conversion
if not ""=="" (
REM call :pip_install 2to3
REM call :pip_install pdfminer.six[image]
REM call :pip_install pdf-to-markdown
REM call :pip_install markdownify
REM call :pip_install textract
call :pip_install pymupdf
REM call :pip_install tabula-py
)
rem === Tui related
if not ""=="" (
call :pip_install Pygments
call :pip_install pytermgui
call :pip_install pyTermTk
call :pip_install rich
call :pip_install rich-cli
call :pip_install textual
call :pip_install tlogg
call :pip_install ttkode
call :pip_install urwid
)
rem === Inspection
if not ""=="" (
call :pip_install inspect-extensions
call :pip_install pipspect
REM call :pip_install inspectshow
REM call :pip_install "git+https://github.com/vadivelmurugank/inspectshow.git"
REM call :pip_install pyexplorer
REM call :pip_install "git+https://github.com/dexpota/pyexplorer.git"
REM call :pip_install pyspector
call :pip_install docutils
call :pip_install markdown
call :pip_install PyQt5
)
rem === Debugging
if not ""=="" (
call :pip_install better_exceptions
REM call :pip_install boofuzz
REM call :pip_install callspectpy
call :pip_install crosshair-tool
REM call :pip_install ddebug
REM call :pip_install epdb
call :pip_install icecream
call :pip_install objprint
call :pip_install pdbpp
call :pip_install pdbr
call :pip_install pretty_errors
REM call :pip_install prettyexc
REM call :pip_install profiling
call :pip_install pudb
call :pip_install PySnooper
REM call :pip_install scalene
REM call :pip_install skjold
call :pip_install "git+https://github.com/twu/skjold.git"
call :pip_install snoop
REM call :pip_install snoop-tensor
call :pip_install stackprinter
REM call :pip_install torchsnooper
REM call :pip_install undent
REM call :pip_install validators
call :pip_install "git+https://github.com/python-validators/validators.git"
call :pip_install viztracer
REM call :pip_install vizplugins
REM call :pip_install voltron
REM call :pip_install watchpoints
REM call :pip_install web-pdb
)
rem === Hot reloading
if not ""=="" (
REM call :pip_install hotreload
call :pip_install jurigged
REM call :pip_install python-hmr
call :pip_install reloadium
)
rem === Binary parser
if not ""=="" (
REM call :pip_install auto-struct
REM call :pip_install binmap
REM call :pip_install bread
REM call :pip_install construct
REM call :pip_install construct-classes
REM call :pip_install construct-editor
REM call :pip_install construct-typing
REM call :pip_install construct-gallery
call :pip_install deconstruct
REM call :pip_install destructify
call :pip_install hachoir
call :pip_install iofree
REM call :pip_install pabo
call :pip_install structures
)
rem === Gui related (wxPython, official wxWidgets' interface)
if not ""=="" (
call :pip_install wxPython
)
rem === Gui related (enaml, declarative and functional oriented)
if not ""=="" (
REM call :pip_install rtree
REM call :pip_install intervaltree
REM call :pip_install traits
REM call :pip_install vtk
call :pip_install qtpy
call :pip_install qasync
call :pip_install PyQt5
REM call :pip_install PySide6
call :pip_install enaml
)
rem === Gui related (enamlx, maybe outdated a bit)
if not ""=="" (
call :pip_install pyqtgraph
call :pip_install enamlx
call :pip_install enaml-extensions
REM call :pip_install enaml-coverage-plugin
REM call :pip_install ae-enaml-app
REM call :pip_install gild[qt5-pyqt]
REM call :pip_install gild[qt5-pyside]
REM call :pip_install gild[qt6-pyqt]
REM call :pip_install gild[qt6-pyside]
)
rem === Gui related (enaml-web, maybe not mature)
if not ""=="" (
call :pip_install enaml-web
call :pip_install materialize-ui
call :pip_install tornado
call :pip_install pandas
)
rem === Gui related (enaml-native)
if not ""=="" (
call :pip_install enaml-native
call :pip_install enaml-native-cli
call :pip_install enaml-native-icons
call :pip_install enaml-native-barcode
call :pip_install enaml-native-charts
call :pip_install enaml-native-maps
)
rem === Wui
if not ""=="" (
call :pip_install pyodide
call :pip_install shiny
)
rem === Cryptography
if not ""=="" (
call :pip_install ciphey
)
rem === Generative AI
if not ""=="" (
call :pip_install discoart
call :pip_install docarray
call :pip_install jina
REM call :pip_install norfair
)
rem === Opcua related (aka FreeOpcUa/opcua-asyncio, some Qt5 dependencies)
if not ""=="" (
call :pip_install asyncua
call :pip_install opcua
call :pip_install opcua-webclient
call :pip_install opcua-client
call :pip_install opcua-modeler
REM call :pip_install "git+https://github.com/PrediktorAS/opcua-tools.git"
)
rem === ZigBee related
if not ""=="" (
call :pip_install zigpy
call :pip_install zigpy-cli
call :pip_install zigpy-xbee
call :pip_install zigpy-znp
call :pip_install zigpy-cc
call :pip_install bellows
call :pip_install zha-quirks
REM call :pip_install zigpy-homeassistant
)
rem === Graph
if not ""=="" (
call :pip_install blockdiag
call :pip_install data-flow-diagram
call :pip_install diagrams
call :pip_install code2flow
call :pip_install processpiper
call :pip_install pyflowchart
call :pip_install roadmapper
call :pip_install umlsequence2
)
rem === Threat modelling
if not ""=="" (
call :pip_install fluentm
REM call :pip_install pytm
call :pip_install "git+https://github.com/izar/pytm.git"
REM call :pip_install threatspec
call :pip_install "git+https://github.com/threatspec/threatspec.git"
)
goto :eof
:pip_check
if not "%~1"=="" if not exist "%PYTHONSITE%\%~1" (
call :pip_install %~1
)
goto :eof
:pip_install
echo;
echo; - - - Installing "%~1" - - - - - - - - - - - - - - - - - - - - - - - -
echo;
"%PYTHONROOT%\python" -m pip install %PIP_PATH% %PIP_OPTS% --upgrade %~1 | findstr /V /C:"already satisfied"
rem set -o pipefail; pip install -r requirements.txt | { grep -v "already satisfied" || :; }
goto :eof