-
Notifications
You must be signed in to change notification settings - Fork 8
/
PythonEmbed4Win.ps1
1228 lines (1152 loc) · 60.3 KB
/
PythonEmbed4Win.ps1
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
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!powershell
#
# PythonEmbed4Win.ps1
#
# To run:
#
# PS> Invoke-WebRequest -Uri https://raw.githubusercontent.com/jtmoon79/PythonEmbed4Win/main/PythonEmbed4Win.ps1 -OutFile PythonEmbed4Win.ps1
# PS> Get-Help .\PythonEmbed4Win.ps1 -full
#
<#
.SYNOPSIS
Quickly setup a portable python environment for Windows using an embed.zip.
.DESCRIPTION
Quickly setup a portable self-referential python environment for Windows. No
prior python installation is needed. The python code is downloaded
from the web (https://www.python.org/ftp/python/).
If no -Version is passed then the latest Python version is chosen.
If only Version major.minor passed then chooses latest major.minor.micro version.
e.g. passing "-Version 3.8" will choose Python 3.8.12.
The installation uses the Windows "Embedded" distribution zip file,
e.g. python-3.8.12-embed-amd64.zip
That zip file distribution requires tedious and non-obvious steps.
This script adjusts the installation to be runnable and isolated (removes
references to python paths outside it's own directory).
This script also installs latest pip.
Python 3.6 and later is supported.
-UriCheck is merely a self-test to see which URIs for embed.zip files
are valid.
The installed Python distribution is like a Python Virtual Environment but
technically is not. It does not set environment variable VIRTUAL_ENV nor
modify the PATH.
Users of this installation must call the `python.exe` executable. Do not
call other modules by their script entrypoint,
e.g. for using pip, do not
C:/path/to/embed/Scripts/pip.exe install ...
do
C:/path/to/embed/Scripts/python.exe -m pip install ...
Inspired by this stackoverflow.com question:
https://stackoverflow.com/questions/68958635/python-windows-embeddable-package-fails-to-run-no-module-named-pip-the-system/68958636
BUG: Some embed.zip for a few releases are hardcoded to look for other
Windows Python installations.
For example, if you install Python-3.8.6.msi and then run this script to
install python-3.8.4-embed-amd64.zip, the embed Python 3.8.4 sys.path
will be the confusing paths:
C:\python-embed-3.8.4\python38.zip
C:\python-msi-install-3.8.6\Lib
C:\python-msi-install-3.8.6\DLLs
C:\python-embed-3.8.4
C:\python-msi-install-3.8.6
C:\python-msi-install-3.8.6\lib\site-packages
The python._pth and sitecustomize.py seem to have no affect.
As of November 2023, the latest version of supported Pythons,
3.6 to 3.12, appear to behave correctly. It only affects a few
intermediate releases.
.PARAMETER Version
Version of Python to install. Leave blank to fetch the latest Python.
Can pass major.minor.micro or just major.minor, e.g. "3.8.2" or "3.8".
If passed only major.minor then the latest major.minor.micro will be chosen.
Python 3.6 and later is supported.
.PARAMETER Path
Install to this path. Defaults to a descriptive name.
.PARAMETER Arch
Architecture: win32 or amd64 or arm64. Defaults to the current architecture.
.PARAMETER SkipExec
Do not execute python.exe after installation.
This skips the python.exe self-test and the run of `get-pip.py`.
.PARAMETER UriCheck
Only check pre-filled URIs (script self-test). Does not install Python.
.LINK
https://github.com/jtmoon79/PythonEmbed4Win
.NOTES
Author: James Thomas Moon
#>
[Cmdletbinding(DefaultParameterSetName = 'Install')]
Param (
[Parameter(ParameterSetName = 'Install')]
[System.IO.FileInfo] $Path,
[Parameter(ParameterSetName = 'Install')]
[String] $Version,
# TODO: how to set a script Param to custom Enum type `Archs`?
# placing the definition of `Archs` before this Param declaration
# will cause an error.
[Parameter(ParameterSetName = 'Install')]
[Parameter(ParameterSetName = 'UriCheck')]
[ValidateSet('win32','amd64','arm64')]
[String] $Arch,
[Parameter(ParameterSetName = 'Install')]
[switch] $SkipExec,
[Parameter(ParameterSetName = 'UriCheck')]
[switch] $UriCheck
)
$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch
$stopWatch.Start()
New-Variable -Name SCRIPT_NAME -Value "PythonEmbed4Win.ps1" -Option ReadOnly -Force
$SecurityProtocolType = [Net.SecurityProtocolType]::Tls12
Enum Archs {
# enum names are the literal substrings within the named .zip file
# e.g. "win32" from "python-3.8.12-embed-win32.zip"
win32
amd64
arm64
}
$arch_default = ${env:PROCESSOR_ARCHITECTURE}.ToLower()
New-Variable -Name URI_GETPIP -Option ReadOnly -Force -Value ([URI] "https://bootstrap.pypa.io/get-pip.py")
New-Variable -Name URI_GETPIP36 -Option ReadOnly -Force -Value ([URI] "https://bootstrap.pypa.io/pip/3.6/get-pip.py")
New-Variable -Name URI_PYTHON_VERSIONS -Option ReadOnly -Force -Value ([URI] "https://www.python.org/ftp/python")
function URI-Combine
{
[OutputType([URI])]
Param(
[Parameter(Mandatory=$true)][URI]$uri,
[Parameter(Mandatory=$true)][String]$append
)
return [URI]($uri.ToString() + $append.ToString())
}
# Pre-fill known URIs that exist as of Dec. 2023, i.e. return HTTP 200.
# This allows skipping some work of scraping URIs from the root page and makes
# this script a little faster.
#
# These can be reviewed by passing `-UriCheck` to this script.
$URIs_200 = @(
# win32
URI-Combine $URI_PYTHON_VERSIONS '/3.5.0/python-3.5.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.1/python-3.5.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.2/python-3.5.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.3/python-3.5.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.4/python-3.5.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.0/python-3.6.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.1/python-3.6.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.2/python-3.6.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.3/python-3.6.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.4/python-3.6.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.5/python-3.6.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.6/python-3.6.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.7/python-3.6.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.8/python-3.6.8-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.0/python-3.7.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.1/python-3.7.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.3/python-3.7.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.4/python-3.7.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.5/python-3.7.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.6/python-3.7.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.7/python-3.7.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.8/python-3.7.8-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.9/python-3.7.9-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.0/python-3.8.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.1/python-3.8.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.2/python-3.8.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.3/python-3.8.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.4/python-3.8.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.5/python-3.8.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.6/python-3.8.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.7/python-3.8.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.8/python-3.8.8-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.9/python-3.8.9-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.10/python-3.8.10-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.0/python-3.9.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.1/python-3.9.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.2/python-3.9.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.3/python-3.9.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.4/python-3.9.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.5/python-3.9.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.6/python-3.9.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.7/python-3.9.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.8/python-3.9.8-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.9/python-3.9.9-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.10/python-3.9.10-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.0/python-3.10.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.1/python-3.10.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.2/python-3.10.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.3/python-3.10.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.4/python-3.10.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.5/python-3.10.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.6/python-3.10.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.7/python-3.10.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.8/python-3.10.8-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.9/python-3.10.9-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.10/python-3.10.10-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.11/python-3.10.11-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.0/python-3.11.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.1/python-3.11.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.2/python-3.11.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.3/python-3.11.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.4/python-3.11.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.5/python-3.11.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.6/python-3.11.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.7/python-3.11.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.8/python-3.11.8-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.9/python-3.11.9-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.0/python-3.12.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.1/python-3.12.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.2/python-3.12.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.3/python-3.12.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.4/python-3.12.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.5/python-3.12.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.13.0/python-3.13.0-embed-win32.zip'
# amd64
URI-Combine $URI_PYTHON_VERSIONS '/3.5.0/python-3.5.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.1/python-3.5.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.2/python-3.5.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.3/python-3.5.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.4/python-3.5.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.0/python-3.6.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.1/python-3.6.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.2/python-3.6.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.3/python-3.6.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.4/python-3.6.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.5/python-3.6.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.6/python-3.6.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.7/python-3.6.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.8/python-3.6.8-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.0/python-3.7.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.1/python-3.7.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.3/python-3.7.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.4/python-3.7.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.5/python-3.7.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.6/python-3.7.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.7/python-3.7.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.8/python-3.7.8-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.9/python-3.7.9-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.0/python-3.8.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.1/python-3.8.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.2/python-3.8.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.3/python-3.8.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.4/python-3.8.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.5/python-3.8.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.6/python-3.8.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.7/python-3.8.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.8/python-3.8.8-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.9/python-3.8.9-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.10/python-3.8.10-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.0/python-3.9.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.1/python-3.9.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.2/python-3.9.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.3/python-3.9.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.4/python-3.9.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.5/python-3.9.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.6/python-3.9.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.7/python-3.9.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.8/python-3.9.8-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.9/python-3.9.9-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.11/python-3.9.11-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.12/python-3.9.12-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.13/python-3.9.13-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.10/python-3.9.10-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.0/python-3.10.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.1/python-3.10.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.2/python-3.10.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.3/python-3.10.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.4/python-3.10.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.5/python-3.10.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.6/python-3.10.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.7/python-3.10.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.8/python-3.10.8-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.9/python-3.10.9-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.10/python-3.10.10-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.11/python-3.10.11-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.0/python-3.11.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.1/python-3.11.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.2/python-3.11.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.3/python-3.11.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.4/python-3.11.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.5/python-3.11.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.6/python-3.11.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.7/python-3.11.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.8/python-3.11.8-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.9/python-3.11.9-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.0/python-3.12.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.1/python-3.12.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.2/python-3.12.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.3/python-3.12.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.4/python-3.12.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.5/python-3.12.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.13.0/python-3.13.0-embed-amd64.zip'
# arm64
URI-Combine $URI_PYTHON_VERSIONS '/3.9.7/python-3.9.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.8/python-3.9.8-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.9/python-3.9.9-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.10/python-3.9.10-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.0/python-3.10.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.1/python-3.10.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.0/python-3.11.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.1/python-3.11.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.2/python-3.11.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.3/python-3.11.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.4/python-3.11.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.5/python-3.11.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.6/python-3.11.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.7/python-3.11.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.8/python-3.11.8-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.9/python-3.11.9-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.0/python-3.12.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.11.1/python-3.11.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.2/python-3.12.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.3/python-3.12.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.4/python-3.12.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.5/python-3.12.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.6/python-3.12.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.12.7/python-3.12.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.13.0/python-3.13.0-embed-arm64.zip'
)
# Pre-fill known URIs that do not exist as of Dec. 2023, i.e. return HTTP 404 or 503.
$URIs_503 = @(
# win32
URI-Combine $URI_PYTHON_VERSIONS '/3.0.1/python-3.0.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.1/python-3.1.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.2/python-3.1.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.3/python-3.1.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.4/python-3.1.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.5/python-3.1.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.1/python-3.2.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.2/python-3.2.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.3/python-3.2.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.4/python-3.2.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.5/python-3.2.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.6/python-3.2.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.0/python-3.3.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.1/python-3.3.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.2/python-3.3.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.3/python-3.3.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.4/python-3.3.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.5/python-3.3.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.6/python-3.3.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.7/python-3.3.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.0/python-3.4.0-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.1/python-3.4.1-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.2/python-3.4.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.3/python-3.4.3-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.4/python-3.4.4-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.5/python-3.4.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.6/python-3.4.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.7/python-3.4.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.8/python-3.4.8-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.9/python-3.4.9-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.10/python-3.4.10-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.5/python-3.5.5-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.6/python-3.5.6-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.7/python-3.5.7-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.8/python-3.5.8-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.9/python-3.5.9-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.10/python-3.5.10-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.9/python-3.6.9-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.10/python-3.6.10-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.11/python-3.6.11-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.12/python-3.6.12-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.13/python-3.6.13-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.14/python-3.6.14-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.15/python-3.6.15-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.2/python-3.7.2-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.10/python-3.7.10-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.11/python-3.7.11-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.12/python-3.7.12-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.11/python-3.8.11-embed-win32.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.12/python-3.8.12-embed-win32.zip'
# amd64
URI-Combine $URI_PYTHON_VERSIONS '/3.0.1/python-3.0.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.1/python-3.1.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.2/python-3.1.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.3/python-3.1.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.4/python-3.1.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.5/python-3.1.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.1/python-3.2.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.2/python-3.2.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.3/python-3.2.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.4/python-3.2.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.5/python-3.2.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.6/python-3.2.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.0/python-3.3.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.1/python-3.3.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.2/python-3.3.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.3/python-3.3.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.4/python-3.3.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.5/python-3.3.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.6/python-3.3.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.7/python-3.3.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.0/python-3.4.0-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.1/python-3.4.1-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.2/python-3.4.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.3/python-3.4.3-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.4/python-3.4.4-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.5/python-3.4.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.6/python-3.4.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.7/python-3.4.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.8/python-3.4.8-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.9/python-3.4.9-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.10/python-3.4.10-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.5/python-3.5.5-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.6/python-3.5.6-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.7/python-3.5.7-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.8/python-3.5.8-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.9/python-3.5.9-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.10/python-3.5.10-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.9/python-3.6.9-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.10/python-3.6.10-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.11/python-3.6.11-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.12/python-3.6.12-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.13/python-3.6.13-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.14/python-3.6.14-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.15/python-3.6.15-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.2/python-3.7.2-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.10/python-3.7.10-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.11/python-3.7.11-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.12/python-3.7.12-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.13/python-3.7.13-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.14/python-3.7.14-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.15/python-3.7.15-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.16/python-3.7.16-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.17/python-3.7.17-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.11/python-3.8.11-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.12/python-3.8.12-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.13/python-3.8.13-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.14/python-3.8.14-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.15/python-3.8.15-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.16/python-3.8.16-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.17/python-3.8.17-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.18/python-3.8.18-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.14/python-3.9.14-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.15/python-3.9.15-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.16/python-3.9.16-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.17/python-3.9.17-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.18/python-3.9.18-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.12/python-3.10.12-embed-amd64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.13/python-3.10.13-embed-amd64.zip'
# arm64
URI-Combine $URI_PYTHON_VERSIONS '/3.0.1/python-3.0.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.1/python-3.1.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.2/python-3.1.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.3/python-3.1.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.4/python-3.1.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.1.5/python-3.1.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.1/python-3.2.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.2/python-3.2.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.3/python-3.2.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.4/python-3.2.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.5/python-3.2.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.2.6/python-3.2.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.0/python-3.3.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.1/python-3.3.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.2/python-3.3.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.3/python-3.3.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.4/python-3.3.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.5/python-3.3.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.6/python-3.3.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.3.7/python-3.3.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.0/python-3.4.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.1/python-3.4.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.2/python-3.4.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.3/python-3.4.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.4/python-3.4.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.5/python-3.4.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.6/python-3.4.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.7/python-3.4.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.8/python-3.4.8-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.9/python-3.4.9-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.4.10/python-3.4.10-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.0/python-3.5.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.1/python-3.5.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.2/python-3.5.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.3/python-3.5.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.4/python-3.5.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.5/python-3.5.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.6/python-3.5.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.7/python-3.5.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.8/python-3.5.8-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.9/python-3.5.9-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.5.10/python-3.5.10-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.0/python-3.6.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.1/python-3.6.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.2/python-3.6.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.3/python-3.6.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.4/python-3.6.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.5/python-3.6.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.6/python-3.6.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.7/python-3.6.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.8/python-3.6.8-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.9/python-3.6.9-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.10/python-3.6.10-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.11/python-3.6.11-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.12/python-3.6.12-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.13/python-3.6.13-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.14/python-3.6.14-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.6.15/python-3.6.15-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.0/python-3.7.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.1/python-3.7.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.2/python-3.7.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.3/python-3.7.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.4/python-3.7.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.5/python-3.7.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.6/python-3.7.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.7/python-3.7.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.8/python-3.7.8-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.9/python-3.7.9-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.10/python-3.7.10-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.11/python-3.7.11-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.12/python-3.7.12-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.13/python-3.7.13-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.14/python-3.7.14-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.15/python-3.7.15-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.16/python-3.7.16-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.7.17/python-3.7.17-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.0/python-3.8.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.1/python-3.8.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.2/python-3.8.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.3/python-3.8.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.4/python-3.8.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.5/python-3.8.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.6/python-3.8.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.7/python-3.8.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.8/python-3.8.8-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.9/python-3.8.9-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.10/python-3.8.10-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.11/python-3.8.11-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.12/python-3.8.12-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.13/python-3.8.13-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.14/python-3.8.14-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.15/python-3.8.15-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.16/python-3.8.16-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.17/python-3.8.17-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.18/python-3.8.18-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.19/python-3.8.19-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.8.20/python-3.8.20-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.0/python-3.9.0-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.1/python-3.9.1-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.2/python-3.9.2-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.3/python-3.9.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.4/python-3.9.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.5/python-3.9.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.6/python-3.9.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.11/python-3.9.11-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.12/python-3.9.12-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.13/python-3.9.13-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.14/python-3.9.14-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.15/python-3.9.15-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.16/python-3.9.16-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.17/python-3.9.17-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.18/python-3.9.18-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.19/python-3.9.19-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.9.20/python-3.9.20-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.3/python-3.10.3-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.4/python-3.10.4-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.5/python-3.10.5-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.6/python-3.10.6-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.7/python-3.10.7-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.8/python-3.10.8-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.9/python-3.10.9-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.10/python-3.10.10-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.11/python-3.10.11-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.12/python-3.10.12-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.13/python-3.10.13-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.14/python-3.10.14-embed-arm64.zip'
URI-Combine $URI_PYTHON_VERSIONS '/3.10.15/python-3.10.15-embed-arm64.zip'
)
function New-TemporaryDirectory {
[OutputType([System.IO.FileInfo])]
Param([String]$extra)
Join-Path -Path $([System.IO.Path]::GetTempPath()) -ChildPath $extra.ToString() `
| ForEach-Object { New-Item -Path $_ -ItemType Directory -Force }
}
function Print-File-Nicely {
<#
.SYNOPSIS
Print a file for easy grok.
#>
Param([System.IO.FileInfo]$path)
Write-Host -ForegroundColor Yellow `
"File:" $path "`n"
$text = Get-Content $path -Raw
$textt = "`t" + $text.Replace("`n", "`n`t").TrimEnd("`t")
Write-Host -ForegroundColor Yellow $textt
}
function Invoke-WebRequest-Head {
<#
.SYNOPSIS
Wrapper to call `Invoke-WebRequest` using HTTP Method HEAD,
adjusted to the running version of PowerShell.
#>
Param(
[Parameter(Mandatory=$true)][URI]$uri
)
if (7 -le $PSVersionTable.PSVersion.Major) {
# XXX: not entirely sure precisely which Powershell version introduced
# the `-SkipHTTPErrorCheck` parameter.
$result = Invoke-WebRequest -Uri $uri -Method Head -SkipHTTPErrorCheck
} else {
try {
# if the HTTP Status Code is >=400 then this always raises an error
# even if passed `-ErrorAction SilentlyContinue`. So it must be
# handled specially.
$result = Invoke-WebRequest -Uri $uri -Method Head
} catch {
$result = [PSCustomObject]@{
StatusCode = 500
StatusDescription = "BAD"
}
}
}
return $result
}
function Download
{
<#
.SYNOPSIS
download file at $uri to $dest, note the time taken
#>
Param(
[Parameter(Mandatory=$true)][URI]$uri,
[Parameter(Mandatory=$true)][System.IO.FileInfo]$dest
)
$start_time = Get-Date
[Net.ServicePointManager]::SecurityProtocol = $SecurityProtocolType
$ProgressPreference = 'SilentlyContinue'
$wr1 = Invoke-WebRequest -Uri $uri -OutFile $dest
# BUG: why does Invoke-WebRequest sometimes return no object!?
$sc = "URI "
if ($wr1) {
$sc = "URI " + $wr1.StatusCode.ToString() + " "
}
Write-Host ($sc + $uri.ToString() + " downloaded to temporary directory " + $dest)
Write-Verbose "Downloaded time: $((Get-Date).Subtract($start_time).Seconds) second(s)"
}
function Confirm-URI
{
<#
.SYNOPSIS
confirm URI exists by sending HTTP HEAD request
return $True if HTTP StatusCode == 200 else $False
#>
[OutputType([Bool])]
Param(
[Parameter(Mandatory=$true)][URI]$uri,
[Parameter(Mandatory=$false)][Bool]$printResult=$false
)
[Net.ServicePointManager]::SecurityProtocol = $SecurityProtocolType
$ProgressPreference = 'SilentlyContinue'
$wr1 = Invoke-WebRequest-Head -Uri $uri
if ($wr1.StatusCode -eq 200) {
if ($printResult) {
Write-Host ("URI " + $uri.ToString() + " returned " + $wr1.StatusCode.ToString()) -ForegroundColor Green
}
return $True
}
if ($printResult) {
Write-Host ("URI " + $uri.ToString() + " returned " + $wr1.StatusCode.ToString()) -ForegroundColor Red
}
return $False
}
function Confirm-URI-Python-Version
{
<#
.SYNOPSIS
confirm the URI for a python zip file exists
first check known hardcoded URIs then do Confirm-URI $uri
if -onlyLive then skip known hardcoded URIs (check them online)
#>
[OutputType([Bool])]
Param(
[Parameter(Mandatory=$true)][URI]$uri,
[Parameter(Mandatory=$false)][Bool]$onlyLive=$false
)
# first check hardcoded known URIs
if (($URIs_200.Contains($uri.ToString())) -and (-not $onlyLive)) {
Write-Verbose "URI known to exist ${uri}"
return $True
} elseif (($URIs_503.Contains($uri.ToString())) -and (-not $onlyLive)) {
Write-Verbose "URI known to not exist ${uri}"
return $False
}
# check live URI
Write-Verbose "URI must be checked ${uri}"
return Confirm-URI $uri $onlyLive
}
function Create-Python-Zip-Name
{
<#
.SYNOPSIS
return String of python embed.zip file name
e.g. "python-3.8.2-embed-amd64.zip"
#>
[OutputType([String])]
Param
(
[Parameter(Mandatory=$true)][System.Version]$version,
[Parameter(Mandatory=$true)][Archs]$arch
)
return "python-" + $version.ToString() + "-embed-" + $arch.ToString() + ".zip"
}
function Create-Python-Zip-URI
{
<#
.SYNOPSIS
return URI for the Python embed.zip
example URI of embed .zip
https://www.python.org/ftp/python/3.8.2/python-3.8.2-embed-amd64.zip
#>
[OutputType([URI])]
Param
(
[Parameter(Mandatory=$true)][URI]$base_uri,
[Parameter(Mandatory=$true)][System.Version]$version,
[Parameter(Mandatory=$true)][Archs]$arch
)
# $version_scraped the version number, e.g. '3.8.10'
$filename = Create-Python-Zip-Name $version $arch
# $filename e.g. 'python-3.8.2-embed-amd64.zip'
# XXX: [URI] does not have an append method? disappoint.
$uri_file = [URI]($base_uri.ToString() + '/' + $version.ToString() + '/' + $filename)
# e.g. 'https://www.python.org/ftp/python/3.8.2/python-3.8.2-embed-amd64.zip'
return $uri_file
}
function Scrape-Python-Versions
{
<#
.SYNOPSIS
Scrape the Python versions HTML page for all archived Python builds among
versions, do HTTP HEAD to check if the associated embed.zip file exists.
return Hashtable{[System.Version]$version, [URI]$URI_zip}
#>
[OutputType([System.Collections.Hashtable])]
Param
(
[Parameter(Mandatory=$true)][URI]$uri,
[Parameter(Mandatory=$true)][System.IO.DirectoryInfo]$path_tmp,
[Parameter(Mandatory=$true)][Archs]$arch_install,
[Parameter()][AllowNull()][System.Version]$version_filter=$null,
[Parameter()][Bool]$onlyLive=$false
)
Write-Verbose ("Scraping all available versions of Python at " + $uri.ToString())
$python_versions_html = [System.IO.FileInfo] (Join-Path -Path $path_tmp -ChildPath "python_versions.html")
if(-not (Test-Path $python_versions_html))
{
Download $uri $python_versions_html
}
# example snippet of the HTML with listed versions (https://www.python.org/ftp/python/)
#
# <a href="2.3.3/">2.3.3/</a> 20-Mar-2014 21:57 -
# <a href="2.3.4/">2.3.4/</a> 20-Mar-2014 21:57 -
# <a href="2.3.5/">2.3.5/</a> 20-Mar-2014 21:58 -
# <a href="2.3.6/">2.3.6/</a> 01-Nov-2006 07:25 -
# <a href="2.3.7/">2.3.7/</a> 20-Mar-2014 21:58 -
# ...
# <a href="3.9.2/">3.9.2/</a> 19-Feb-2021 14:44 -
# <a href="3.9.3/">3.9.3/</a> 02-Apr-2021 13:10 -
#
# TODO: consider using built-in HTML parser instead of regexp scraping
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.2#example-3--get-links-from-a-web-page
#
# scrape the versions
$versions_scraped = New-Object Collections.Generic.List[System.Version]
foreach(
$m1 in Select-String -CaseSensitive -Pattern '\<a href="[345]\.\d+\.\d+/"\>' -Path $python_versions_html
) {
$m2 = $m1.Matches.value | Select-String -Pattern '"(.*)"'
if ( $m2.Matches.Groups.Length -lt 2 ) {
continue
}
$subdir = $m2.Matches.Groups[1].value
# $subdir e.g. '3.8.10/'
$m3 = $subdir | Select-String -Pattern '[345]\.\d+\.\d+'
if ($m3.Matches.Length -lt 1) {
continue
}
$version_scraped = $m3.Matches.Value
# $version_scraped the version number, e.g. '3.8.10'
$py_version = [System.Version]$version_scraped
Write-Verbose "scraped version '$version_scraped'"
$versions_scraped.Add($py_version)
}
$versions_scraped.sort()
# check which scraped versions are valid URIs
$links = [System.Collections.Hashtable]::new()
foreach ($py_version in $versions_scraped) {
if ($null -ne $version_filter) {
# only check within the passed filter
if (($version_filter.Build -ne -1)) {
if (($version_filter.Major -ne $py_version.Major) -or `
($version_filter.Minor -ne $py_version.Minor) -or `
($version_filter.Build -ne $py_version.Build) `
) {
Write-Verbose "Skip confirming $py_version; not within filter $version_filter (M,m,b)"
continue
}
} elseif ($version_filter.Minor -ne -1) {
if (($version_filter.Major -ne $py_version.Major) -or `
($version_filter.Minor -ne $py_version.Minor)`
) {
Write-Verbose "Skip confirming $py_version; not within filter $version_filter (M,m)"
continue
}
} elseif ($version_filter.Major -ne -1) {
if ($version_filter.Major -ne $py_version.Major) {
Write-Verbose "Skip confirming $py_version; not within filter $version_filter (M)"
continue
}
} else {
Write-Warning "Bad version filter $version_filter"
}
}
Write-Verbose "Confirming scrape $py_version ..."
$uri_file = Create-Python-Zip-URI $URI_PYTHON_VERSIONS $py_version $arch_install
if (Confirm-URI-Python-Version $uri_file -onlyLive $onlyLive) {
Write-Verbose "Add link '$uri_file'"
$links.Add($py_version, $uri_file)
}
}
return $links
}
function Check-Premade-Uris
{
<#
.SYNOPSIS
Check built-in URIs for expected HTTP Status Codes
Only meant to aid self-testing this script.
#>
Param
(
[Parameter(Mandatory=$true)][Archs]$arch_install
)
Write-Host "Check expected good URIs for" $arch_install.ToString()
foreach ($uri in $URIs_200) {
if (-not ($uri.ToString().Contains($arch_install.ToString())))
{
continue
}
if ($wr1 = Invoke-WebRequest-Head -Uri $uri) {
if ($wr1.StatusCode -eq 200) {
Write-Host ("URI " + $uri.ToString() + " returned " + $wr1.StatusCode.ToString() + " (expected 200)") -ForegroundColor Green
} else {
Write-Host ("URI " + $uri.ToString() + " returned " + $wr1.StatusCode.ToString() + " (not expected)") -ForegroundColor Red
}
}
}
Write-Host "Check expected bad URIs for" $arch_install.ToString() "(scraped URIs that lead to invalid data)"
foreach ($uri in $URIs_503) {
if (-not ($uri.ToString().Contains($arch_install.ToString())))
{
continue
}
if ($wr1 = Invoke-WebRequest-Head -Uri $uri) {
if ($wr1.StatusCode -ge 400) {
Write-Host ("URI " + $uri.ToString() + " returned " + $wr1.StatusCode.ToString() + " (expected ≥400)") -ForegroundColor Green
} else {
Write-Host ("URI " + $uri.ToString() + " returned " + $wr1.StatusCode.ToString() + " (not expected)") -ForegroundColor Red
}
}
}
}
function Process-Python-Zip
{
<#
.SYNOPSIS
Given the downloaded python zip file $python_zip, install it to
$path_install.
BUG: interleaved Write-host and python.exe stdout occurs here
#>
Param
(
[Parameter(Mandatory=$true)][System.IO.FileInfo]$path_zip,
[Parameter(Mandatory=$true)][System.IO.FileInfo]$path_install,
[Parameter(Mandatory=$true)][System.Version]$ver,
[Parameter(Mandatory=$true)][bool]$skip_exec
)
# if $path_install does not exist this will raise
$path_install = Join-Path $path_install -ChildPath "" -Resolve
Expand-Archive $path_zip_tmp -DestinationPath $path_install
#
# do tedious operations within the $PWD of the recently unzipped Python environment
#
Push-Location -Path $path_install
# 1a. not all versions of embed.zip have this directory
# e.g. https://www.python.org/ftp/python/3.8.4/python-3.8.4-embed-amd64.zip
New-Item -type Directory "Lib/site-packages"
# 1b. the downloaded zip file contains a zip file, python39.zip. Unzip that
# to under `Lib/`.
$pythonzip = Get-ChildItem -File -Filter "python*.zip" -Depth 1
Write-Host -ForegroundColor Yellow "Unzip" $pythonzip
Expand-Archive $pythonzip -DestinationPath "Lib/python_zip"
Remove-Item -Path $pythonzip
# 2. set python._pth file
$pythonpth = Get-ChildItem -File -Filter "python*._pth" -Depth 1
if($null -eq $pythonpth) {
$pythonpth = ".\python._pth"
}
$content_pythonpth = "# python._pth
#
# this file was added by PythonEmbed4Win.ps1
.\Lib\python_zip
.\DLLs
.\Lib
.\Scripts
.
.\Lib\site-packages
".Replace("`r`n", "`n")
# use -Encoding 'ascii'; 'utf8' will prepend UTF8 BOM which is seen by Python
# as a path (and Python then adds a junk path to `sys.path`)
$content_pythonpth | Out-File -Force -FilePath $pythonpth -Encoding "ascii"
Print-File-Nicely $pythonpth
# 3. set sitecustomize.py
$python_site_path = Join-Path -Path "." -ChildPath "sitecustomize.py"
$content_sitecustomize = "# sitecustomize.py
#
# this file was added by PythonEmbed4Win.ps1
import os
import site
import sys
# do not use user-wide site.USER_SITE path; it refers to a path location
# outside of this embed installation
site.ENABLE_USER_SITE = False
# remove site.USER_SITE and the realpath variation from sys.path
# XXX: somewhat time consuming to do on every startup but thorough
__sys_path_index_del = list()
`"`"`"index to delete from sys.path`"`"`"
__user_site_resolve = os.path.realpath(site.USER_SITE)
for __i, __path in enumerate(sys.path):
__path_resolve = os.path.realpath(__path)
if site.USER_SITE in (__path, __path_resolve):
__sys_path_index_del.append(__i)
continue
if __user_site_resolve in (__path, __path_resolve):
__sys_path_index_del.append(__i)
for __index_del in reversed(__sys_path_index_del):
sys.path.pop(__index_del)
del __sys_path_index_del
del __user_site_resolve
".Replace("`r`n", "`n")
# use 'ascii' encoding, see above
$content_sitecustomize | Out-File -FilePath $python_site_path -Encoding "ascii"
Print-File-Nicely $python_site_path
# 5. set `pip.ini`
$python_pip_ini = Join-Path -Path "." -ChildPath "pip.ini"
$content_pip_ini = "# pip.ini
#
# this file was added by PythonEmbed4Win.ps1
[install]
# this embed installation does not add itself to the shell environment PATH; do not warn about that
no-warn-script-location = true
".Replace("`r`n", "`n")
# use 'ascii' encoding, see above
$content_pip_ini | Out-File -FilePath $python_pip_ini -Encoding "ascii"
Print-File-Nicely $python_pip_ini
# 6. create empty directory DLLs
$python_DLL_path = Join-Path -Path "." -ChildPath "DLLs"
Write-Host -ForegroundColor Yellow "Create Directory" $python_DLL_path
New-Item -type directory $python_DLL_path
# 7. basic tests that python can run