mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
remapping handling pushed to pype publish command
This commit is contained in:
parent
1a6462d358
commit
408c220df8
1 changed files with 5 additions and 22 deletions
|
|
@ -26,7 +26,6 @@ error_format = "Failed {plugin.__name__}: {error} -- {error.traceback}"
|
||||||
|
|
||||||
|
|
||||||
def __main__():
|
def __main__():
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--paths",
|
parser.add_argument("--paths",
|
||||||
nargs="*",
|
nargs="*",
|
||||||
|
|
@ -46,27 +45,11 @@ def __main__():
|
||||||
print("Running pype ...")
|
print("Running pype ...")
|
||||||
auto_pype_root = os.path.dirname(os.path.abspath(__file__))
|
auto_pype_root = os.path.dirname(os.path.abspath(__file__))
|
||||||
auto_pype_root = os.path.abspath(auto_pype_root + "../../../../..")
|
auto_pype_root = os.path.abspath(auto_pype_root + "../../../../..")
|
||||||
# we need to use `auto_pype_root` to be able to remap locations.
|
|
||||||
# This is egg and chicken case: we need to know our storage locations
|
|
||||||
# to be able to remap them on different platforms but if we got `PYPE_ROOT`
|
|
||||||
# variable, we cannot be sure it originated on different platform and is
|
|
||||||
# therefor invalid.
|
|
||||||
# So we use auto_pype_root to get to `PypeLauncher.path_remapper()`. This
|
|
||||||
# will load Storage environments and is able to remap environment to
|
|
||||||
# correct paths.
|
|
||||||
sys.path.append(auto_pype_root)
|
|
||||||
try:
|
|
||||||
from pypeapp import PypeLauncher
|
|
||||||
except ImportError:
|
|
||||||
print("!!! Error: cannot determine Pype location.")
|
|
||||||
print("--- we are looking at {}, but this is not Pype.".format(
|
|
||||||
auto_pype_root))
|
|
||||||
|
|
||||||
remapped_env = PypeLauncher.path_remapper()
|
auto_pype_root = os.environ.get('PYPE_ROOT') or auto_pype_root
|
||||||
auto_pype_root = remapped_env.get('PYPE_ROOT') or auto_pype_root
|
if os.environ.get('PYPE_ROOT'):
|
||||||
if remapped_env.get('PYPE_ROOT'):
|
|
||||||
print("Got Pype location from environment: {}".format(
|
print("Got Pype location from environment: {}".format(
|
||||||
remapped_env.get('PYPE_ROOT')))
|
os.environ.get('PYPE_ROOT')))
|
||||||
|
|
||||||
pype_command = "pype.ps1"
|
pype_command = "pype.ps1"
|
||||||
if platform.system().lower() == "linux":
|
if platform.system().lower() == "linux":
|
||||||
|
|
@ -92,7 +75,7 @@ def __main__():
|
||||||
print("Set pype root to: {}".format(pype_root))
|
print("Set pype root to: {}".format(pype_root))
|
||||||
print("Paths: {}".format(kwargs.paths or [os.getcwd()]))
|
print("Paths: {}".format(kwargs.paths or [os.getcwd()]))
|
||||||
|
|
||||||
paths = kwargs.paths or [os.getcwd()]
|
paths = kwargs.paths or [os.environ.get("PYPE_METADATA_FILE")] or [os.getcwd()] # noqa
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
os.path.join(pype_root, pype_command),
|
os.path.join(pype_root, pype_command),
|
||||||
|
|
@ -104,7 +87,7 @@ def __main__():
|
||||||
# Forcing forwaring the environment because environment inheritance does
|
# Forcing forwaring the environment because environment inheritance does
|
||||||
# not always work.
|
# not always work.
|
||||||
# Cast all values in environment to str to be safe
|
# Cast all values in environment to str to be safe
|
||||||
env = {k: str(v) for k, v in remapped_env.items()}
|
env = {k: str(v) for k, v in os.environ.items()}
|
||||||
exit_code = subprocess.call(args, env=env)
|
exit_code = subprocess.call(args, env=env)
|
||||||
if exit_code != 0:
|
if exit_code != 0:
|
||||||
raise RuntimeError("Publishing failed.")
|
raise RuntimeError("Publishing failed.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue