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
3

Q'íc­Ÿã@sdZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZej
ƒdkrpddl	mZejZnGd	d
„d
ƒZeƒZeejjfZyddlmZWnek
r´YnXdd
„Zd dd„Zdd„Zdd„Zd!dd„ZGdd„dƒZGdd„dƒZGdd„dƒZGdd„dƒZ dS)"a@
Improved support for Microsoft Visual C++ compilers.

Known supported compilers:
--------------------------
Microsoft Visual C++ 9.0:
    Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64)
    Microsoft Windows SDK 6.1 (x86, x64, ia64)
    Microsoft Windows SDK 7.0 (x86, x64, ia64)

Microsoft Visual C++ 10.0:
    Microsoft Windows SDK 7.1 (x86, x64, ia64)

Microsoft Visual C++ 14.0:
    Microsoft Visual C++ Build Tools 2015 (x86, x64, arm)
    Microsoft Visual Studio 2017 (x86, x64, arm, arm64)
    Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64)
éN)Ú
LegacyVersion)Úfilterfalseé)Ú
get_unpatchedÚWindows)Úwinregc@seZdZdZdZdZdZdS)rN)Ú__name__Ú
__module__Ú__qualname__Ú
HKEY_USERSÚHKEY_CURRENT_USERÚHKEY_LOCAL_MACHINEÚHKEY_CLASSES_ROOT©rrú5/tmp/pip-build-l_bcah40/setuptools/setuptools/msvc.pyr(sr)ÚRegcCsžd}|d|f}ytj|dƒ}WnJtk
rjy|d|f}tj|dƒ}Wntk
rdd}YnXYnX|r’tjjjj|dƒ}tjj|ƒr’|Sttƒ|ƒS)a+
    Patched "distutils.msvc9compiler.find_vcvarsall" to use the standalone
    compiler build for Python (VCForPython). Fall back to original behavior
    when the standalone compiler is not available.

    Redirect the path of "vcvarsall.bat".

    Known supported compilers
    -------------------------
    Microsoft Visual C++ 9.0:
        Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64)

    Parameters
    ----------
    version: float
        Required Microsoft Visual C++ version.

    Return
    ------
    vcvarsall.bat path: str
    z-Software\%sMicrosoft\DevDiv\VCForPython\%0.1fÚÚ
installdirzWow6432Node\Nz
vcvarsall.bat)	rÚ	get_valueÚKeyErrorÚosÚpathÚjoinÚisfilerÚmsvc9_find_vcvarsall)ÚversionZVC_BASEÚkeyÚ
productdirÚ	vcvarsallrrrr?srÚx86cOsŽyttƒ}|||f|ž|ŽStjjk
r2Yntk
rDYnXyt||ƒjƒStjjk
rˆ}zt|||ƒ‚WYdd}~XnXdS)aœ
    Patched "distutils.msvc9compiler.query_vcvarsall" for support extra
    compilers.

    Set environment without use of "vcvarsall.bat".

    Known supported compilers
    -------------------------
    Microsoft Visual C++ 9.0:
        Microsoft Visual C++ Compiler for Python 2.7 (x86, amd64)
        Microsoft Windows SDK 6.1 (x86, x64, ia64)
        Microsoft Windows SDK 7.0 (x86, x64, ia64)

    Microsoft Visual C++ 10.0:
        Microsoft Windows SDK 7.1 (x86, x64, ia64)

    Parameters
    ----------
    ver: float
        Required Microsoft Visual C++ version.
    arch: str
        Target architecture.

    Return
    ------
    environment: dict
    N)	rÚmsvc9_query_vcvarsallÚ	distutilsÚerrorsÚDistutilsPlatformErrorÚ
ValueErrorÚEnvironmentInfoÚ
return_envÚ_augment_exception)ÚverÚarchÚargsÚkwargsÚorigÚexcrrrr jsr cCsnyttƒ|ƒStjjk
r$YnXyt|ddjƒStjjk
rh}zt|dƒ‚WYdd}~XnXdS)a'
    Patched "distutils._msvccompiler._get_vc_env" for support extra
    compilers.

    Set environment without use of "vcvarsall.bat".

    Known supported compilers
    -------------------------
    Microsoft Visual C++ 14.0:
        Microsoft Visual C++ Build Tools 2015 (x86, x64, arm)
        Microsoft Visual Studio 2017 (x86, x64, arm, arm64)
        Microsoft Visual Studio Build Tools 2017 (x86, x64, arm, arm64)

    Parameters
    ----------
    plat_spec: str
        Target architecture.

    Return
    ------
    environment: dict
    g,@)Ú
