Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Python 2 support + extra logging #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions rezify_python/rezify_python/create_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -26,7 +35,7 @@ def create_package(packages_path, python_version):
cmd = [
nuget_path,
"install",
"python",
package_name,
"-OutputDirectory",
temp_folder,
"-Version",
Expand All @@ -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)
Expand All @@ -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)