Skip to content

Commit 76f0ac6

Browse files
authored
Update packman and repo_docs versions (#3293)
Co-authored-by: Ashwin Srinath <shwina@users.noreply.github.com>
1 parent 4166471 commit 76f0ac6

File tree

11 files changed

+238
-76
lines changed

11 files changed

+238
-76
lines changed

docs/repo.bat

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
1-
@echo off
2-
3-
call "%~dp0tools\packman\python.bat" %~dp0tools\repoman\repoman.py %*
4-
if %errorlevel% neq 0 ( goto Error )
5-
6-
:Success
7-
exit /b 0
8-
9-
:Error
10-
exit /b %errorlevel%
1+
@echo off
2+
3+
:: Set OMNI_REPO_ROOT early so `repo` bootstrapping can target the repository
4+
:: root when writing out Python dependencies.
5+
:: Use SETLOCAL and ENDLOCAL to constrain these variables to this batch file.
6+
:: Use ENABLEDELAYEDEXPANSION to evaluate the value of PM_PACKAGES_ROOT
7+
:: at execution time.
8+
SETLOCAL ENABLEDELAYEDEXPANSION
9+
set OMNI_REPO_ROOT="%~dp0"
10+
11+
:: Set Packman cache directory early if repo-cache.json is configured
12+
:: so that the Packman Python version is not fetched from the web.
13+
IF NOT EXIST "%~dp0repo-cache.json" goto :RepoCacheEnd
14+
15+
:: Read PM_PACKAGES_ROOT from repo-cache.json and make sure it is an absolute path (assume relative to the script directory).
16+
for /f "usebackq tokens=*" %%i in (`powershell -NoProfile -Command "$PM_PACKAGES_ROOT = (Get-Content '%~dp0repo-cache.json' | ConvertFrom-Json).PM_PACKAGES_ROOT; if ([System.IO.Path]::IsPathRooted($PM_PACKAGES_ROOT)) { Write-Output ('absolute;' + $PM_PACKAGES_ROOT) } else { Write-Output ('relative;' + $PM_PACKAGES_ROOT) }"`) do (
17+
for /f "tokens=1,2 delims=;" %%A in ("%%i") do (
18+
if /i "%%A" == "relative" (
19+
set PM_PACKAGES_ROOT=%~dp0%%B
20+
) else (
21+
set PM_PACKAGES_ROOT=%%B
22+
)
23+
)
24+
)
25+
26+
:RepoCacheEnd
27+
28+
call "%~dp0tools\packman\python.bat" "%~dp0tools\repoman\repoman.py" %*
29+
if %errorlevel% neq 0 ( goto Error )
30+
31+
:Success
32+
ENDLOCAL
33+
exit /b 0
34+
35+
:Error
36+
ENDLOCAL
37+
exit /b %errorlevel%

docs/repo.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,35 @@
22

33
set -e
44

5+
# Set OMNI_REPO_ROOT early so `repo` bootstrapping can target the repository
6+
# root when writing out Python dependencies.
7+
export OMNI_REPO_ROOT="$( cd "$(dirname "$0")" ; pwd -P )"
8+
9+
# By default custom caching is disabled in repo_man. But if a repo-cache.json
10+
# caching configuration file is generated via the `repo cache` command, it's
11+
# presence will trigger the configuration of custom caching.
12+
if [[ -f "${OMNI_REPO_ROOT}/repo-cache.json" ]]; then
13+
PM_PACKAGES_ROOT=$(grep '"PM_PACKAGES_ROOT"' "${OMNI_REPO_ROOT}/repo-cache.json" | sed 's/.*"PM_PACKAGES_ROOT": "\(.*\)".*/\1/')
14+
15+
# PM_PACKAGES_ROOT is present in the config file. We set this early
16+
# so Packman will reference our cached package repository.
17+
if [[ -n "${PM_PACKAGES_ROOT}" ]]; then
18+
# Use eval to resolve ~ and perform parameter expansion
19+
RESOLVED_PACKAGES_ROOT=$(eval echo "$PM_PACKAGES_ROOT")
20+
21+
if [[ "${RESOLVED_PACKAGES_ROOT}" != /* ]]; then
22+
# PM_PACKAGES_ROOT is not an abs path, assumption is then
23+
# that it is a relative path to the repository root.
24+
PM_PACKAGES_ROOT="${OMNI_REPO_ROOT}/${RESOLVED_PACKAGES_ROOT}"
25+
else
26+
PM_PACKAGES_ROOT=${RESOLVED_PACKAGES_ROOT}
27+
fi
28+
export PM_PACKAGES_ROOT
29+
fi
30+
fi
31+
532
SCRIPT_DIR=$(dirname ${BASH_SOURCE})
633
cd "$SCRIPT_DIR"
734

8-
exec "tools/packman/python.sh" tools/repoman/repoman.py $@
35+
# Use "exec" to ensure that environment variables don't accidentally affect other processes.
36+
exec "tools/packman/python.sh" tools/repoman/repoman.py "$@"

docs/repo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ social_media = [
1515
[ "discord", "https://discord.com/channels/1019361803752456192/1161051667945508884" ],
1616
]
1717

18+
sphinx_version = "4.5.0.2-py3.10-${platform}"
19+
1820
enhanced_search_enabled = true
1921
api_output_directory = "api"
2022
use_fast_doxygen_conversion = true

docs/tools/deps/repo-deps.packman.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<project toolsVersion="5.0">
22
<dependency name="repo_man" linkPath="../../_repo/deps/repo_man">
3-
<package name="repo_man" version="1.10.1"/>
3+
<package name="repo_man" version="1.71.1"/>
44
</dependency>
55
<dependency name="repo_docs" linkPath="../../_repo/deps/repo_docs">
66
<package name="repo_docs" version="0.10.4"/>

docs/tools/packman/bootstrap/configure.bat

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:: Copyright 2019 NVIDIA CORPORATION
1+
:: Copyright 2019-2023 NVIDIA CORPORATION
22
::
33
:: Licensed under the Apache License, Version 2.0 (the "License");
44
:: you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
1212
:: See the License for the specific language governing permissions and
1313
:: limitations under the License.
1414

15-
set PM_PACKMAN_VERSION=6.57
15+
set PM_PACKMAN_VERSION=7.24.4
1616

1717
:: Specify where packman command is rooted
1818
set PM_INSTALL_PATH=%~dp0..
@@ -59,7 +59,7 @@ if defined PM_PYTHON_EXT (
5959
goto PACKMAN
6060
)
6161

62-
set PM_PYTHON_VERSION=3.7.13-nv1-windows-x86_64
62+
set PM_PYTHON_VERSION=3.10.5-1-windows-x86_64
6363
set PM_PYTHON_BASE_DIR=%PM_PACKAGES_ROOT%\python
6464
set PM_PYTHON_DIR=%PM_PYTHON_BASE_DIR%\%PM_PYTHON_VERSION%
6565
set PM_PYTHON=%PM_PYTHON_DIR%\python.exe
@@ -95,11 +95,16 @@ if exist "%PM_PYTHON%" (
9595
if exist "%PM_PYTHON_DIR%" ( rd /s /q "%PM_PYTHON_DIR%" > nul )
9696
)
9797

98-
:: Perform atomic rename
99-
rename "%TEMP_FOLDER_NAME%" "%PM_PYTHON_VERSION%" 1> nul
100-
:: Failure during move, need to clean up and abort
98+
:: Perform atomic move (allowing overwrite, /y)
99+
move /y "%TEMP_FOLDER_NAME%" "%PM_PYTHON_DIR%" 1> nul
100+
:: Verify that python.exe is now where we expect
101+
if exist "%PM_PYTHON%" goto PACKMAN
102+
103+
:: Wait a second and try again (can help with access denied weirdness)
104+
timeout /t 1 /nobreak 1> nul
105+
move /y "%TEMP_FOLDER_NAME%" "%PM_PYTHON_DIR%" 1> nul
101106
if %errorlevel% neq 0 (
102-
echo !!! Error renaming python !!!
107+
echo !!! Error moving python %TEMP_FOLDER_NAME% -> %PM_PYTHON_DIR% !!!
103108
call :CLEAN_UP_TEMP_FOLDER
104109
goto ERROR
105110
)
@@ -114,7 +119,7 @@ if defined PM_MODULE_DIR_EXT (
114119

115120
set PM_MODULE=%PM_MODULE_DIR%\run.py
116121

117-
if exist "%PM_MODULE%" goto ENSURE_7ZA
122+
if exist "%PM_MODULE%" goto END
118123

119124
:: Clean out broken PM_MODULE_DIR if it exists
120125
if exist "%PM_MODULE_DIR%" ( rd /s /q "%PM_MODULE_DIR%" > nul )
@@ -137,19 +142,6 @@ if %errorlevel% neq 0 (
137142

138143
del "%TARGET%"
139144

140-
:ENSURE_7ZA
141-
set PM_7Za_VERSION=22.01-1
142-
set PM_7Za_PATH=%PM_PACKAGES_ROOT%\7za\%PM_7ZA_VERSION%
143-
if exist "%PM_7Za_PATH%" goto END
144-
set PM_7Za_PATH=%PM_PACKAGES_ROOT%\chk\7za\%PM_7ZA_VERSION%
145-
if exist "%PM_7Za_PATH%" goto END
146-
147-
"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" pull "%PM_MODULE_DIR%\deps.packman.xml"
148-
if %errorlevel% neq 0 (
149-
echo !!! Error fetching packman dependencies !!!
150-
goto ERROR
151-
)
152-
153145
goto END
154146

155147
:ERROR_MKDIR_PACKAGES_ROOT

docs/tools/packman/bootstrap/install_package.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
import os
2020
import stat
2121
import time
22-
from typing import Any, Callable
22+
import hashlib
23+
from typing import Any, Callable, Union
2324

2425

2526
RENAME_RETRY_COUNT = 100
@@ -130,7 +131,24 @@ def rename_folder_with_retry(staging_dir: StagingDirectory, folder_name):
130131
)
131132

132133

133-
def install_package(package_path, install_path):
134+
def generate_sha256_for_file(file_path: Union[str, os.PathLike]) -> str:
135+
"""Returns the SHA-256 hex digest for the file at `file_path`"""
136+
hash = hashlib.sha256()
137+
# Read the file in binary mode and update the hash object with data
138+
with open(file_path, "rb") as file:
139+
for chunk in iter(lambda: file.read(4096), b""):
140+
hash.update(chunk)
141+
return hash.hexdigest()
142+
143+
144+
def install_common_module(package_path, install_path):
145+
COMMON_SHA256 = "ef974608cf903f39dbd3f22b3e26c15a1dd21f6e71d05c1510dcf423128cd7a4"
146+
package_sha256 = generate_sha256_for_file(package_path)
147+
if package_sha256 != COMMON_SHA256:
148+
raise RuntimeError(
149+
f"Package at '{package_path}' must have a sha256 of '{COMMON_SHA256}' "
150+
f"but was found to have '{package_sha256}'"
151+
)
134152
staging_path, version = os.path.split(install_path)
135153
with StagingDirectory(staging_path) as staging_dir:
136154
output_folder = staging_dir.get_temp_folder_path()
@@ -151,4 +169,4 @@ def install_package(package_path, install_path):
151169
for exec_path in paths_list:
152170
if os.path.normcase(os.path.normpath(exec_path)) == target_path_np_nc:
153171
raise RuntimeError(f"packman will not install to executable path '{exec_path}'")
154-
install_package(sys.argv[1], target_path_np)
172+
install_common_module(sys.argv[1], target_path_np)

docs/tools/packman/packman

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright 2019-2020 NVIDIA CORPORATION
3+
# Copyright 2019-2023 NVIDIA CORPORATION
44

55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -18,11 +18,13 @@ set -eu
1818

1919
if echo ${PM_VERBOSITY-} | grep -i "debug" > /dev/null ; then
2020
set -x
21+
PM_CURL_SILENT=""
22+
PM_WGET_QUIET=""
2123
else
2224
PM_CURL_SILENT="-s -S"
2325
PM_WGET_QUIET="--quiet"
2426
fi
25-
PM_PACKMAN_VERSION=6.57
27+
export PM_PACKMAN_VERSION=7.24.4
2628

2729
# This is necessary for newer macOS
2830
if [ `uname` == 'Darwin' ]; then
@@ -58,17 +60,49 @@ if [ ! -d "$PM_PACKAGES_ROOT" ]; then
5860
mkdir -p -m a+rwx "$PM_PACKAGES_ROOT"
5961
fi
6062

63+
execute_with_retry()
64+
{
65+
# Don't exit on error, we need to handle them
66+
set +e
67+
68+
local CMD="$1"
69+
local MAX_TRIES=4
70+
local DELAY=2
71+
local TRIES=0
72+
local exit_code
73+
74+
while [ $TRIES -lt $MAX_TRIES ]
75+
do
76+
((TRIES++))
77+
eval $CMD
78+
exit_code=$?
79+
if [ $exit_code -eq 0 ]; then
80+
return 0
81+
fi
82+
83+
if [ $TRIES -lt $MAX_TRIES ]; then
84+
echo "Attempt $TRIES failed. Retrying in $DELAY seconds ..."
85+
sleep $DELAY
86+
DELAY=$((DELAY * DELAY))
87+
echo "Retrying ..."
88+
fi
89+
done
90+
91+
echo "Command failed after $MAX_TRIES attempts: $CMD"
92+
return $exit_code
93+
}
94+
6195
fetch_file_from_s3()
6296
{
63-
SOURCE=$1
64-
SOURCE_URL=http://bootstrap.packman.nvidia.com/$SOURCE
65-
TARGET=$2
97+
local SOURCE=$1
98+
local SOURCE_URL=http://bootstrap.packman.nvidia.com/$SOURCE
99+
local TARGET=$2
66100
echo "Fetching $SOURCE from bootstrap.packman.nvidia.com ..."
101+
local CMD="curl -o $TARGET $SOURCE_URL $PM_CURL_SILENT"
67102
if command -v wget >/dev/null 2>&1; then
68-
wget $PM_WGET_QUIET -O$TARGET $SOURCE_URL
69-
else
70-
curl -o $TARGET $SOURCE_URL $PM_CURL_SILENT
103+
CMD="wget $PM_WGET_QUIET -O$TARGET $SOURCE_URL"
71104
fi
105+
execute_with_retry "$CMD"
72106
}
73107

74108
generate_temp_file_name()
@@ -85,7 +119,7 @@ install_python()
85119
{
86120
PLATFORM=`uname`
87121
PROCESSOR=`uname -m`
88-
PYTHON_VERSION=3.7.13-nv1
122+
PYTHON_VERSION=3.10.5-1
89123

90124
if [ $PLATFORM == 'Darwin' ]; then
91125
PYTHON_PACKAGE=$PYTHON_VERSION-macos-x86_64
@@ -154,20 +188,6 @@ if [ ! -f "$PM_MODULE" ]; then
154188
fi
155189
fi
156190

157-
# Ensure 7za package exists:
158-
PM_7za_VERSION=22.01-1
159-
export PM_7za_PATH="$PM_PACKAGES_ROOT/7za/$PM_7za_VERSION"
160-
if [ ! -d "$PM_7za_PATH" ]; then
161-
export PM_7za_PATH="$PM_PACKAGES_ROOT/chk/7za/$PM_7za_VERSION"
162-
if [ ! -d "$PM_7za_PATH" ]; then
163-
"$PM_PYTHON" -S -s -u -E "$PM_MODULE" pull "$PM_MODULE_DIR/deps.packman.xml"
164-
if [ "$?" -ne 0 ]; then
165-
echo "Failure while installing required 7za package"
166-
exit 1
167-
fi
168-
fi
169-
fi
170-
171191
# Generate temporary file name for environment variables:
172192
PM_VAR_PATH=`mktemp -u -t tmp.$$.pmvars.XXXXXX`
173193

docs/tools/packman/packman.cmd

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
:: RUN_PM_MODULE must always be at the same spot for packman update to work (batch reloads file during update!)
2-
:: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
2+
:: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
33
:: Reset errorlevel status (don't inherit from caller)
44
@call :ECHO_AND_RESET_ERROR
5-
:: You can remove the call below if you do your own manual configuration of the dev machines
6-
call "%~dp0\bootstrap\configure.bat"
75

6+
:: You can remove this section if you do your own manual configuration of the dev machines
7+
call :CONFIGURE
88
if %errorlevel% neq 0 ( exit /b %errorlevel% )
9+
910
:: Everything below is mandatory
1011
if not defined PM_PYTHON goto :PYTHON_ENV_ERROR
1112
if not defined PM_MODULE goto :MODULE_ENV_ERROR
@@ -46,6 +47,7 @@ exit /b 1
4647
@echo Error while processing and setting environment variables!
4748
exit /b 1
4849

50+
:: pad [xxxx]
4951
:ECHO_AND_RESET_ERROR
5052
@echo off
5153
if /I "%PM_VERBOSITY%"=="debug" (
@@ -58,3 +60,30 @@ exit /b 0
5860
for /f "delims=" %%a in ('%PM_PYTHON% -S -s -u -E -c "import tempfile;file = tempfile.NamedTemporaryFile(mode='w+t', delete=False);print(file.name)"') do (set PM_VAR_PATH=%%a)
5961
set PM_VAR_PATH_ARG=--var-path="%PM_VAR_PATH%"
6062
goto :RUN_PM_MODULE
63+
64+
:CONFIGURE
65+
:: Must capture and set code page to work around issue #279, powershell invocation mutates console font
66+
:: This issue only happens in Windows CMD shell when using 65001 code page. Some Git Bash implementations
67+
:: don't support chcp so this workaround is a bit convoluted.
68+
:: Test for chcp:
69+
chcp > nul 2>&1
70+
if %errorlevel% equ 0 (
71+
for /f "tokens=2 delims=:" %%a in ('chcp') do (set PM_OLD_CODE_PAGE=%%a)
72+
) else (
73+
call :ECHO_AND_RESET_ERROR
74+
)
75+
:: trim leading space (this is safe even when PM_OLD_CODE_PAGE has not been set)
76+
set PM_OLD_CODE_PAGE=%PM_OLD_CODE_PAGE:~1%
77+
if "%PM_OLD_CODE_PAGE%" equ "65001" (
78+
chcp 437 > nul
79+
set PM_RESTORE_CODE_PAGE=1
80+
)
81+
call "%~dp0\bootstrap\configure.bat"
82+
set PM_CONFIG_ERRORLEVEL=%errorlevel%
83+
if defined PM_RESTORE_CODE_PAGE (
84+
:: Restore code page
85+
chcp %PM_OLD_CODE_PAGE% > nul
86+
)
87+
set PM_OLD_CODE_PAGE=
88+
set PM_RESTORE_CODE_PAGE=
89+
exit /b %PM_CONFIG_ERRORLEVEL%

0 commit comments

Comments
 (0)