vc_min_verN)rÚmsvc14_get_vc_envr!r"r#r%r&r')Z	plat_specr-rrrr/™s
r/cOsBdtjkr4ddl}t|jƒtdƒkr4|jjj||ŽStt	ƒ||ŽS)z¦
    Patched "distutils._msvccompiler.gen_lib_options" for fix
    compatibility between "numpy.distutils" and "distutils._msvccompiler"
    (for Numpy < 1.11.2)
    znumpy.distutilsrNz1.11.2)
ÚsysÚmodulesZnumpyrÚ__version__r!Z	ccompilerZgen_lib_optionsrÚmsvc14_gen_lib_options)r*r+Únprrrr3¿s

r3rcCs¬|jd}d|jƒks"d|jƒkr d}|jftƒŽ}d}|dkrr|jƒjdƒdkrh|d	7}||d
7}q |d7}n.|dkr|d
7}||d7}n|dkr |d7}|f|_dS)zl
    Add details to the exception message to help guide the user
    as to what action will resolve it.
    rrzvisual cz0Microsoft Visual C++ {version:0.1f} is required.z-www.microsoft.com/download/details.aspx?id=%dg"@Zia64rz* Get it with "Microsoft Windows SDK 7.0": iBz% Get it from http://aka.ms/vcpython27g$@z* Get it with "Microsoft Windows SDK 7.1": iW g,@zj Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-toolsNéÿÿÿÿ)r*ÚlowerÚformatÚlocalsÚfind)r-rr)ÚmessageÚtmplZ
msdownloadrrrr'Ìs 

r'c@sbeZdZdZejddƒjƒZdd„Ze	dd„ƒZ
dd	„Zd
d„Zdd
d„Z
ddd„Zddd„ZdS)ÚPlatformInfoz‚
    Current and Target Architectures informations.

    Parameters
    ----------
    arch: str
        Target architecture.
    Zprocessor_architecturercCs|jƒjddƒ|_dS)NÚx64Úamd64)r6Úreplacer))Úselfr)rrrÚ__init__üszPlatformInfo.__init__cCs|j|jjdƒdd…S)NÚ_r)r)r9)r@rrrÚ
target_cpuÿszPlatformInfo.target_cpucCs
|jdkS)Nr)rC)r@rrrÚ
target_is_x86szPlatformInfo.target_is_x86cCs
|jdkS)Nr)Úcurrent_cpu)r@rrrÚcurrent_is_x86szPlatformInfo.current_is_x86FcCs.|jdkr|rdS|jdkr$|r$dSd|jS)uk
        Current platform specific subfolder.

        Parameters
        ----------
        hidex86: bool
            return '' and not '†' if architecture is x86.
        x64: bool
            return 'd' and not 'md64' if architecture is amd64.

        Return
        ------
        subfolder: str
            '	arget', or '' (see hidex86 parameter)
        rrr>z\x64z\%s)rE)r@Úhidex86r=rrrÚcurrent_dir	szPlatformInfo.current_dircCs.|jdkr|rdS|jdkr$|r$dSd|jS)ar
        Target platform specific subfolder.

        Parameters
        ----------
        hidex86: bool
            return '' and not '\x86' if architecture is x86.
        x64: bool
            return '\x64' and not '\amd64' if architecture is amd64.

        Return
        ------
        subfolder: str
            '\current', or '' (see hidex86 parameter)
        rrr>z\x64z\%s)rC)r@rGr=rrrÚ
target_dirszPlatformInfo.target_dircCs0|rdn|j}|j|krdS|jƒjdd|ƒS)ao
        Cross platform specific subfolder.

        Parameters
        ----------
        forcex86: bool
            Use 'x86' as current architecture even if current acritecture is
            not x86.

        Return
        ------
        subfolder: str
            '' if target architecture is current architecture,
            '\current_target' if not.
        rrú\z\%s_)rErCrIr?)r@Úforcex86ÚcurrentrrrÚ	cross_dir5szPlatformInfo.cross_dirN)FF)FF)F)rr	r
Ú__doc__Úsafe_envÚgetr6rErAÚpropertyrCrDrFrHrIrMrrrrr<ñs

r<c@sªeZdZdZejejejejfZ	dd„Z
edd„ƒZedd„ƒZ
edd	„ƒZed
d„ƒZedd
„ƒZedd„ƒZedd„ƒZedd„ƒZedd„ƒZddd„Zdd„ZdS)ÚRegistryInfoz 
    Microsoft Visual Studio related registry informations.

    Parameters
    ----------
    platform_info: PlatformInfo
        "PlatformInfo" instance.
    cCs
