1- # Use this file to bootstrap packman into your Python environment (3.7.x). Simply
1+ # Copyright 2021-2024 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+ # Use this file to bootstrap packman into your Python environment. Simply
216# add the path by doing sys.insert to where packmanconf.py is located and then execute:
317#
418# >>> import packmanconf
@@ -32,11 +46,16 @@ def init():
3246 >>> import packmanapi
3347 >>> packmanapi.set_verbosity_level(packmanapi.VERBOSITY_HIGH)
3448 """
35- major = sys .version_info [0 ]
36- minor = sys .version_info [1 ]
37- if major != 3 or minor != 10 :
49+ major = sys .version_info .major
50+ minor = sys .version_info .minor
51+ patch = sys .version_info .micro
52+ if major == 3 and (minor == 10 or (minor == 11 and patch <= 2 )):
53+ # we are good
54+ pass
55+ else :
3856 raise RuntimeError (
39- f"This version of packman requires Python 3.10.x, but { major } .{ minor } was provided"
57+ f"This version of packman requires Python 3.10.0 up to 3.11.2, "
58+ f"but { major } .{ minor } .{ patch } was provided"
4059 )
4160 conf_dir = os .path .dirname (os .path .abspath (__file__ ))
4261 os .environ ["PM_INSTALL_PATH" ] = conf_dir
@@ -79,7 +98,13 @@ def get_module_dir(conf_dir, packages_root: str, version: str) -> str:
7998 tf = tempfile .NamedTemporaryFile (delete = False )
8099 target_name = tf .name
81100 tf .close ()
82- url = f"http://bootstrap.packman.nvidia.com/packman-common@{ version } .zip"
101+ # Using http here and not https is by design. Unfortunately SSL keeps getting revised
102+ # which breaks old clients when servers are forced to upgrade to newer version of TLS
103+ # and refuse to downgrade when asked. Instead of relying on SSL for transport security
104+ # packman does SHA256 verification of the downloaded package in the `install_package`
105+ # method. We therefore inform SonarQube to stop complaining about the line below.
106+ # See issue #367 for more detail.
107+ url = f"http://bootstrap.packman.nvidia.com/packman-common@{ version } .zip" # NOSONAR
83108 print (f"Downloading '{ url } ' ..." )
84109 import urllib .request
85110
@@ -90,7 +115,7 @@ def get_module_dir(conf_dir, packages_root: str, version: str) -> str:
90115 script_path = os .path .join (conf_dir , "bootstrap" , "install_package.py" )
91116 ip = SourceFileLoader ("install_package" , script_path ).load_module ()
92117 print ("Unpacking ..." )
93- ip .install_package (target_name , module_dir )
118+ ip .install_common_module (target_name , module_dir )
94119 os .unlink (tf .name )
95120 return module_dir
96121
@@ -101,7 +126,7 @@ def get_version(conf_dir: str):
101126 path += ".sh"
102127 with open (path , "rt" , encoding = "utf8" ) as launch_file :
103128 for line in launch_file .readlines ():
104- if line . startswith ( "PM_PACKMAN_VERSION" ) :
129+ if "PM_PACKMAN_VERSION" in line :
105130 _ , value = line .split ("=" )
106131 return value .strip ()
107132 raise RuntimeError (f"Unable to find 'PM_PACKMAN_VERSION' in '{ path } '" )
0 commit comments