|
1 | 1 |
|
2 | 2 | !include TextFunc.nsh |
3 | 3 |
|
4 | | -# ${GetPythonInstall} VERSION $(user_var: INSTALL_PREFIX) $(user_var: INSTALL_MODE) |
| 4 | +# ${GetPythonInstallPEP514} COMPANY TAG $(user_var: INSTALL_PREFIX) $(user_var: INSTALL_MODE) |
5 | 5 | # |
6 | | -# Retrive the registered install prefix for Python |
7 | | -# - input: VERSION is a Major.Minor version number |
| 6 | +# Retrive the registered install prefix for Python (as documented by PEP 514) |
| 7 | +# - input: COMPANY distibutor (use PythonCore for default pyhton.org |
| 8 | +# distributed python) |
| 9 | +# - input: TAG environemnt tag (e.g 3.6 or 3.6-32; sys.winver for PythonCore) |
8 | 10 | # - output: INSTALL_PREFIX installation path (e.g C:\Python35) or empty if |
9 | 11 | # not found |
10 | 12 | # - output: INSTALL_MODE |
11 | | -# 1 if Python was installed for all users or 0 if |
12 | | -# current user only (-1 when not installed). |
| 13 | +# 1 if Python was installed for all users, 0 if |
| 14 | +# current user only or -1 when not found. |
13 | 15 | # |
14 | 16 | # Example |
15 | 17 | # ------- |
16 | | -# ${GetPythonInstall} 3.5 $PythonDir $InstallMode |
17 | | - |
| 18 | +# ${GetPythonInstallPEP14} PythonCore 3.5 $PythonDir $InstallMode |
| 19 | +# ${GetPythonInstallPEP14} ContinuumAnalytics Anaconda36-64 $1 $2 |
18 | 20 |
|
19 | | -!macro __GET_PYTHON_INSTALL VERSION INSTALL_PREFIX INSTALL_MODE |
| 21 | +!macro __GET_PYTHON_INSTALL_PEP514 COMPANY TAG INSTALL_PREFIX INSTALL_MODE |
20 | 22 | ReadRegStr ${INSTALL_PREFIX} \ |
21 | | - HKCU Software\Python\PythonCore\${VERSION}\InstallPath "" |
| 23 | + HKCU Software\Python\${COMPANY}\${TAG}\InstallPath "" |
22 | 24 | ${If} ${INSTALL_PREFIX} != "" |
23 | 25 | StrCpy ${INSTALL_MODE} 0 |
24 | 26 | ${Else} |
25 | 27 | ReadRegStr ${INSTALL_PREFIX} \ |
26 | | - HKLM Software\Python\PythonCore\${VERSION}\InstallPath "" |
| 28 | + HKLM Software\Python\${COMPANY}\${TAG}\InstallPath "" |
27 | 29 | ${If} ${INSTALL_PREFIX} != "" |
28 | 30 | StrCpy ${INSTALL_MODE} 1 |
29 | 31 | ${Else} |
|
43 | 45 | Pop $0 |
44 | 46 | ${EndIf} |
45 | 47 | !macroend |
46 | | -!define GetPythonInstall "!insertmacro __GET_PYTHON_INSTALL" |
| 48 | +!define GetPythonInstallPEP514 "!insertmacro __GET_PYTHON_INSTALL_PEP514" |
| 49 | + |
| 50 | + |
| 51 | +# ${GetPythonInstall} VERSION BITS $(user_var: INSTALL_PREFIX) $(user_var: INSTALL_MODE) |
| 52 | +# |
| 53 | +# Retrive the registered install prefix for Python |
| 54 | +# - input: VERSION is a Major.Minor version number |
| 55 | +# - input: BITS is 32 or 64 constant speciying which python arch to lookup |
| 56 | +# - output: INSTALL_PREFIX installation path (e.g C:\Python35) or empty if |
| 57 | +# not found |
| 58 | +# - output: INSTALL_MODE |
| 59 | +# 1 if Python was installed for all users, 0 if |
| 60 | +# current user only or -1 when not found. |
| 61 | +# |
| 62 | +# Example |
| 63 | +# ------- |
| 64 | +# ${GetPythonInstall} 3.5 64 $PythonDir $InstallMode |
47 | 65 |
|
| 66 | +!macro __GET_PYTHON_INSTALL VERSION BITS INSTALL_PREFIX INSTALL_MODE |
| 67 | + !if ${VERSION} < 3.5 |
| 68 | + !define __TAG ${VERSION} |
| 69 | + !else if ${BITS} == 64 |
| 70 | + !define __TAG ${VERSION} |
| 71 | + !else |
| 72 | + !define __TAG ${VERSION}-${BITS} |
| 73 | + !endif |
| 74 | + ${GetPythonInstallPEP514} PythonCore ${__TAG} ${INSTALL_PREFIX} ${INSTALL_MODE} |
| 75 | + !undef __TAG |
| 76 | +!macroend |
| 77 | +!define GetPythonInstall "!insertmacro __GET_PYTHON_INSTALL" |
48 | 78 |
|
49 | 79 | # ${GetAnacondaInstall} VERSIONTAG BITS $(user_var: INSTALL_PREFIX) $(user_var: INSTALL_MODE) |
50 | 80 | # |
51 | 81 | # Retrive the registered install prefix for Python |
52 | 82 | # - input: VERSIONTAG is a MajorMinor version number (no dots) |
53 | | -# - input: BITS 34 or 64 (constant!) |
| 83 | +# - input: BITS 34 or 64 (constant) |
54 | 84 | # - output: INSTALL_PREFIX installation path (e.g C:\Python35) |
55 | 85 | # - output: INSTALL_MODE |
56 | 86 | # 1 if Python was installed for all users or 0 if |
57 | 87 | # current user only (-1 when not installed). |
58 | 88 | # |
59 | 89 | # Example |
60 | 90 | # ------- |
61 | | -# ${GetPythonInstall} 3.5 $PythonDir $InstallMode |
| 91 | +# ${GetAnacondaInstall} 35 64 $PythonDir $InstallMode |
62 | 92 |
|
63 | 93 | !macro __GET_CONDA_INSTALL VERSION_TAG BITS INSTALL_PREFIX INSTALL_MODE |
64 | | - !define __CONDA_REG_PREFIX \ |
65 | | - Software\Python\ContinuumAnalytics\Anaconda${VERSION_TAG}-${BITS} |
66 | | - |
67 | | - !if "${BITS}" != 32 |
68 | | - !if "${BITS}" != 64 |
69 | | - !error "BITS must be a 32 or 64 constant" |
70 | | - !endif |
71 | | - !endif |
72 | | - ReadRegStr ${INSTALL_PREFIX} HKCU ${__CONDA_REG_PREFIX}\InstallPath "" |
73 | | - ${If} ${INSTALL_PREFIX} != "" |
74 | | - StrCpy ${INSTALL_MODE} 0 |
75 | | - ${Else} |
76 | | - ReadRegStr ${INSTALL_PREFIX} HKLM ${__CONDA_REG_PREFIX}\InstallPath "" |
77 | | - ${If} ${INSTALL_PREFIX} != "" |
78 | | - StrCpy ${INSTALL_MODE} 1 |
79 | | - ${Else} |
80 | | - StrCpy ${INSTALL_MODE} 0 |
81 | | - ${EndIf} |
82 | | - ${EndIf} |
83 | | - |
84 | | - ${If} ${INSTALL_PREFIX} != "" |
85 | | - # Strip (single) trailing '\' if present |
86 | | - Push $0 |
87 | | - StrCpy $0 ${INSTALL_PREFIX} "" -1 |
88 | | - ${If} $0 == "\" |
89 | | - StrLen $0 ${INSTALL_PREFIX} |
90 | | - IntOp $0 $0 - 1 |
91 | | - StrCpy ${INSTALL_PREFIX} ${INSTALL_PREFIX} $0 0 |
92 | | - ${EndIf} |
93 | | - Pop $0 |
94 | | - ${EndIf} |
95 | | - !undef __CONDA_REG_PREFIX |
| 94 | + !define __TAG Anaconda${VERSION_TAG}-${BITS} |
| 95 | + ${GetPythonInstallPEP514} ContinuumAnalytics ${__TAG} ${INSTALL_PREFIX} ${INSTALL_MODE} |
| 96 | + !undef __TAG |
96 | 97 | !macroend |
97 | 98 | !define GetAnacondaInstall "!insertmacro __GET_CONDA_INSTALL" |
98 | 99 |
|
|
118 | 119 | ReadRegStr $2 ${ROOT_KEY} \ |
119 | 120 | "${__CONDA_REG_PREFIX}\$1\InstallPath" "" |
120 | 121 | ${If} $2 != "" |
| 122 | + ${AndIf} ${FileExists} "$2\python.exe" |
| 123 | + ${AndIf} ${FileExists} "$2\Scripts\conda.exe" |
121 | 124 | ${LogWrite} "${ROOT_KEY} ${__CONDA_REG_PREFIX}\$1\InstallPath: $2" |
122 | 125 | Exch $2 # <stack> $0, $1, $2, "prefix" |
123 | 126 | ${EndIf} |
|
0 commit comments