-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathkivy.bat
813 lines (772 loc) · 30.3 KB
/
kivy.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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
::Author: KeyWeeUsr @ https://github.com/KeyWeeUsr
::Version: 3.9
::Inspired by kivy.bat file for kivy1.8.0
::To reset file just delete "config.kivyinstaller"
::Bitsadmin is available since winXP SP2
::If it is not available, download and install to C:\Windows
::https://www.microsoft.com/en-us/download/details.aspx?id=18546
:: Customizable variables
@if not defined DEBUG (echo off)
if not defined cp2 (set cp2=cp27)
if not defined cp3 (set cp3=cp35)
if not defined py2 (set py2=2.7.13)
if not defined py3 (set py3=3.5.2)
if not defined master (set master=1.11.0)
:: Config variables
:: - KivyInstaller variables
set xp=0
set cp=0
set first=1
set admin=1
set cpwhl=0
set stable=1
set arch=win32
set pyversion=0
set gstreamer=0
set installkivy=1
set installerversion=3.9
set kilog=[KivyInstaller]
title = KivyInstaller %installerversion%
:: - Environment paths and configs
set sendto=%appdata%\Microsoft\Windows\SendTo
set taskbar=%appdata%\Microsoft\Internet Explorer\Quick Launch
set addlocal=ADDLOCAL^=DefaultFeature,PrivateCRT,TclTk,Documentation,Tools,Testsuite
set py35addlocal=Shortcuts=0 Include_launcher=0 Include_pip=0
set pyFTP=https://www.python.org/ftp/python/
:: Return version without installation
:version
if defined DEBUG echo [%1]==[version]
if [%1]==[version] (
echo %installerversion%
exit
)
:: Check whether we are on WinXP
ver | find "5.1" >nul && set xp=1
if defined DEBUG echo [%xp%]==[1]
if [%xp%]==[1] (
set sendto=%userprofile%\SendTo
)
echo ###############################################################################
echo KivyInstaller v%installerversion%
echo Author: KeyWeeUsr @ https://github.com/KeyWeeUsr
echo.
echo Report issues @ https://github.com/KeyWeeUsr/KivyInstaller/issues
echo ###############################################################################
:: Look for KivyInstaller config
:: - if found, Python+Kivy+... were installed properly and script expects it
echo %kilog% Looking for config file...
if exist "%~dp0config.kivyinstaller" (
echo %kilog% Config file found, setting variables...
set first=0
for /f "delims=" %%z in ('type "%~dp0config.kivyinstaller"') do set %%z
) else (
echo %kilog% Config file not found, running installation...
set first=1
)
if defined DEBUG echo not [%first%]==[1]
if not [%first%]==[1] (
goto installed
)
if defined DEBUG echo [%processor_architecture%]==[AMD64]
if [%processor_architecture%]==[AMD64] (
set /p arch32="64bit environment detected! Create 32bit instead? y/n"
)
if defined DEBUG echo [%arch32%]==[n]
if [%arch32%]==[n] (
set arch=win_amd64
)
:: %~dp0 needed to access the Python executable directly where
:: kivy.bat is, otherwise it might fetch the global system one
if exist "%~dp0python.exe" (
echo %kilog% Python is already installed!
echo %kilog% - To continue with kivy installation choose "y"
echo %kilog% - To uninstall choose "n"
set /p kivycontinue="Continue with kivy installation? y/n"
)
if defined DEBUG echo [%kivycontinue%]==[n]
if [%kivycontinue%]==[n] (
goto uninstall
)
:privileges
set /p choice_privileges="Install Python globally (requires admin)? y/n"
if defined DEBUG echo [%choice_privileges%]==[y]
if [%choice_privileges%]==[y] (
goto py_version
) else if [%choice_privileges%]==[n] (
set admin=0
) else (
goto privileges
)
:py_version
set /p choice_python="Choose the Python version! 2/3"
if defined DEBUG echo [%choice_python%]==[2]
if [%choice_python%]==[2] (
set pyversion=%py2%
set cp=%cp2%m
set cpwhl=%cp2%
set shrtct=%cp2:~2%
set pyext=.msi
) else if [%choice_python%]==[3] (
set pyversion=%py3%
set cp=%cp3%m
set cpwhl=%cp3%
set shrtct=%cp3:~2%
if defined DEBUG echo [%py3%] geq [3.5.0]
if [%py3%] geq [3.5.0] (
set pyext=.exe
) else (
set pyext=.msi
)
) else (
goto py_version
)
:: Python 3.5+ has different type of installer
set amdext=.amd64
if defined DEBUG echo [%pyext%]==[.exe]
if [%pyext%]==[.exe] (
set amdext=-amd64
)
:extensions
set /p choice_ext="Register Python extensions (.py, .pyc, ...)? y/n"
if defined DEBUG echo [%choice_ext%]==[y]
if [%choice_ext%]==[y] (
set addlocal=%addlocal%,Extensions
set py35addlocal=%py35addlocal% AssociateFiles=1
) else if [%choice_ext%]==[n] (
set addlocal=%addlocal%
set py35addlocal=%py35addlocal% AssociateFiles=0
) else (
goto extensions
)
:kivy
set /p choice_kivy="Proceed with Kivy installation? y/n"
if defined DEBUG echo [%choice_kivy%]==[y]
if [%choice_kivy%]==[y] (
set installkivy=1
) else if [%choice_kivy%]==[n] (
set installkivy=0
goto nokivy
) else (
goto kivy
)
set /p choice_master="Install the latest development version? y/n"
if defined DEBUG echo [%choice_master%]==[y]
if [%choice_master%]==[y] (
set stable=0
)
set /p choice_gst="Install GStreamer? y/n"
if defined DEBUG echo [%choice_gst%]==[y]
if [%choice_gst%]==[y] (
set gstreamer=1
)
set /p choice_dsgn="Install Kivy Designer? y/n"
if defined DEBUG echo [%choice_dsgn%]==[y]
if [%choice_dsgn%]==[y] (
set designer=1
)
set /p choice_shrt="Make shortcuts (taskbar + send to)? y/n"
if defined DEBUG echo [%choice_shrt%]==[y]
if [%choice_shrt%]==[y] (
set shortcuts=1
)
:: No Kivy installation expected
:nokivy
if defined DEBUG echo [%kivycontinue%]==[y]
if [%kivycontinue%]==[y] (
goto check
)
:: needs fixing for webinstallers
if defined DEBUG echo [%arch%]==[win32]
if [%arch%]==[win32] (
if exist "%~dp0py%pyversion%%pyext%" (
echo %kilog% Installer is already downloaded!
) else (
echo %kilog% Downloading Python installer...
if defined DEBUG echo [%pyext%]==[.exe]
if [%pyext%]==[.exe] (
if defined DEBUG echo [%admin%]==[0]
if [%admin%]==[0] (
bitsadmin.exe /transfer ^
"GetPython%pyversion%-webinstall%pyext%" ^
"%pyFTP%%pyversion%/python-%pyversion%-webinstall%pyext%" ^
"%~dp0py%pyversion%-webinstall%pyext%"
) else (
bitsadmin.exe /transfer ^
"GetPython%pyversion%%pyext%" ^
"%pyFTP%%pyversion%/python-%pyversion%%pyext%" ^
"%~dp0py%pyversion%%pyext%"
)
) else (
bitsadmin.exe /transfer ^
"GetPython%pyversion%%pyext%" ^
"%pyFTP%%pyversion%/python-%pyversion%%pyext%" ^
"%~dp0py%pyversion%%pyext%"
)
echo %kilog% Installing...
)
if defined DEBUG echo [%admin%]==[0]
if [%admin%]==[0] (
copy "%~dp0py%pyversion%%pyext%" "%~dp0py%pyversion%_%pyext%" >nul
if defined DEBUG echo [%pyext%]==[.msi]
if [%pyext%]==[.msi] (
msiexec.exe /a "%~dp0py%pyversion%.msi" /qb /L*V "%~dp0msi.log" ^
ALLUSERS=0 TARGETDIR="%~dp0kivy" ^
CURRENTDIRECTORY="%~dp0" %addlocal%
for /f "tokens=*" %%f in ('dir /b "%~dp0kivy"') do move "%~dp0kivy\%%f" "%~dp0%%f" >nul
) else if [%pyext%]==[.exe] (
"%~dp0py%pyversion%-webinstall.exe" /quiet /layout "%~dp0\_installers"
msiexec.exe /a "%~dp0\_installers\core.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\dev.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\doc.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\exe.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\lib.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\tcltk.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\test.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\tools.msi" TARGETDIR="%~dp0"
del /q "%~dp0\core.msi"
del /q "%~dp0\dev.msi"
del /q "%~dp0\doc.msi"
del /q "%~dp0\exe.msi"
del /q "%~dp0\lib.msi"
del /q "%~dp0\tcltk.msi"
del /q "%~dp0\test.msi"
del /q "%~dp0\tools.msi"
rmdir /s /q "%~dp0_installers"
)
) else (
if defined DEBUG echo [%pyext%]==[.msi]
if [%pyext%]==[.msi] (
msiexec.exe /i "%~dp0py%pyversion%.msi" /qb /L*V "%~dp0msi.log" ^
ALLUSERS=0 TARGETDIR="%~dp0" CURRENTDIRECTORY="%~dp0" %addlocal%
) else if [%pyext%]==[.exe] (
"%~dp0py%pyversion%.exe" /quiet /log "%~dp0msi.log" ^
DefaultJustForMeTargetDir="%~dp0" InstallAllUsers=0 %py35addlocal%
)
)
) else (
if exist "%~dp0py%pyversion%%amdext%%pyext%" (
echo %kilog% Installer is already downloaded!
) else (
if defined DEBUG echo [%pyext%]==[.exe]
if [%pyext%]==[.exe] (
if defined DEBUG echo [%admin%]==[0]
if [%admin%]==[0] (
bitsadmin.exe /transfer ^
"GetPython%pyversion%%amdext%-webinstall%pyext%" ^
"%pyFTP%%pyversion%/python-%pyversion%%amdext%-webinstall%pyext%" ^
"%~dp0py%pyversion%%amdext%-webinstall%pyext%"
) else (
bitsadmin.exe /transfer ^
"GetPython%pyversion%%amdext%%pyext%" ^
"%pyFTP%%pyversion%/python-%pyversion%%amdext%%pyext%" ^
"%~dp0py%pyversion%%amdext%%pyext%"
)
) else (
bitsadmin.exe /transfer "GetPython%pyversion%%amdext%%pyext%" ^
"%pyFTP%%pyversion%/python-%pyversion%%amdext%%pyext%" ^
"%~dp0py%pyversion%%amdext%%pyext%"
)
echo %kilog% Installing...
)
if defined DEBUG echo [%admin%]==[0]
if [%admin%]==[0] (
copy "%~dp0py%pyversion%%amdext%.msi" "%~dp0py%pyversion%_%amdext%.msi" >nul
if defined DEBUG echo [%pyext%]==[.msi]
if [%pyext%]==[.msi] (
msiexec.exe /a "%~dp0py%pyversion%%amdext%.msi" /qb /L*V "%~dp0msi.log" ^
ALLUSERS=0 TARGETDIR="%~dp0kivy" CURRENTDIRECTORY="%~dp0" %addlocal%
for /f "tokens=*" %%f in ('dir /b "%~dp0kivy"') do move "%~dp0kivy\%%f" "%~dp0%%f" >nul
) else if [%pyext%]==[.exe] (
"%~dp0py%pyversion%%amdext%-webinstall.exe" /quiet /layout "%~dp0\_installers"
msiexec.exe /a "%~dp0\_installers\core.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\dev.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\doc.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\exe.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\lib.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\tcltk.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\test.msi" TARGETDIR="%~dp0"
msiexec.exe /a "%~dp0\_installers\tools.msi" TARGETDIR="%~dp0"
del /q "%~dp0\core.msi"
del /q "%~dp0\dev.msi"
del /q "%~dp0\doc.msi"
del /q "%~dp0\exe.msi"
del /q "%~dp0\lib.msi"
del /q "%~dp0\tcltk.msi"
del /q "%~dp0\test.msi"
del /q "%~dp0\tools.msi"
rmdir /s /q "%~dp0_installers"
)
) else (
if defined DEBUG echo [%pyext%]==[.msi]
if [%pyext%]==[.msi] (
msiexec.exe /i "%~dp0py%pyversion%%amdext%.msi" /qb /L*V "%~dp0msi.log" ^
ALLUSERS=0 TARGETDIR="%~dp0" CURRENTDIRECTORY="%~dp0" %addlocal%
) else if [%pyext%]==[.exe] (
"%~dp0py%pyversion%%amdext%.exe" /quiet /log "%~dp0msi.log" ^
DefaultJustForMeTargetDir="%~dp0" InstallAllUsers=0 %py35addlocal%
)
)
)
if defined DEBUG echo [%admin%]==[0]
if [%admin%]==[0] (
del /q "%~dp0py%pyversion%%pyext%"
move /y "%~dp0py%pyversion%_%pyext%" "%~dp0py%pyversion%%pyext%" >nul
del /q "%~dp0py%pyversion%%amdext%%pyext%"
move /y "%~dp0py%pyversion%_%amdext%%pyext%" "%~dp0py%pyversion%%amdext%%pyext%" >nul
)
goto check
:uninstall
set /p choice_uninstall="Uninstall the whole environment? y/n"
set /p choice_pipcache="Remove cached pip files? y/n"
set /p choice_dist="Remove PyInstaller dist folder (if any)? y/n"
if defined DEBUG echo [%arch%]==[win32]
if [%arch%]==[win32] (
if not exist "%~dp0py%pyversion%%pyext%" (
bitsadmin.exe /transfer "GetPython%pyversion%%pyext%" ^
"%pyFTP%%pyversion%/python-%pyversion%%pyext%" ^
"%~dp0py%pyversion%%pyext%"
)
if defined DEBUG echo [%choice_uninstall%]==[y]
if [%choice_uninstall%]==[y] (
if defined DEBUG echo [%admin%]==[0]
if [%admin%]==[0] (
attrib +r +a *.bat
for /f "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
attrib -r -a *.bat
) else (
if defined DEBUG echo [%pyext%]==[.msi]
if [%pyext%]==[.msi] (
msiexec.exe /x "%~dp0py%pyversion%.msi" /qb
) else if [%pyext%]==[.exe] (
"%~dp0py%pyversion%.exe" /uninstall
)
)
) else (goto end)
) else (
if not exist "%~dp0py%pyversion%%amdext%%pyext%" (
bitsadmin.exe /transfer "GetPython%pyversion%%amdext%%pyext%" ^
"%pyFTP%%pyversion%/python-%pyversion%%amdext%%pyext%" ^
"%~dp0py%pyversion%%amdext%%pyext%"
)
if defined DEBUG echo [%choice_uninstall%]==[y]
if [%choice_uninstall%]==[y] (
if defined DEBUG echo [%admin%]==[0]
if [%admin%]==[0] (
attrib +r +a *.bat
for /f "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
attrib -r -a *.bat
) else (
if defined DEBUG echo [%pyext%]==[.msi]
if [%pyext%]==[.msi] (
msiexec.exe /x "%~dp0py%pyversion%%amdext%.msi" /qb
) else if [%pyext%]==[.exe] (
"%~dp0py%pyversion%%amdext%.msi" /uninstall
)
)
) else (goto end)
)
if not exist "%~dp0python.exe" (
del /q "%~dp0config.kivyinstaller"
del /q "%~dp0extrapath.kivyinstaller"
del /q "%~dp0update_kivy.bat"
del /q "%~dp0backup_kivy.bat"
del /s /q /f "%~dp0*.spec"
rmdir /s /q "%userprofile%\.kivy"
rmdir /s /q "%userprofile%\.idlerc"
rmdir /s /q "%~dp0Lib"
rmdir /s /q "%~dp0Scripts"
rmdir /s /q "%~dp0share"
rmdir /s /q "%~dp0whls"
rmdir /s /q "%~dp0build"
)
if defined DEBUG echo [%choice_pipcache%]==[y]
if [%choice_pipcache%]==[y] (
if exist "%localappdata%\pip" (
rmdir /s /q "%localappdata%\pip"
) else (
rmdir /s /q "%userprofile%\Local Settings\Application Data\pip"
)
)
if defined DEBUG echo [%choice_dist%]==[y]
if [%choice_dist%]==[y] (
rmdir /s /q "%~dp0dist"
)
goto rmshortcuts
:batupdate
:: Download GitHub's raw output
echo %kilog% Checking for updates...
bitsadmin.exe /transfer "GetKivyInstaller" "https://git.io/vDDjn" "%~dp0_update_kivy.bat"
:: UNIX to WIN EOL (GitHub raw provides \n) with MORE /P
type "%~dp0_update_kivy.bat" | more /p > "%~dp0update_kivy.bat"
del "%~dp0_update_kivy.bat"
:: Find the installer's version - fixed to the 2nd line
:: -> strip "::Version: "(11)
for /f "tokens=1*delims=::Version: " ^
%%A in ('findstr /n "^" "%~dp0update_kivy.bat"') do (
if %%A equ 2 set updateversion=%%B
)
if defined DEBUG echo "%installerversion% lss %updateversion%"
if %installerversion% lss %updateversion% (
echo %kilog% You are using KivyInstaller version %installerversion%!
echo %kilog% - New version %updateversion% is available!
if defined DEBUG echo [%onlycheck%]==[1]
if [%onlycheck%]==[1] (
echo %kilog% - To install new version use - %~n0 batupdate
del "%~dp0update_kivy.bat"
goto console
)
) else if %installerversion% == %updateversion% (
echo %kilog% Your version is up to date!
del "%~dp0update_kivy.bat"
goto console
)
:: echo F for file
:: After update an exit is needed, otherwise a cached file is used!
echo %kilog% Backing up the original file...
echo F | xcopy /y "%~dp0%~n0.bat" "%~dp0backup_kivy.bat"
echo %kilog% Updating...
(echo Y | xcopy "%~dp0update_kivy.bat" "%~dp0%~n0.bat") ^
& del "%~dp0update_kivy.bat" & echo Done & exit
:help
echo.
echo KivyInstaller v%installerversion%
echo.
echo Usage:
echo %~n0 [options]
echo.
echo ^<file^> Run python(.py) file
echo update Update kivy wheel to the latest stable
echo updatemaster Update kivy wheel to the latest nightly-build
echo batcheck Check for new KivyInstaller version only
echo batupdate Check for new KivyInstaller version and update
echo remove Uninstall kivy only
echo uninstall Uninstall kivy, python and leave only %~n0.bat
echo mkshortcuts Create shortcuts for SendTo and TaskBar
echo rmshortcuts Remove shortcuts for SendTo and TaskBar
echo pack "<abs path to .py>" Quick packaging with pyinstaller
echo version Print version of the KivyInstaller
echo help Show this
echo.
echo Optional:
echo idle Python text editor with syntax highlighting
echo pyinstaller Executable packager for Python programs
echo.
echo Extra install:
echo getdesigner Install Kivy Designer (python -m designer)
echo getgcc Install GNU Compiler Collection (mingw32-make, gcc)
echo getmsvc9 Download Visual C++ 9.0 standalone compiler
echo getmsvc10 Download Visual C++ 10.0 standalone SDK
echo getmsvc14 Download Visual C++ 14.0 Build Tools 2015
echo.
echo ExtraPATH:
echo Write new PATH as it is. Separate with ; . No quotes, no ; at the end.
goto end
:check
if defined DEBUG (type "%~dp0msi.log")
if exist "%~dp0python.exe" (
echo %kilog% Python is installed!
echo %kilog% Installing pip...
"%~dp0python.exe" -m ensurepip
)
if defined DEBUG echo [%installkivy%]==[0]
if [%installkivy%]==[0] (
goto end
)
echo %kilog% Preparing Python for Kivy...
"%~dp0python.exe" -m pip install --upgrade pip wheel setuptools
set packages=docutils pygments pypiwin32 requests wget ^
kivy.deps.sdl2 kivy.deps.glew kivy.deps.angle ^
pyinstaller
if defined DEBUG echo [%gstreamer%]==[1]
if [%gstreamer%]==[1] (
"%~dp0python.exe" -m pip install %packages%
"%~dp0python.exe" -m pip install --no-cache-dir kivy.deps.gstreamer
) else (
"%~dp0python.exe" -m pip install %packages%
)
"%~dp0python.exe" -m pip install -U --no-cache-dir https://kivy.org/downloads/appveyor/kivy/Kivy_examples-%master%.dev0-py2.py3-none-any.whl
if defined DEBUG echo [%stable%]==[1]
if [%stable%]==[1] (
"%~dp0python.exe" -m pip uninstall -y kivy
"%~dp0python.exe" -m pip install kivy
if defined DEBUG echo [%designer%]==[1]
if [%designer%]==[1] (
"%~dp0python.exe" -m pip install https://github.com/kivy/kivy-designer/zipball/master
)
goto kivyend
)
mkdir "%~dp0whls"
:: Download nightly wheels from kivy.org FTP [PY]
echo.import os,glob,sys,re,requests,wget,datetime,shutil> "%~dp0getnightly.py"
echo.import os.path as op; import datetime as dt>> "%~dp0getnightly.py"
echo.k = 'Kivy-%master%.dev0-'>> "%~dp0getnightly.py"
echo.w32 = '-win32.whl'>> "%~dp0getnightly.py"
echo.a64 = '-win_amd64.whl'>> "%~dp0getnightly.py"
echo.fid = {>> "%~dp0getnightly.py"
echo. 'cp27_win32': k + 'cp27-cp27m' + w32,>> "%~dp0getnightly.py"
echo. 'cp34_win32': k + 'cp34-cp34m' + w32,>> "%~dp0getnightly.py"
echo. 'cp35_win32': k + 'cp35-cp35m' + w32,>> "%~dp0getnightly.py"
echo. 'cp36_win32': k + 'cp36-cp36m' + w32,>> "%~dp0getnightly.py"
echo. 'cp27_win_amd64': k + 'cp27-cp27m' + a64,>> "%~dp0getnightly.py"
echo. 'cp34_win_amd64': k + 'cp34-cp34m' + a64,>> "%~dp0getnightly.py"
echo. 'cp35_win_amd64': k + 'cp35-cp35m' + a64,>> "%~dp0getnightly.py"
echo. 'cp36_win_amd64': k + 'cp36-cp36m' + a64>> "%~dp0getnightly.py"
echo.}>> "%~dp0getnightly.py"
:: escape % here
echo.y = '{:%%d%%m%%Y}'.format(>> "%~dp0getnightly.py"
echo. dt.datetime.now() - dt.timedelta(days=1)>> "%~dp0getnightly.py"
echo.)>> "%~dp0getnightly.py"
echo.file_id = fid['%cpwhl%_%arch%']>>"%~dp0getnightly.py"
echo.file_name = 'Kivy-%master%.dev0_'>> "%~dp0getnightly.py"
echo.file_name += y + '-%cpwhl%-%cp%-%arch%.whl'>> "%~dp0getnightly.py"
echo.link = 'https://kivy.org/downloads/appveyor/kivy/'>> "%~dp0getnightly.py"
echo.link += file_id>> "%~dp0getnightly.py"
echo.p = op.join(>> "%~dp0getnightly.py"
echo. op.dirname(op.abspath(__file__)),>> "%~dp0getnightly.py"
echo. 'whls', file_name.replace('%cp%', 'none')>> "%~dp0getnightly.py"
echo.)>> "%~dp0getnightly.py"
echo.try:>>"%~dp0getnightly.py"
echo. wget.download(link, p)>> "%~dp0getnightly.py"
echo.except:>>"%~dp0getnightly.py"
echo. with open(p, 'wb') as f:>>"%~dp0getnightly.py"
echo. import ssl>>"%~dp0getnightly.py"
echo. import urllib.request as ulib>>"%~dp0getnightly.py"
echo. f.write(ulib.urlopen(>>"%~dp0getnightly.py"
echo. link,>>"%~dp0getnightly.py"
echo. context=ssl._create_unverified_context()>>"%~dp0getnightly.py"
echo. ).read())>>"%~dp0getnightly.py"
echo.print('\nWheel downloaded...')>> "%~dp0getnightly.py"
echo.root = op.dirname(op.abspath(sys.executable))>> "%~dp0getnightly.py"
echo.whl = op.basename(max(>>"%~dp0getnightly.py"
echo. glob.glob(root + '/whls/*.[Ww][Hh][Ll]*'),>>"%~dp0getnightly.py"
echo. key=op.getctime>>"%~dp0getnightly.py"
echo.))>>"%~dp0getnightly.py"
echo.new = 'Kivy-%master%.dev0-%cpwhl%-none-%arch%.whl'>> "%~dp0getnightly.py"
echo.shutil.copy2(>> "%~dp0getnightly.py"
echo. op.join(root, 'whls', whl),>> "%~dp0getnightly.py"
echo. op.join(root, 'whls', new)>> "%~dp0getnightly.py"
echo.)>> "%~dp0getnightly.py"
"%~dp0python.exe" "%~dp0getnightly.py"
if not defined DEBUG (del "%~dp0getnightly.py")
if defined DEBUG echo [%first%]==[0]
if [%first%]==[0] (
if exist "%~dp0whls\Kivy-%master%.dev0-%cpwhl%-none-%arch%.whl" (
"%~dp0python.exe" -m pip uninstall -y kivy
"%~dp0python.exe" -m pip install "%~dp0whls\Kivy-%master%.dev0-%cpwhl%-none-%arch%.whl"
) else (
echo %kilog% No nightly wheel is available yet!
)
) else (
"%~dp0python.exe" -m pip install "%~dp0whls\Kivy-%master%.dev0-%cpwhl%-none-%arch%.whl"
)
if defined DEBUG echo [%designer%]==[1]
if [%designer%]==[1] (
"%~dp0python.exe" -m pip install https://github.com/kivy/kivy-designer/zipball/master
)
del /q "%~dp0whls\Kivy-%master%.dev0-%cpwhl%-none-%arch%.whl"
:kivyend
if not defined DEBUG (
del /q "%~dp0msi.log"
)
set PATH=%~dp0;%~dp0Tools;%~dp0Scripts;%~dp0share\sdl2\bin;%~dp0Lib\idlelib;%PATH%
:: Check if Kivy can be imported, presume it can't
set has_error=1
"%~dp0python.exe" -c "import kivy" && set has_error=0
if defined DEBUG echo [%has_error%]==[0]
if [%has_error%]==[0] (
if not defined DEBUG (
echo %kilog% Running touchtracer demo...
"%~dp0python.exe" "%~dp0share\kivy-examples\demo\touchtracer\main.py"
)
(echo cp=%cp%) > "%~dp0config.kivyinstaller"
(echo cpwhl=%cpwhl%) >> "%~dp0config.kivyinstaller"
(echo stable=%stable%) >> "%~dp0config.kivyinstaller"
(echo cp2=%cp2%) >> "%~dp0config.kivyinstaller"
(echo cp3=%cp3%) >> "%~dp0config.kivyinstaller"
(echo py3=%py3%) >> "%~dp0config.kivyinstaller"
(echo arch=%arch%) >> "%~dp0config.kivyinstaller"
(echo py2=%py2%) >> "%~dp0config.kivyinstaller"
(echo pyversion=%pyversion%) >> "%~dp0config.kivyinstaller"
(echo gstreamer=%gstreamer%) >> "%~dp0config.kivyinstaller"
(echo master=%master%) >> "%~dp0config.kivyinstaller"
(echo installkivy=%installkivy%) >> "%~dp0config.kivyinstaller"
(echo shrtct=%shrtct%) >> "%~dp0config.kivyinstaller"
(echo admin=%admin%) >> "%~dp0config.kivyinstaller"
if not exist "%~dp0extrapath.kivyinstaller" (
type nul > "%~dp0extrapath.kivyinstaller"
)
echo %kilog% Configuration created in "%~dp0config.kivyinstaller"
) else (
echo %kilog% Kivy was not installed properly!
pause
exit /B 1
)
:mkshortcuts
:: Create a launcher that triggers kivy.bat remotely [BAT]
if defined DEBUG echo [%shortcuts%]==[1]
if [%shortcuts%]==[1] (
(echo @echo off) > "%taskbar%\Kivy%shrtct%.bat"
(echo if "%%~1"=="" ^() >> "%taskbar%\Kivy%shrtct%.bat"
(echo cd "%~dp0") >> "%taskbar%\Kivy%shrtct%.bat"
(echo start "" call "%~dp0%~n0.bat") >> "%taskbar%\Kivy%shrtct%.bat"
(echo ^) else ^() >> "%taskbar%\Kivy%shrtct%.bat"
(echo cd "%~dp0") >> "%taskbar%\Kivy%shrtct%.bat"
(echo start "" call "%~dp0%~n0.bat" "%%~1") >> "%taskbar%\Kivy%shrtct%.bat"
(echo ^)) >> "%taskbar%\Kivy%shrtct%.bat" && type "%taskbar%\Kivy%shrtct%.bat" > "%sendto%\Kivy%shrtct%.bat"
)
goto end
:rmshortcuts
del /q "%sendto%\Kivy%shrtct%.bat"
del /q "%taskbar%\Kivy%shrtct%.bat"
goto end
:installed
if defined DEBUG echo [%1]==[update]
if [%1]==[update] (
set stable=1
goto check
) else if [%1]==[updatemaster] (
set stable=0
goto check
) else if [%1]==[remove] (
"%~dp0python.exe" -m pip uninstall -y kivy
) else if [%1]==[uninstall] (
goto uninstall
) else if [%1]==[batcheck] (
set onlycheck=1
goto batupdate
) else if [%1]==[batupdate] (
set onlycheck=0
goto batupdate
) else if [%1]==[mkshortcuts] (
set shortcuts=1
goto mkshortcuts
) else if [%1]==[rmshortcuts] (
goto rmshortcuts
) else if [%1]==[pack] (
goto pack
) else if [%1]==[getdesigner] (
"%~dp0python.exe" -m pip install -I -U https://github.com/kivy/kivy-designer/zipball/master
goto end
) else if [%1]==[getgcc] (
"%~dp0python.exe" -m pip install -I -U -i https://pypi.anaconda.org/carlkl/simple mingwpy
start "" "https://kivy.org/docs/installation/installation-windows.html#use-development-kivy"
goto end
) else if [%1]==[getmsvc9] (
bitsadmin.exe /transfer "GetVC++" "https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi" "%~dp0VCForPython27.msi"
start %cd%\VCForPython27.msi
goto end
) else if [%1]==[getmsvc10] (
bitsadmin.exe /transfer "GetVC++" "http://download.microsoft.com/download/F/1/0/F10113F5-B750-4969-A255-274341AC6BCE/GRMSDK_EN_DVD.iso" "%~dp0GRMSDK_EN_DVD.iso"
start %cd%\GRMSDK_EN_DVD.iso
goto end
) else if [%1]==[getmsvc14] (
bitsadmin.exe /transfer "GetVC++" "http://go.microsoft.com/fwlink/?LinkId=691126" "%~dp0visualcppbuildtools_full.exe"
start %cd%\visualcppbuildtools_full.exe
start "" "https://git.io/vyyhO"
goto end
) else if [%1]==[help] (
goto help
) else if [%1]==[version] (
goto version
)
set /p extrapath=<"%~dp0extrapath.kivyinstaller"
if defined extrapath (
set new_PATH=%extrapath%;%~dp0;%~dp0Tools;%~dp0Scripts;%~dp0share\sdl2\bin;%~dp0Lib\idlelib
) else (
set new_PATH=%~dp0;%~dp0Tools;%~dp0Scripts;%~dp0share\sdl2\bin;%~dp0Lib\idlelib
)
set PATH=%new_PATH%;%PATH%
echo PATH:
echo %PATH%
if defined DEBUG echo [%1]==[]
if [%1]==[] goto console
echo.
echo %kilog% Running "python.exe %*"
"%~dp0python.exe" %*
if not %errorlevel%==0 (goto end)
:end
pause
exit
:console
echo.
echo ###############################################################################
@if not defined DEBUG (echo off)
"%~dp0python.exe" -c "import sys; print('.'.join(str(x) for x in sys.version_info[:3]))" > t
set /p python_version=<t
set kv_imp=import kivy;f=open('t','w');f.write(kivy
start "" /min /wait "%~dp0python.exe" -c "%kv_imp%.__version__);f.close()"
set /p kivy_version=<t
start "" /min /wait "%~dp0python.exe" -c "%kv_imp%.__date__);f.close()"
set /p wheel_version=<t
del t
echo - KivyInstaller: %installerversion%
echo - Python: %python_version%
echo - Kivy: %kivy_version%
echo - Wheel: %wheel_version%
echo - Update Kivy: %~n0 update or %~n0 updatemaster
echo - Examples: share\kivy-examples
echo - Launch: %~n0 main.py or python main.py
echo - Pack: %~n0 pack "<abs path to .py>"
echo - Uninstall: %~n0 uninstall
echo ###############################################################################
echo.
cmd
exit
:pack
:: Package simple Kivy apps (Standard library + Kivy+GLEW+ANGLE+SDL2+GST) [PY]
if defined DEBUG echo not [%1]==[pack] (
if not [%1]==[pack] (
pause
exit
)
:: Expected: kivy pack "%cd%\share\kivy-examples\demo\touchtracer\main.py"
:: Get .py name, fullpath folder, parent folder (for app name), then build
echo.import os, sys, subprocess> "%~dp0kvpack.py"
echo.from os.path import join, split>> "%~dp0kvpack.py"
echo.folder, main_name = split(sys.argv[1])>> "%~dp0kvpack.py"
echo.name = os.path.split(folder)[-1]>> "%~dp0kvpack.py"
echo.print(os.environ['kilog'] + ' Collecting data...')>> "%~dp0kvpack.py"
echo.subprocess.call([>> "%~dp0kvpack.py"
echo. r'%~dp0python.exe', '-m', 'PyInstaller', '-y',>> "%~dp0kvpack.py"
echo. '--debug', '--name', name, join(folder, main_name)>> "%~dp0kvpack.py"
echo.])>> "%~dp0kvpack.py"
echo.print(os.environ['kilog'] + ' Editing .spec file...')>> "%~dp0kvpack.py"
echo.gl = "from kivy.deps.glew import dep_bins as gl">> "%~dp0kvpack.py"
echo.sd = "from kivy.deps.sdl2 import dep_bins as sd">> "%~dp0kvpack.py"
echo.gs = (>> "%~dp0kvpack.py"
echo. "try:\n ">> "%~dp0kvpack.py"
echo. "from kivy.deps.gstreamer import dep_bins as gs\n">> "%~dp0kvpack.py"
echo. "except ImportError:\n ">> "%~dp0kvpack.py"
echo. "gs = []\n">> "%~dp0kvpack.py"
echo.)>> "%~dp0kvpack.py"
echo.ag = (>> "%~dp0kvpack.py"
echo. "try:\n ">> "%~dp0kvpack.py"
echo. "from kivy.deps.angle import dep_bins as ag\n">> "%~dp0kvpack.py"
echo. "except ImportError:\n ">> "%~dp0kvpack.py"
echo. "ag = []">> "%~dp0kvpack.py"
echo.)>> "%~dp0kvpack.py"
echo.try:>> "%~dp0kvpack.py"
echo. import kivy.deps.gstreamer>> "%~dp0kvpack.py"
echo.except ImportError:>> "%~dp0kvpack.py"
echo. gst = []>> "%~dp0kvpack.py"
echo.try:>> "%~dp0kvpack.py"
echo. import kivy.deps.angle>> "%~dp0kvpack.py"
echo.except ImportError:>> "%~dp0kvpack.py"
echo. ang = []>> "%~dp0kvpack.py"
echo.imp = '\n'.join([gl, sd, gs, ag, 'a = '])>> "%~dp0kvpack.py"
echo.t = "a.datas, *[Tree(p) for p in (gl + sd + gs + ag)],">> "%~dp0kvpack.py"
echo.with open(name + '.spec') as f:>> "%~dp0kvpack.py"
echo. cont = f.read()>> "%~dp0kvpack.py"
echo.n = cont.replace('\na = ', imp).replace('a.datas,', t)>> "%~dp0kvpack.py"
echo.n = n.replace("T(exe,", "T(exe, Tree(r'"+folder+"'),")>> "%~dp0kvpack.py"
echo.with open(name + '.spec', 'w') as f:>> "%~dp0kvpack.py"
echo. f.write(n)>> "%~dp0kvpack.py"
echo.print(os.environ['kilog'] + ' Packaging...')>> "%~dp0kvpack.py"
echo.subprocess.call([>> "%~dp0kvpack.py"
echo. r'%~dp0python.exe', '-m', 'PyInstaller',>> "%~dp0kvpack.py"
echo. name + '.spec', '-y'>> "%~dp0kvpack.py"
echo.])>> "%~dp0kvpack.py"
echo.print(os.environ['kilog'] + ' Done.')>> "%~dp0kvpack.py"
"%~dp0python.exe" "%~dp0kvpack.py" %2
if not defined DEBUG (del "%~dp0kvpack.py")
goto end