-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.py
45 lines (35 loc) · 1.12 KB
/
install.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
"""Drop this file in a Maya viewport to install MayaX."""
import os
import sys
from maya import cmds
def onMayaDroppedPythonFile(*_):
"""Install when the file is dropped in the viewport."""
rootPath = os.path.dirname(os.path.realpath(__file__))
sourcePath = os.path.join(rootPath, 'src')
mayaModulesPath = os.path.normpath(
os.path.join(
cmds.internalVar(userAppDir=True),
cmds.about(version=True),
'modules',
)
)
moduleFilename = os.path.join(mayaModulesPath, 'mayax.mod')
if sourcePath not in sys.path:
sys.path.append(sourcePath)
from mayax import __version__
if not os.path.exists(mayaModulesPath):
os.makedirs(mayaModulesPath)
with open(moduleFilename, mode='w') as moduleFile:
moduleContent = '\n'.join(
[
'+ MayaX {} {}'.format(__version__, rootPath),
'scripts: src',
]
)
moduleFile.write(moduleContent)
cmds.confirmDialog(
title='MayaX',
message='MayaX was installed.',
button='OK',
icon='information',
)