This commit is contained in:
antisch 2017-11-30 15:30:45 -08:00
Родитель a4947f00ef
Коммит bdc6012758
3 изменённых файлов: 20094 добавлений и 53 удалений

Просмотреть файл

@ -30,7 +30,7 @@ warnings.simplefilter('ignore')
INSTALL_DIR = os.path.normpath(
os.path.join(cmds.internalVar(userScriptDir=True), 'azure-batch-libs'))
sys.path.append(INSTALL_DIR)
sys.path.insert(0, INSTALL_DIR)
REQUIREMENTS = {
"pathlib==1.0.1": "pathlib",
@ -269,6 +269,7 @@ class AzureBatchSetup(OpenMayaMPx.MPxCommand):
sys.path.append(modpath)
sys.path.append(srcpath)
sys.path.append(os.path.join(srcpath, "ui"))
sys.path.append(tolpath)
script_dirs = os.environ["MAYA_SCRIPT_PATH"] + os.pathsep
os.environ["AZUREBATCH_ICONS"] = AzureBatchSetup.clean(icnpath)
@ -349,7 +350,7 @@ def dependency_installed(package, namespace):
return True
def install_pkg(package):
def install_pkg(pip, package):
"""Install the specified package by shelling out to pip.
:param str package: A pip-formatted package reference.
@ -358,9 +359,7 @@ def install_pkg(package):
"""
if not os.path.isdir(INSTALL_DIR):
os.makedirs(INSTALL_DIR)
pip_cmds = ['mayapy', os.path.join(INSTALL_DIR, 'pip'),
'install', package,
'--target', INSTALL_DIR]
pip_cmds = ['mayapy', pip, 'install', package, '--target', INSTALL_DIR]
print(pip_cmds)
installer = subprocess.Popen(pip_cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
installer.wait()
@ -370,7 +369,7 @@ def install_pkg(package):
raise RuntimeError("Failed to install package: {}".format(package))
def install_namespace_pkg(package, namespace):
def install_namespace_pkg(pip, package, namespace):
"""Azure packages have issues installing one by one as they don't
unpackage correctly into the namespace directory. So we have to install
to a temp directory and move it to the right place.
@ -381,10 +380,7 @@ def install_namespace_pkg(package, namespace):
temp_target = os.path.join(INSTALL_DIR, 'temp-target')
if not os.path.isdir(temp_target):
os.makedirs(temp_target)
pip_cmds = ['mayapy', os.path.join(INSTALL_DIR, 'pip'),
'install', package,
'--no-deps',
'--target', temp_target]
pip_cmds = ['mayapy', pip, 'install', package, '--no-deps', '--target', temp_target]
print(pip_cmds)
installer = subprocess.Popen(pip_cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
installer.wait()
@ -447,25 +443,39 @@ def initializePlugin(obj):
print("Attempting to install dependencies via Pip.")
try:
install_script = os.path.normpath(os.path.join( os.environ['AZUREBATCH_TOOLS'], 'install_pip.py'))
installer = subprocess.Popen(["mayapy", install_script, '--target', INSTALL_DIR],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
installer.wait()
if installer.returncode != 0:
import pip
if StrictVersion(pip.__version__) < StrictVersion("9.0.0"):
print("Found out-of-date pip ({}) - attempting to upgrade.".format(pip.__version__))
raise ImportError
print("Found pip installed, version: {}".format(pip.__version__))
pip_location = os.path.dirname(pip.__file__)
except ImportError:
try:
import getpip
print("Running getpip command")
install_script = getpip.__file__
args = ["mayapy", install_script, "--target", INSTALL_DIR]
print(args)
installer = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
installer.wait()
print(installer.stdout.read())
print(installer.stderr.read())
raise RuntimeError("Failed to install pip")
except BaseException as exp:
print("Failed to install Pip. Please install dependencies manually to continue.")
raise
if installer.returncode != 0:
raise RuntimeError("Failed to install pip")
except ImportError as e:
print("Unable to load getpip")
raise
else:
print("Getpip complete")
pip_location = os.path.join(INSTALL_DIR, "pip")
try:
print("Installing dependencies")
print("Installing dependencies using {}".format(pip_location))
for package in missing_libs:
if package in NAMESPACE_PACKAGES:
package_path = NAMESPACE_PACKAGES[package].split('.')
install_namespace_pkg(package, os.path.join(*package_path))
install_namespace_pkg(pip_location, package, os.path.join(*package_path))
else:
install_pkg(package)
install_pkg(pip_location, package)
shutil.copy(os.path.join(INSTALL_DIR, 'azure', '__init__.py'), os.path.join(INSTALL_DIR, 'azure', 'mgmt', '__init__.py'))
except:
error = "Failed to install dependencies - please install manually"
@ -521,6 +531,7 @@ def uninitializePlugin(obj):
try:
sys.path.extend(os.environ["AZUREBATCH_SCRIPTS"].split(os.pathsep))
sys.path.append(os.environ['AZUREBATCH_MODULES'])
sys.path.append(os.environ['AZUREBATCH_TOOLS'])
except KeyError as e:
print("Couldn't find Azure Batch environment, setting up now...")
setup_module()

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,31 +0,0 @@
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import os
import tempfile
import sys
import urllib2
_GET_PIP = "https://bootstrap.pypa.io/get-pip.py"
if __name__ == '__main__':
temp_dir = os.path.join(tempfile.gettempdir(), 'azure-batch-maya')
if not os.path.isdir(temp_dir):
os.makedirs(temp_dir)
sys.path.append(temp_dir)
pip_script = os.path.join(temp_dir, 'getpip.py')
if not os.path.exists(pip_script):
with open(pip_script, 'w') as script:
data = urllib2.urlopen(_GET_PIP)
script.write(data.read())
import getpip
try:
getpip.main()
except BaseException as e:
import pip
sys.exit(0)