||_dS)N)Úpi)r@Z
platform_inforrrrAZszRegistryInfo.__init__cCsdS)z<
        Microsoft Visual Studio root registry key.
        ZVisualStudior)r@rrrÚvisualstudio]szRegistryInfo.visualstudiocCstjj|jdƒS)z;
        Microsoft Visual Studio SxS registry key.
        ZSxS)rrrrT)r@rrrÚsxsdszRegistryInfo.sxscCstjj|jdƒS)z8
        Microsoft Visual C++ VC7 registry key.
        ZVC7)rrrrU)r@rrrÚvckszRegistryInfo.vccCstjj|jdƒS)z;
        Microsoft Visual Studio VS7 registry key.
        ZVS7)rrrrU)r@rrrÚvsrszRegistryInfo.vscCsdS)z?
        Microsoft Visual C++ for Python registry key.
        zDevDiv\VCForPythonr)r@rrrÚ
vc_for_pythonyszRegistryInfo.vc_for_pythoncCsdS)z-
        Microsoft SDK registry key.
        zMicrosoft SDKsr)r@rrrÚ
microsoft_sdk€szRegistryInfo.microsoft_sdkcCstjj|jdƒS)z>
        Microsoft Windows/Platform SDK registry key.
        r)rrrrY)r@rrrÚwindows_sdk‡szRegistryInfo.windows_sdkcCstjj|jdƒS)z<
        Microsoft .NET Framework SDK registry key.
        ZNETFXSDK)rrrrY)r@rrrÚ	netfx_sdkŽszRegistryInfo.netfx_sdkcCsdS)z<
        Microsoft Windows Kits Roots registry key.
        zWindows Kits\Installed Rootsr)r@rrrÚwindows_kits_roots•szRegistryInfo.windows_kits_rootsFcCs(|jjƒs|rdnd}tjjd|d|ƒS)a

        Return key in Microsoft software registry.

        Parameters
        ----------
        key: str
            Registry key path where look.
        x86: str
            Force x86 software registry.

        Return
        ------
        str: value
        rZWow6432NodeZSoftwareÚ	Microsoft)rSrFrrr)r@rrZnode64rrrÚ	microsoftœszRegistryInfo.microsoftcCsÂtj}tj}|j}xª|jD] }y||||ƒd|ƒ}WnZttfk
rŽ|jjƒsˆy||||dƒd|ƒ}WqŠttfk
r„wYqŠXnwYnXytj	||ƒdSttfk
r¸YqXqWdS)a
        Look for values in registry in Microsoft software registry.

        Parameters
        ----------
        key: str
            Registry key path where look.
        name: str
            Value name to find.

        Return
        ------
        str: value
        rTN)
rÚKEY_READÚOpenKeyr^ÚHKEYSÚOSErrorÚIOErrorrSrFÚQueryValueEx)r@rÚnamer_ZopenkeyÚmsÚhkeyÚbkeyrrrÚlookup®s"

zRegistryInfo.lookupN)F)rr	r
rNrrrr
rrarArQrTrUrVrWrXrYrZr[r\r^rirrrrrRLs"
rRc@s$eZdZdZejddƒZejddƒZejdeƒZd3dd„Z	d	d
„Z
dd„Zed
d„ƒZ
edd„ƒZdd„Zdd„Zedd„ƒZedd„ƒZedd„ƒZedd„ƒZedd„ƒZedd „ƒZed!d"„ƒZed#d$„ƒZed%d&„ƒZed'd(„ƒZed)d*„ƒZed+d,„ƒZed-d.„ƒZd/d0„Zd4d1d2„ZdS)5Ú
SystemInfozê
    Microsoft Windows and Visual Studio related system inormations.

    Parameters
    ----------
    registry_info: RegistryInfo
        "RegistryInfo" instance.
    vc_ver: float
        Required Microsoft Visual C++ version.
    ÚWinDirrÚProgramFileszProgramFiles(x86)NcCs"||_|jj|_|p|jƒ|_dS)N)ÚrirSÚ_find_latest_available_vc_verÚvc_ver)r@Z
registry_infororrrrAãs
zSystemInfo.__init__cCs6y|jƒdStk
r0d}tjj|ƒ‚YnXdS)Nrz%No Microsoft Visual C++ version foundr5)Úfind_available_vc_versÚ
IndexErrorr!r"r#)r@Úerrrrrrnès
z(SystemInfo._find_latest_available_vc_vercCs6|jj}|jj|jj|jjf}g}x|jjD]ü}xö|D]î}ytj|||ƒdtjƒ}Wnt	t
fk
rpw8YnXtj|ƒ\}}}	xPt|ƒD]D}
y*t
tj||
ƒdƒ}||kr¸|j|ƒWqŒtk
rÎYqŒXqŒWxPt|ƒD]D}
y(t
tj||
ƒƒ}||kr|j|ƒWqÞtk
r YqÞXqÞWq8Wq.Wt|ƒS)zC
        Find all available Microsoft Visual C++ versions.
        r)rmr^rVrXrWrarr`r_rbrcZQueryInfoKeyÚrangeÚfloatZ	EnumValueÚappendr$ÚEnumKeyÚsorted)r@rfZvckeysZvc_versrgrrhZsubkeysÚvaluesrBÚir(rrrrpïs2


z!SystemInfo.find_available_vc_verscCs6d|j}tjj|j|ƒ}|jj|jjd|jƒp4|S)z4
        Microsoft Visual Studio directory.
        zMicrosoft Visual Studio %0.1fz%0.1f)rorrrÚProgramFilesx86rmrirW)r@reÚdefaultrrrÚVSInstallDir
s
zSystemInfo.VSInstallDircCsŽ|j|jƒp|jƒ}tjj|jjd|jƒ}|jj	|dƒ}|rNtjj|dƒn|}|jj	|jj
d|jƒpl|}tjj|ƒsŠd}tj
j|ƒ‚|S)z1
        Microsoft Visual C++ directory.
        z%0.1frZVCz(Microsoft Visual C++ directory not found)r|Ú	_guess_vcÚ_guess_vc_legacyrrrrmrXrorirVÚisdirr!r"r#)r@Úguess_vcZreg_pathZ	python_vcZ
default_vcrÚmsgrrrÚVCInstallDirszSystemInfo.VCInstallDirc
Cs^|jdkrdSd}tjj|j|ƒ}ytj|ƒd}tjj||ƒStttfk
rXYnXdS)z*
        Locate Visual C for 2017
        g,@Nz
VC\Tools\MSVCrr5)	rorrrr|Úlistdirrbrcrq)r@r{r€Zvc_exact_verrrrr}0s
zSystemInfo._guess_vccCsd|j}tjj|j|ƒS)z<
        Locate Visual C for versions prior to 2017
        z Microsoft Visual Studio %0.1f\VC)rorrrrz)r@r{rrrr~@s
zSystemInfo._guess_vc_legacycCsJ|jdkrdS|jdkrdS|jdkr*dS|jdkr8dS|jdkrFdSdS)zN
        Microsoft Windows SDK versions for specified MSVC++ version.
        g"@ú7.0ú6.1ú6.0ag$@ú7.1ú7.0ag&@ú8.0ú8.0ag(@ú8.1ú8.1ag,@ú10.0N)r„r…r†)r‡rˆ)r‰rŠ)r‹rŒ)rr‹)ro)r@rrrÚWindowsSdkVersionGs




zSystemInfo.WindowsSdkVersioncCs|jtjj|jdƒƒS)z4
        Microsoft Windows SDK last version
        Úlib)Ú_use_last_dir_namerrrÚ
WindowsSdkDir)r@rrrÚWindowsSdkLastVersionWs
z SystemInfo.WindowsSdkLastVersioncCsTd}x8|jD].}tjj|jjd|ƒ}|jj|dƒ}|rPqW|sRtjj|ƒrŠtjj|jjd|j	ƒ}|jj|dƒ}|rŠtjj|dƒ}|sžtjj|ƒrèxH|jD]>}|d|j
dƒ…}d	|}tjj|j|ƒ}tjj|ƒr¦|}q¦W|sþtjj|ƒr:x:|jD]0}d
|}tjj|j|ƒ}tjj|ƒr|}qW|sPtjj|jdƒ}|S)z2
        Microsoft Windows SDK directory.
        rzv%sÚinstallationfolderz%0.1frZWinSDKNÚ.zMicrosoft SDKs\Windows Kits\%szMicrosoft SDKs\Windows\v%sZPlatformSDK)
rŽrrrrmrZrirrXroÚrfindrlr‚)r@Úsdkdirr(ÚlocrÚinstall_baseZintverÚdrrrr‘_s6
zSystemInfo.WindowsSdkDirc	CsÚ|jdkrd}d}n&d}|jdkr&dnd}|jjd|d}d	||jd
dƒf}g}|jdkr†x(|jD]}|tjj|jj	||ƒg7}qdWx,|j
D]"}|tjj|jjd
||ƒg7}qŽWx |D]}|jj|dƒ}|rºPqºW|S)z=
        Microsoft Windows SDK executable directory.
        g&@é#ré(g(@TF)r=rGzWinSDK-NetFx%dTools%srJú-g,@zv%sAr“)
rorSrHr?ÚNetFxSdkVersionrrrrmr[rŽrZri)	r@Znetfxverr)rGZfxZregpathsr(rZexecpathrrrÚWindowsSDKExecutablePath…s$

"
z#SystemInfo.WindowsSDKExecutablePathcCs.d|j}tjj|jj|ƒ}|jj|dƒp,dS)z0
        Microsoft Visual F# directory.
        z%0.1f\Setup\F#rr)rorrrrmrTri)r@rrrrÚFSharpInstallDir¤s
zSystemInfo.FSharpInstallDircCsF|jdkrd}nf}x(|D] }|jj|jjd|ƒ}|rPqW|pDdS)z8
        Microsoft Universal CRT SDK directory.
        g,@Ú10Ú81z
kitsroot%sr)r r¡)rormrir\)r@Úversr(r–rrrÚUniversalCRTSdkDir­s


zSystemInfo.UniversalCRTSdkDircCs|jtjj|jdƒƒS)z@
        Microsoft Universal C Runtime SDK last version
        r)rrrrr£)r@rrrÚUniversalCRTSdkLastVersionÀs
z%SystemInfo.UniversalCRTSdkLastVersioncCs|jdkrdSfSdS)z8
        Microsoft .NET Framework SDK versions.
        g,@ú4.6.1ú4.6N)r¥r¦)ro)r@rrrrÈs
zSystemInfo.NetFxSdkVersioncCs>x4|jD]*}tjj|jj|ƒ}|jj|dƒ}|rPqW|p<dS)z9
        Microsoft .NET Framework SDK directory.
        Zkitsinstallationfolderr)rrrrrmr[ri)r@r(r—r–rrrÚNetFxSdkDirÓszSystemInfo.NetFxSdkDircCs&tjj|jdƒ}|jj|jjdƒp$|S)z;
        Microsoft .NET Framework 32bit directory.
        zMicrosoft.NET\FrameworkZframeworkdir32)rrrrkrmrirV)r@Úguess_fwrrrÚFrameworkDir32ßszSystemInfo.FrameworkDir32cCs&tjj|jdƒ}|jj|jjdƒp$|S)z;
        Microsoft .NET Framework 64bit directory.
        zMicrosoft.NET\Framework64Zframeworkdir64)rrrrkrmrirV)r@r¨rrrÚFrameworkDir64êszSystemInfo.FrameworkDir64cCs
|jdƒS)z:
        Microsoft .NET Framework 32bit versions.
        é )Ú_find_dot_net_versions)r@rrrÚFrameworkVersion32õszSystemInfo.FrameworkVersion32cCs
|jdƒS)z:
        Microsoft .NET Framework 64bit versions.
        é@)r¬)r@rrrÚFrameworkVersion64üszSystemInfo.FrameworkVersion64cCs˜|jj|jjd|ƒ}t|d|ƒ}|p6|j|dƒp6d}|jdkrL|df}n:|jdkrx|jƒdd	…d
krndn|df}n|jd
kr†d}|jdkr”d}|S)z¡
        Find Microsoft .NET Framework versions.

        Parameters
        ----------
        bits: int
            Platform number of bits: 32 or 64.
        zframeworkver%dzFrameworkDir%dÚvrg(@zv4.0g$@NéZv4z
v4.0.30319úv3.5g"@ú
v2.0.50727g @úv3.0)r²r³)r´r³)rmrirVÚgetattrrror6)r@ÚbitsZreg_verZdot_net_dirr(Zframeworkverrrrr¬s





z!SystemInfo._find_dot_net_versionscs,‡‡fdd„ttjˆƒƒDƒ}t|dƒp*dS)zî
        Return name of the last dir in path or '' if no dir found.

        Parameters
        ----------
        path: str
            Use dirs in this path
        prefix: str
            Use only dirs startings by this prefix
        c3s2|]*}tjjtjjˆ|ƒƒr|jˆƒr|VqdS)N)rrrrÚ
startswith)Ú.0Zdir_name)rÚprefixrrú	<genexpr>)sz0SystemInfo._use_last_dir_name.<locals>.<genexpr>Nr)ÚreversedrrƒÚnext)r@rr¹Z
matching_dirsr)rr¹rrszSystemInfo._use_last_dir_name)N)r) rr	r
rNrOrPrkrlrzrArnrprQr|r‚r}r~rŽr’r‘ržrŸr£r¤rr§r©rªr­r¯r¬rrrrrrjÑs4

&	rjc@sReZdZdZd=dd„Zedd„ƒZedd	„ƒZed
d„ƒZedd
„ƒZ	edd„ƒZ
edd„ƒZedd„ƒZedd„ƒZ
edd„ƒZedd„ƒZdd„Zedd„ƒZedd„ƒZed d!„ƒZed"d#„ƒZed$d%„ƒZed&d'„ƒZed(d)„ƒZed*d+„ƒZed,d-„ƒZed.d/„ƒZed0d1„ƒZed2d3„ƒZed4d5„ƒZd>d7d8„Zd9d:„Zd?d;d<„Z dS)@r%aY
    Return environment variables for specified Microsoft Visual C++ version
    and platform : Lib, Include, Path and libpath.

    This function is compatible with Microsoft Visual C++ 9.0 to 14.0.

    Script created by analysing Microsoft environment configuration files like
    "vcvars[...].bat", "SetEnv.Cmd", "vcbuildtools.bat", ...

    Parameters
    ----------
    arch: str
        Target architecture.
    vc_ver: float
        Required Microsoft Visual C++ version. If not set, autodetect the last
        version.
    vc_min_ver: float
        Minimum Microsoft Visual C++ version.
    NrcCsBt|ƒ|_t|jƒ|_t|j|ƒ|_|j|kr>d}tjj	|ƒ‚dS)Nz.No suitable Microsoft Visual C++ version found)
r<rSrRrmrjÚsiror!r"r#)r@r)ror.rrrrrrAIs

zEnvironmentInfo.__init__cCs|jjS)z/
        Microsoft Visual C++ version.
        )r½ro)r@rrrroRszEnvironmentInfo.vc_vercsVddg}ˆjdkrDˆjjddd}|dg7}|dg7}|d|g7}‡fd	d
„|DƒS)z/
        Microsoft Visual Studio Tools
        zCommon7\IDEz
Common7\Toolsg,@T)rGr=z1Common7\IDE\CommonExtensions\Microsoft\TestWindowzTeam Tools\Performance ToolszTeam Tools\Performance Tools%scsg|]}tjjˆjj|ƒ‘qSr)rrrr½r|)r¸r)r@rrú
<listcomp>fsz+EnvironmentInfo.VSTools.<locals>.<listcomp>)rorSrH)r@ÚpathsÚarch_subdirr)r@rÚVSToolsYs


zEnvironmentInfo.VSToolscCs$tjj|jjdƒtjj|jjdƒgS)zL
        Microsoft Visual C++ & Microsoft Foundation Class Includes
        ÚIncludezATLMFC\Include)rrrr½r‚)r@rrrÚ
VCIncludeshszEnvironmentInfo.VCIncludescsbˆjdkrˆjjdd}nˆjjdd}d|d|g}ˆjdkrP|d|g7}‡fd	d
„|DƒS)zM
        Microsoft Visual C++ & Microsoft Foundation Class Libraries
        g.@T)r=)rGzLib%szATLMFC\Lib%sg,@zLib\store%scsg|]}tjjˆjj|ƒ‘qSr)rrrr½r‚)r¸r)r@rrr¾~sz/EnvironmentInfo.VCLibraries.<locals>.<listcomp>)rorSrI)r@rÀr¿r)r@rÚVCLibrariesps

zEnvironmentInfo.VCLibrariescCs"|jdkrgStjj|jjdƒgS)zA
        Microsoft Visual C++ store references Libraries
        g,@zLib\store\references)rorrrr½r‚)r@rrrÚVCStoreRefs€s
zEnvironmentInfo.VCStoreRefscCs|j}tjj|jdƒg}|jdkr&dnd}|jj|ƒ}|rT|tjj|jd|ƒg7}|jdkrˆd|jjdd}|tjj|j|ƒg7}nŒ|jdkrþ|jj	ƒr d	nd
}|tjj|j||jj
ddƒg7}|jj|jjkrü|tjj|j||jjddƒg7}n|tjj|jdƒg7}|S)
z,
        Microsoft Visual C++ Tools
        Z
VCPackagesg$@TFzBin%sg,@)rGg.@z
bin\HostX86%sz
bin\HostX64%s)r=ÚBin)
r½rrrr‚rorSrMrHrFrIrErC)r@r½ÚtoolsrKrÀrZhost_dirrrrÚVCTools‰s&

zEnvironmentInfo.VCToolscCst|jdkr2|jjddd}tjj|jjd|ƒgS|jjdd}tjj|jjdƒ}|j}tjj|d||fƒgSdS)	z1
        Microsoft Windows SDK Libraries
        g$@T)rGr=zLib%s)r=rz%sum%sN)	rorSrIrrrr½r‘Ú_sdk_subdir)r@rÀrZlibverrrrÚOSLibraries©s
zEnvironmentInfo.OSLibrariescCs|tjj|jjdƒ}|jdkr.|tjj|dƒgS|jdkr@|j}nd}tjj|d|ƒtjj|d|ƒtjj|d|ƒgSd	S)
z/
        Microsoft Windows SDK Include
        Úincludeg$@Úglg,@rz%ssharedz%sumz%swinrtN)rrrr½r‘rorÉ)r@rËÚsdkverrrrÚ
OSIncludes¸s

zEnvironmentInfo.OSIncludescCsºtjj|jjdƒ}g}|jdkr*||j7}|jdkrH|tjj|dƒg7}|jdkr¶||tjj|jjdƒtjj|ddƒtjj|d	dƒtjj|d
dƒtjj|jjddd
|jdddƒg7}|S)z7
        Microsoft Windows SDK Libraries Paths
        Z
Referencesg"@g&@zCommonConfiguration\Neutralg,@Z
UnionMetadataz'Windows.Foundation.UniversalApiContractz1.0.0.0z%Windows.Foundation.FoundationContractz,Windows.Networking.Connectivity.WwanContractZ
ExtensionSDKszMicrosoft.VCLibsz%0.1fZCommonConfigurationZneutral)rrrr½r‘rorÊ)r@ÚrefÚlibpathrrrÚ	OSLibpathËs>




zEnvironmentInfo.OSLibpathcCst|jƒƒS)z-
        Microsoft Windows SDK Tools
        )ÚlistÚ
_sdk_tools)r@rrrÚSdkToolsøszEnvironmentInfo.SdkToolsccs|jdkr0|jdkrdnd}tjj|jj|ƒV|jjƒsd|jjdd}d|}tjj|jj|ƒV|jdksx|jdkr¶|jj	ƒrˆd	}n|jjddd
}d|}tjj|jj|ƒVnL|jdkrtjj|jjdƒ}|jjdd}|jj
}tjj|d||fƒV|jjr|jjVd
S)z=
        Microsoft Windows SDK Tools paths generator
        g.@g&@rÆzBin\x86T)r=zBin%sg$@r)rGr=zBin\NETFX 4.0 Tools%sz%s%sN)rorrrr½r‘rSrFrHrDr’rž)r@Úbin_dirrÀrrÍrrrrÓÿs(



zEnvironmentInfo._sdk_toolscCs|jj}|rd|SdS)z6
        Microsoft Windows SDK version subdir
        z%s\r)r½r’)r@ÚucrtverrrrrÉszEnvironmentInfo._sdk_subdircCs"|jdkrgStjj|jjdƒgS)z-
        Microsoft Windows SDK Setup
        g"@ZSetup)rorrrr½r‘)r@rrrÚSdkSetup%s
zEnvironmentInfo.SdkSetupcs”|j}|j‰|jdkr0d}|jƒo,|jƒ}n$|jƒp>|jƒ}|jdkpR|jdk}g}|rt|‡fdd„ˆjDƒ7}|r|‡fdd„ˆjDƒ7}|S)z0
        Microsoft .NET Framework Tools
        g$@Tr>csg|]}tjjˆj|ƒ‘qSr)rrrr©)r¸r()r½rrr¾@sz+EnvironmentInfo.FxTools.<locals>.<listcomp>csg|]}tjjˆj|ƒ‘qSr)rrrrª)r¸r()r½rrr¾Cs)	rSr½rorDrFrErCr­r¯)r@rSZ	include32Z	include64rÇr)r½rÚFxTools/s
zEnvironmentInfo.FxToolscCs>|jdks|jjrgS|jjdd}tjj|jjd|ƒgS)z8
        Microsoft .Net Framework SDK Libraries
        g,@T)r=zlib\um%s)ror½r§rSrIrrr)r@rÀrrrÚNetFxSDKLibrariesGsz!EnvironmentInfo.NetFxSDKLibrariescCs,|jdks|jjrgStjj|jjdƒgS)z7
        Microsoft .Net Framework SDK Includes
        g,@z
include\um)ror½r§rrr)r@rrrÚNetFxSDKIncludesRsz EnvironmentInfo.NetFxSDKIncludescCstjj|jjdƒgS)z>
        Microsoft Visual Studio Team System Database
        z
VSTSDB\Deploy)rrrr½r|)r@rrrÚVsTDb\szEnvironmentInfo.VsTDbcCs~|jdkrgS|jdkr0|jj}|jjdd}n|jj}d}d|j|f}tjj||ƒg}|jdkrz|tjj||dƒg7}|S)z(
        Microsoft Build Engine
        g(@g.@T)rGrzMSBuild\%0.1f\bin%sZRoslyn)	ror½rzrSrHr|rrr)r@Ú	base_pathrÀrÚbuildrrrÚMSBuildcs


zEnvironmentInfo.MSBuildcCs"|jdkrgStjj|jjdƒgS)z.
        Microsoft HTML Help Workshop
        g&@zHTML Help Workshop)rorrrr½rz)r@rrrÚHTMLHelpWorkshopzs
z EnvironmentInfo.HTMLHelpWorkshopcCsL|jdkrgS|jjdd}tjj|jjdƒ}|j}tjj|d||fƒgS)z=
        Microsoft Universal C Runtime SDK Libraries
        g,@T)r=rz%sucrt%s)	rorSrIrrrr½r£Ú_ucrt_subdir)r@rÀrrÖrrrÚ
UCRTLibraries„s
zEnvironmentInfo.UCRTLibrariescCs6|jdkrgStjj|jjdƒ}tjj|d|jƒgS)z;
        Microsoft Universal C Runtime SDK Include
        g,@rËz%sucrt)rorrrr½r£rà)r@rËrrrÚUCRTIncludes‘s
zEnvironmentInfo.UCRTIncludescCs|jj}|rd|SdS)zB
        Microsoft Universal C Runtime SDK version subdir
        z%s\r)r½r¤)r@rÖrrrràœszEnvironmentInfo._ucrt_subdircCs |jdkr|jdkrgS|jjS)z%
        Microsoft Visual F#
        g&@g(@)ror½rŸ)r@rrrÚFSharp¤szEnvironmentInfo.FSharpcCsl|jjdd}|jdkr&|jj}d}n|jjjddƒ}d}|jdkrHdn|j}|||j|f}tjj||ƒS)	zA
        Microsoft Visual C++ runtime redistribuable dll
        T)r=éz-redist%s\Microsoft.VC%d0.CRT\vcruntime%d0.dllz\Toolsz\Redistz.onecore%s\Microsoft.VC%d0.CRT\vcruntime%d0.dllg,@)	rSrIror½r‚r?rrr)r@rÀZredist_pathZ	vcruntimeZdll_verrrrÚVCRuntimeRedist®s
zEnvironmentInfo.VCRuntimeRedistTcCs¶t|jd|j|j|j|jg|ƒ|jd|j|j|j|j	|j
g|ƒ|jd|j|j|j|jg|ƒ|jd|j
|j|j|j|j|j|j|j|jg	|ƒd}|jdkr²tjj|jƒr²|j|d<|S)z—
        Return environment dict.

        Parameters
        ----------
        exists: bool
            It True, only return existing paths.
        rËrrÐr)rËrrÐréZpy_vcruntime_redist)ÚdictÚ_build_pathsrÃrÎrârÚrÄrÊrØrárÙrÅrÑrÈrÁrÛrÔr×rÞrßrãrorrrrå)r@ÚexistsÚenvrrrr&ÁsD	

zEnvironmentInfo.return_envc
Csxtjj|ƒ}tj|dƒjtjƒ}tj||ƒ}|rBtt	tj
j|ƒƒn|}|sbd|jƒ}t
jj|ƒ‚|j|ƒ}	tjj|	ƒS)a
        Given an environment variable name and specified paths,
        return a pathsep-separated string of paths containing
        unique, extant, directories from those paths and from
        the environment variable. Raise an error if no paths
        are resolved.
        rz %s environment variable is empty)Ú	itertoolsÚchainÚ
from_iterablerOrPÚsplitrÚpathseprÒÚfilterrrÚupperr!r"r#Ú_unique_everseenr)
r@reZspec_path_listsréZ
spec_pathsZ	env_pathsr¿Zextant_pathsrZunique_pathsrrrrèîs	
zEnvironmentInfo._build_pathsccsjtƒ}|j}|dkr:xPt|j|ƒD]}||ƒ|Vq"Wn,x*|D]"}||ƒ}||kr@||ƒ|Vq@WdS)z×
        List unique elements, preserving order.
        Remember all elements ever seen.

        _unique_everseen('AAAABBBCCDAABBB') --> A B C D

        _unique_everseen('ABBCcAD', str.lower) --> A B C D
        N)ÚsetÚaddrÚ__contains__)r@ÚiterablerÚseenZseen_addÚelementÚkrrrròs	
z EnvironmentInfo._unique_everseen)Nr)T)N)!rr	r
rNrArQrorÁrÃrÄrÅrÈrÊrÎrÑrÔrÓrÉr×rØrÙrÚrÛrÞrßrárâràrãrår&rèròrrrrr%1s:
		 -





-r%)r)r)!rNrr0ÚplatformrëZdistutils.errorsr!Z#setuptools.extern.packaging.versionrZsetuptools.extern.six.movesrZmonkeyrÚsystemrÚenvironrOrçÚImportErrorr"r#Z_msvc9_suppress_errorsZdistutils.msvc9compilerrrr r/r3r'r<rRrjr%rrrrÚ<module>s>
+
/&
%[b