-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.py
176 lines (137 loc) · 3.87 KB
/
package.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
early = globals()["early"]
late = globals()["late"]
name = "avalon"
description = "The safe post-production pipeline"
_data = {
"label": "Avalon",
"icon": "{root}/res/icons/ico/avalon.ico"
}
@early()
def __payload():
import os
from earlymod import util
def get_version(data):
import subprocess
data["version"] = subprocess.check_output(
["python", "setup.py", "--version"],
universal_newlines=True,
cwd=data["repo"],
).strip()
local = {
"path": os.path.sep.join([os.environ["MY_DEVS"], "avalon-core"]),
"tag": "localdev",
}
remote = {
"url": "https://github.com/MoonShineVFX/avalon-core.git",
"branch": "production",
"tag": "91e31cac94cb814d4829c5ba26b0e53dde8f3d7d",
}
return util.git_payload(
local=local,
remote=remote,
callbacks=[get_version]
)
@early()
def version():
data = globals()["this"].__payload
version_str = data["version"]
branch_name = data["branch"]
major, minor, patch = version_str.split(".")
return "%s-%s.%s.%s" % (branch_name, major, minor, patch)
@early()
def authors():
data = globals()["this"].__payload
return data["authors"]
@late()
def tools():
in_context = globals()["in_context"]
# Avalon tools
_tools = [
"loader",
]
if in_context():
context = globals()["context"]
for pkg in context.resolved_packages:
if getattr(pkg, "is_project_admin", False):
_tools.append("manager")
break
return _tools
requires = [
# Dependencies
"house",
"pymongo",
"Qt.py",
]
private_build_requires = ["rezutil-1"]
@early()
def build_command():
data = globals()["this"].__payload
return "python -m rezutil build {root} --quiet".format(
root=data["repo"],
)
def pre_commands():
env = globals()["env"]
# (NOTE) convert it into `list` or it will always return True when
# checking __contains__.
# >>> "anything" in env.keys()
# True
# >>> "anything" in list(env.keys())
# False
#
current_env_keys = list(env.keys())
env.AVALON_SESSION_SCHEMA = "avalon-core:session-3.0"
session_v3_required = [
"AVALON_PROJECTS",
"AVALON_PROJECT",
"AVALON_CONFIG",
]
for key in session_v3_required:
if key not in current_env_keys:
env[key] = "__placeholder__"
# Set up environment
def commands():
env = globals()["env"]
resolve = globals()["resolve"]
env.PYTHONPATH.prepend("{root}")
# MongoDB
env.AVALON_MONGO = "{env.HOUSE_PIPELINE_MONGO}"
env.AVALON_DB = "avalon"
env.AVALON_TIMEOUT = 5000
# DCC App Setup
if "maya" in resolve:
env.PYTHONPATH.append("{root}/setup/maya")
env.AVALON_APP = "maya"
env.AVALON_APP_NAME = "maya"
if "houdini" in resolve:
env.HOUDINI_SCRIPT_PATH.append("{root}/res/houdini")
env.AVALON_APP = "houdini"
env.AVALON_APP_NAME = "houdini"
if "nuke" in resolve:
env.NUKE_PATH.append("{root}/setup/nuke/nuke_path")
env.AVALON_APP = "nuke"
env.AVALON_APP_NAME = "nuke"
def post_commands():
import os
env = globals()["env"]
# (NOTE) convert it into `list` or it will always return True when
# checking __contains__.
# >>> "anything" in env.keys()
# True
# >>> "anything" in list(env.keys())
# False
#
current_env_keys = list(env.keys())
# Startup workdir
required = [
"AVALON_PROJECTS",
"AVALON_PROJECT",
"AVALON_APP",
]
if all(k in current_env_keys for k in required):
env.AVALON_WORKDIR = os.path.sep.join([
"{env.AVALON_PROJECTS}",
"{env.AVALON_PROJECT}",
"Avalon",
"_Lobby",
"{env.AVALON_APP}",
])