|
1 | | -@set PM_PACKMAN_VERSION=5.14 |
| 1 | +:: Copyright 2019 NVIDIA CORPORATION |
| 2 | +:: |
| 3 | +:: Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +:: you may not use this file except in compliance with the License. |
| 5 | +:: You may obtain a copy of the License at |
| 6 | +:: |
| 7 | +:: http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +:: |
| 9 | +:: Unless required by applicable law or agreed to in writing, software |
| 10 | +:: distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +:: See the License for the specific language governing permissions and |
| 13 | +:: limitations under the License. |
| 14 | + |
| 15 | +set PM_PACKMAN_VERSION=6.15 |
2 | 16 |
|
3 | 17 | :: Specify where packman command is rooted |
4 | | -@set PM_INSTALL_PATH=%~dp0.. |
| 18 | +set PM_INSTALL_PATH=%~dp0.. |
5 | 19 |
|
6 | 20 | :: The external root may already be configured and we should do minimal work in that case |
7 | | -@if defined PM_PACKAGES_ROOT goto ENSURE_DIR |
| 21 | +if defined PM_PACKAGES_ROOT goto ENSURE_DIR |
8 | 22 |
|
9 | 23 | :: If the folder isn't set we assume that the best place for it is on the drive that we are currently |
10 | 24 | :: running from |
11 | | -@set PM_DRIVE=%CD:~0,2% |
| 25 | +set PM_DRIVE=%CD:~0,2% |
12 | 26 |
|
13 | | -@set PM_PACKAGES_ROOT=%PM_DRIVE%\packman-repo |
| 27 | +set PM_PACKAGES_ROOT=%PM_DRIVE%\packman-repo |
14 | 28 |
|
15 | 29 | :: We use *setx* here so that the variable is persisted in the user environment |
16 | | -@echo Setting user environment variable PM_PACKAGES_ROOT to %PM_PACKAGES_ROOT% |
17 | | -@setx PM_PACKAGES_ROOT %PM_PACKAGES_ROOT% |
18 | | -@if errorlevel 1 goto ERROR |
| 30 | +echo Setting user environment variable PM_PACKAGES_ROOT to %PM_PACKAGES_ROOT% |
| 31 | +setx PM_PACKAGES_ROOT %PM_PACKAGES_ROOT% |
| 32 | +if %errorlevel% neq 0 ( goto ERROR ) |
19 | 33 |
|
20 | 34 | :: The above doesn't work properly from a build step in VisualStudio because a separate process is |
21 | 35 | :: spawned for it so it will be lost for subsequent compilation steps - VisualStudio must |
22 | 36 | :: be launched from a new process. We catch this odd-ball case here: |
23 | | -@if defined PM_DISABLE_VS_WARNING goto ENSURE_DIR |
24 | | -@if not defined VSLANG goto ENSURE_DIR |
25 | | -@echo The above is a once-per-computer operation. Unfortunately VisualStudio cannot pick up environment change |
26 | | -@echo unless *VisualStudio is RELAUNCHED*. |
27 | | -@echo If you are launching VisualStudio from command line or command line utility make sure |
28 | | -@echo you have a fresh launch environment (relaunch the command line or utility). |
29 | | -@echo If you are using 'linkPath' and referring to packages via local folder links you can safely ignore this warning. |
30 | | -@echo You can disable this warning by setting the environment variable PM_DISABLE_VS_WARNING. |
31 | | -@echo. |
| 37 | +if defined PM_DISABLE_VS_WARNING goto ENSURE_DIR |
| 38 | +if not defined VSLANG goto ENSURE_DIR |
| 39 | +echo The above is a once-per-computer operation. Unfortunately VisualStudio cannot pick up environment change |
| 40 | +echo unless *VisualStudio is RELAUNCHED*. |
| 41 | +echo If you are launching VisualStudio from command line or command line utility make sure |
| 42 | +echo you have a fresh launch environment (relaunch the command line or utility). |
| 43 | +echo If you are using 'linkPath' and referring to packages via local folder links you can safely ignore this warning. |
| 44 | +echo You can disable this warning by setting the environment variable PM_DISABLE_VS_WARNING. |
| 45 | +echo. |
32 | 46 |
|
33 | 47 | :: Check for the directory that we need. Note that mkdir will create any directories |
34 | | -:: that may be needed in the path |
| 48 | +:: that may be needed in the path |
35 | 49 | :ENSURE_DIR |
36 | | -@if not exist "%PM_PACKAGES_ROOT%" ( |
37 | | - @echo Creating directory %PM_PACKAGES_ROOT% |
38 | | - @mkdir "%PM_PACKAGES_ROOT%" |
39 | | - @if errorlevel 1 goto ERROR_MKDIR_PACKAGES_ROOT |
| 50 | +if not exist "%PM_PACKAGES_ROOT%" ( |
| 51 | + echo Creating directory %PM_PACKAGES_ROOT% |
| 52 | + mkdir "%PM_PACKAGES_ROOT%" |
40 | 53 | ) |
| 54 | +if %errorlevel% neq 0 ( goto ERROR_MKDIR_PACKAGES_ROOT ) |
41 | 55 |
|
42 | 56 | :: The Python interpreter may already be externally configured |
43 | | -@if defined PM_PYTHON_EXT ( |
44 | | - @set PM_PYTHON=%PM_PYTHON_EXT% |
45 | | - @goto PACKMAN |
| 57 | +if defined PM_PYTHON_EXT ( |
| 58 | + set PM_PYTHON=%PM_PYTHON_EXT% |
| 59 | + goto PACKMAN |
46 | 60 | ) |
47 | 61 |
|
48 | | -@set PM_PYTHON_VERSION=2.7.14-windows-x86_32 |
49 | | -@set PM_PYTHON_BASE_DIR=%PM_PACKAGES_ROOT%\python |
50 | | -@set PM_PYTHON_DIR=%PM_PYTHON_BASE_DIR%\%PM_PYTHON_VERSION% |
51 | | -@set PM_PYTHON=%PM_PYTHON_DIR%\python.exe |
| 62 | +set PM_PYTHON_VERSION=3.7.4-windows-x86_64 |
| 63 | +set PM_PYTHON_BASE_DIR=%PM_PACKAGES_ROOT%\python |
| 64 | +set PM_PYTHON_DIR=%PM_PYTHON_BASE_DIR%\%PM_PYTHON_VERSION% |
| 65 | +set PM_PYTHON=%PM_PYTHON_DIR%\python.exe |
52 | 66 |
|
53 | | -@if exist "%PM_PYTHON%" goto PACKMAN |
54 | | -@if not exist "%PM_PYTHON_BASE_DIR%" call :CREATE_PYTHON_BASE_DIR |
| 67 | +if exist "%PM_PYTHON%" goto PACKMAN |
| 68 | +if not exist "%PM_PYTHON_BASE_DIR%" call :CREATE_PYTHON_BASE_DIR |
55 | 69 |
|
56 | | -@set PM_PYTHON_PACKAGE=python@%PM_PYTHON_VERSION%.cab |
57 | | -@for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do @set TEMP_FILE_NAME=%%a |
58 | | -@set TARGET=%TEMP_FILE_NAME%.zip |
59 | | -@call "%~dp0fetch_file_from_s3.cmd" %PM_PYTHON_PACKAGE% "%TARGET%" |
60 | | -@if errorlevel 1 goto ERROR |
| 70 | +set PM_PYTHON_PACKAGE=python@%PM_PYTHON_VERSION%.cab |
| 71 | +for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a |
| 72 | +set TARGET=%TEMP_FILE_NAME%.zip |
| 73 | +call "%~dp0fetch_file_from_s3.cmd" %PM_PYTHON_PACKAGE% "%TARGET%" |
| 74 | +if %errorlevel% neq 0 ( goto ERROR ) |
61 | 75 |
|
62 | | -@for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_folder.ps1" -parentPath "%PM_PYTHON_BASE_DIR%"') do @set TEMP_FOLDER_NAME=%%a |
63 | | -@echo Unpacking Python interpreter ... |
64 | | -@"%SystemRoot%\system32\expand.exe" -F:* "%TARGET%" "%TEMP_FOLDER_NAME%" 1> nul |
65 | | -@del "%TARGET%" |
| 76 | +for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_folder.ps1" -parentPath "%PM_PYTHON_BASE_DIR%"') do set TEMP_FOLDER_NAME=%%a |
| 77 | +echo Unpacking Python interpreter ... |
| 78 | +"%SystemRoot%\system32\expand.exe" -F:* "%TARGET%" "%TEMP_FOLDER_NAME%" 1> nul |
| 79 | +del "%TARGET%" |
66 | 80 | :: Failure during extraction to temp folder name, need to clean up and abort |
67 | | -@if errorlevel 1 ( |
68 | | - @call :CLEAN_UP_TEMP_FOLDER |
69 | | - @goto ERROR |
| 81 | +if %errorlevel% neq 0 ( |
| 82 | + call :CLEAN_UP_TEMP_FOLDER |
| 83 | + goto ERROR |
70 | 84 | ) |
71 | 85 |
|
72 | 86 | :: If python has now been installed by a concurrent process we need to clean up and then continue |
73 | | -@if exist "%PM_PYTHON%" ( |
74 | | - @call :CLEAN_UP_TEMP_FOLDER |
75 | | - @goto PACKMAN |
| 87 | +if exist "%PM_PYTHON%" ( |
| 88 | + call :CLEAN_UP_TEMP_FOLDER |
| 89 | + goto PACKMAN |
76 | 90 | ) else ( |
77 | | - @if exist "%PM_PYTHON_DIR%" ( @rd /s /q "%PM_PYTHON_DIR%" > nul ) |
| 91 | + if exist "%PM_PYTHON_DIR%" ( rd /s /q "%PM_PYTHON_DIR%" > nul ) |
78 | 92 | ) |
79 | 93 |
|
80 | 94 | :: Perform atomic rename |
81 | | -@rename "%TEMP_FOLDER_NAME%" "%PM_PYTHON_VERSION%" 1> nul |
| 95 | +rename "%TEMP_FOLDER_NAME%" "%PM_PYTHON_VERSION%" 1> nul |
82 | 96 | :: Failure during move, need to clean up and abort |
83 | | -@if errorlevel 1 ( |
84 | | - @call :CLEAN_UP_TEMP_FOLDER |
85 | | - @goto ERROR |
| 97 | +if %errorlevel% neq 0 ( |
| 98 | + call :CLEAN_UP_TEMP_FOLDER |
| 99 | + goto ERROR |
86 | 100 | ) |
87 | 101 |
|
88 | 102 | :PACKMAN |
89 | 103 | :: The packman module may already be externally configured |
90 | | -@if defined PM_MODULE_DIR_EXT ( |
91 | | - @set PM_MODULE_DIR=%PM_MODULE_DIR_EXT% |
| 104 | +if defined PM_MODULE_DIR_EXT ( |
| 105 | + set PM_MODULE_DIR=%PM_MODULE_DIR_EXT% |
92 | 106 | ) else ( |
93 | | - @set PM_MODULE_DIR=%PM_PACKAGES_ROOT%\packman-common\%PM_PACKMAN_VERSION% |
| 107 | + set PM_MODULE_DIR=%PM_PACKAGES_ROOT%\packman-common\%PM_PACKMAN_VERSION% |
94 | 108 | ) |
95 | 109 |
|
96 | | -@set PM_MODULE=%PM_MODULE_DIR%\packman.py |
| 110 | +set PM_MODULE=%PM_MODULE_DIR%\packman.py |
97 | 111 |
|
98 | | -@if exist "%PM_MODULE%" goto ENSURE_7ZA |
| 112 | +if exist "%PM_MODULE%" goto ENSURE_7ZA |
99 | 113 |
|
100 | | -@set PM_MODULE_PACKAGE=packman-common@%PM_PACKMAN_VERSION%.zip |
101 | | -@for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do @set TEMP_FILE_NAME=%%a |
102 | | -@set TARGET=%TEMP_FILE_NAME% |
103 | | -@call "%~dp0fetch_file_from_s3.cmd" %PM_MODULE_PACKAGE% "%TARGET%" |
104 | | -@if errorlevel 1 goto ERROR |
| 114 | +set PM_MODULE_PACKAGE=packman-common@%PM_PACKMAN_VERSION%.zip |
| 115 | +for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a |
| 116 | +set TARGET=%TEMP_FILE_NAME% |
| 117 | +call "%~dp0fetch_file_from_s3.cmd" %PM_MODULE_PACKAGE% "%TARGET%" |
| 118 | +if %errorlevel% neq 0 ( goto ERROR ) |
105 | 119 |
|
106 | | -@echo Unpacking ... |
107 | | -@"%PM_PYTHON%" -S -s -u -E "%~dp0\install_package.py" "%TARGET%" "%PM_MODULE_DIR%" |
108 | | -@if errorlevel 1 goto ERROR |
| 120 | +echo Unpacking ... |
| 121 | +"%PM_PYTHON%" -S -s -u -E "%~dp0\install_package.py" "%TARGET%" "%PM_MODULE_DIR%" |
| 122 | +if %errorlevel% neq 0 ( goto ERROR ) |
109 | 123 |
|
110 | | -@del "%TARGET%" |
| 124 | +del "%TARGET%" |
111 | 125 |
|
112 | 126 | :ENSURE_7ZA |
113 | | -@set PM_7Za_VERSION=16.02.4 |
114 | | -@set PM_7Za_PATH=%PM_PACKAGES_ROOT%\7za\%PM_7ZA_VERSION% |
115 | | -@if exist "%PM_7Za_PATH%" goto END |
116 | | -@set PM_7Za_PATH=%PM_PACKAGES_ROOT%\chk\7za\%PM_7ZA_VERSION% |
117 | | -@if exist "%PM_7Za_PATH%" goto END |
| 127 | +set PM_7Za_VERSION=16.02.4 |
| 128 | +set PM_7Za_PATH=%PM_PACKAGES_ROOT%\7za\%PM_7ZA_VERSION% |
| 129 | +if exist "%PM_7Za_PATH%" goto END |
| 130 | +set PM_7Za_PATH=%PM_PACKAGES_ROOT%\chk\7za\%PM_7ZA_VERSION% |
| 131 | +if exist "%PM_7Za_PATH%" goto END |
118 | 132 |
|
119 | | -@"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" pull "%PM_MODULE_DIR%\deps.packman.xml" |
120 | | -@if errorlevel 1 goto ERROR |
| 133 | +"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" pull "%PM_MODULE_DIR%\deps.packman.xml" |
| 134 | +if %errorlevel% neq 0 ( goto ERROR ) |
121 | 135 |
|
122 | | -@goto END |
| 136 | +goto END |
123 | 137 |
|
124 | 138 | :ERROR_MKDIR_PACKAGES_ROOT |
125 | | -@echo Failed to automatically create packman packages repo at %PM_PACKAGES_ROOT%. |
126 | | -@echo Please set a location explicitly that packman has permission to write to, by issuing: |
127 | | -@echo. |
128 | | -@echo setx PM_PACKAGES_ROOT {path-you-choose-for-storing-packman-packages-locally} |
129 | | -@echo. |
130 | | -@echo Then launch a new command console for the changes to take effect and run packman command again. |
131 | | -@exit /B 1 |
| 139 | +echo Failed to automatically create packman packages repo at %PM_PACKAGES_ROOT%. |
| 140 | +echo Please set a location explicitly that packman has permission to write to, by issuing: |
| 141 | +echo. |
| 142 | +echo setx PM_PACKAGES_ROOT {path-you-choose-for-storing-packman-packages-locally} |
| 143 | +echo. |
| 144 | +echo Then launch a new command console for the changes to take effect and run packman command again. |
| 145 | +exit /B %errorlevel% |
132 | 146 |
|
133 | 147 | :ERROR |
134 | | -@echo !!! Failure while configuring local machine :( !!! |
135 | | -@exit /B 1 |
| 148 | +echo !!! Failure while configuring local machine :( !!! |
| 149 | +exit /B %errorlevel% |
136 | 150 |
|
137 | 151 | :CLEAN_UP_TEMP_FOLDER |
138 | | -@rd /S /Q "%TEMP_FOLDER_NAME%" |
139 | | -@exit /B |
| 152 | +rd /S /Q "%TEMP_FOLDER_NAME%" |
| 153 | +exit /B |
140 | 154 |
|
141 | 155 | :CREATE_PYTHON_BASE_DIR |
142 | 156 | :: We ignore errors and clean error state - if two processes create the directory one will fail which is fine |
143 | | -@md "%PM_PYTHON_BASE_DIR%" > nul 2>&1 |
144 | | -@exit /B 0 |
| 157 | +md "%PM_PYTHON_BASE_DIR%" > nul 2>&1 |
| 158 | +exit /B 0 |
145 | 159 |
|
146 | 160 | :END |
0 commit comments