From cc736cc02785cb8f89776f5dd638be0840f7c0d9 Mon Sep 17 00:00:00 2001 From: Colin Kennedy Date: Wed, 29 Jun 2022 23:34:40 -0700 Subject: [PATCH] Added Python 2 support + extra logging --- rezify_python/rezify_python/create_package.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/rezify_python/rezify_python/create_package.py b/rezify_python/rezify_python/create_package.py index e1905e7..e10680b 100644 --- a/rezify_python/rezify_python/create_package.py +++ b/rezify_python/rezify_python/create_package.py @@ -14,6 +14,15 @@ def create_package(packages_path, python_version): """Release a python nuget package as rez package. """ + # Source: https://www.nuget.org/packages/python#versions-body-tab + package_name = "python" + + if ( + python_version == "2" or python_version.startswith("2.") + ): + # Source: https://www.nuget.org/packages/python2#versions-body-tab + package_name = "python2" + try: temp_folder = tempfile.mkdtemp(prefix="rezpy-") nuget_path = os.path.join(temp_folder, "nuget.exe") @@ -26,7 +35,7 @@ def create_package(packages_path, python_version): cmd = [ nuget_path, "install", - "python", + package_name, "-OutputDirectory", temp_folder, "-Version", @@ -42,7 +51,11 @@ def create_package(packages_path, python_version): except Exception as e: raise OSError("Installation failed: " + str(e.stderr)) - source_path = os.path.join(temp_folder, "python." + python_version, "tools") + source_path = os.path.join( + temp_folder, + "{package_name}.".format(package_name=package_name) + python_version, + "tools" + ) def make_root(variant, path): distutils.dir_util.copy_tree(source_path, path) @@ -61,6 +74,8 @@ def make_root(variant, path): except Exception as e: log.error(e) + else: + log.info("Installed to %s", packages_path) finally: log.info("Remove temporary folder -> " + temp_folder) shutil.rmtree(temp_folder)