diff --git a/houy.py b/houy.py index 8084e9d..99a5587 100755 --- a/houy.py +++ b/houy.py @@ -1,6 +1,5 @@ #!/usr/bin/python3 - from subprocess import call from sys import argv, platform, exit, stderr from os import environ, getenv, chdir @@ -25,7 +24,7 @@ def enter_hfs(): exit(1) if hfsen.get(platform): h = list(hfsen[platform]) - print('Found: ', ', '.join(f.name for f in h), '*', sep='') + print('HFS environment found: ', ', '.join(f.name for f in h), '*', sep='') hfs = h[-1] else: print("ERROR - couldn't find HFS") @@ -40,40 +39,53 @@ def enter_hfs(): chdir(hfs) return hfs -def welcome_redshift(): - if platform == 'win32': - if '-rs3' in argv: - redshift_path = 'C:/ProgramData/Redshift3' +def init_opencl(): + environ.update({ + 'HOUDINI_OCL_DEVICETYPE': 'GPU', + 'HOUDINI_OCL_DEVICENUMBER': '0', + }) + +def init_redshift(ver=0): + global plugins, redshift_path + rs_path = { + 'linux': Path('/').glob('*/redshift' + (ver and str(ver) or '')), + 'win32': Path(r'C:/ProgramData').glob('Redshift*'), + } + rs_path['darwin'] = rs_path['linux'] + + # choose version + paths = [p for p in rs_path[platform]] + if paths: + redshift_path = paths[0] + print('Redshift found:',str(redshift_path)) + plugins = sorted(redshift_path.glob('redshift4houdini/[1-9]*')) + if plugins: + plugin = str(plugins[-1]) + print('Redshift plugins found:', plugin) + environ.update({ + 'PATH': ';'.join(['{}/bin'.format(str(redshift_path)), + environ.get('PATH')]), + 'REDSHIFT_COREDATAPATH': str(redshift_path), + 'HOUDINI_PATH': "{};&".format(plugin), + }) else: - redshift_path = 'C:/ProgramData/Redshift' + print('Redshift: no plugins found') else: - if '-rs3' in argv: - redshift_path = '/opt/redshift3' - else: - redshift_path = '/opt/redshift' - return redshift_path - -if __name__ == '__main__': - enter_hfs() - redshift_path = welcome_redshift() - if redshift_path: - print('Redshift:', redshift_path) + print('Redshift not found') +def init_faststart(): environ.update({ 'HOUDINI_NO_SPLASH': '1', 'HOUDINI_DSO_ERROR': '2', - 'PATH': ';'.join(['{}/bin'.format(redshift_path), - environ.get('PATH')]), - 'REDSHIFT_COREDATAPATH': redshift_path, - 'HOUDINI_OCL_DEVICETYPE': 'GPU', - 'HOUDINI_OCL_DEVICENUMBER': '0', - 'HOUDINI_PATH': "{}/Plugins/Houdini/17.5.173;&".format(redshift_path), }) + +def init_remote_gl(): if platform == 'win32': print() print('For OpenGL support remotely run this as an administrator:') print(r'c:\Windows\System32\tscon.exe {} /dest:console'.format(getenv('SessionName'))) +def init_env(): # Initialize env vars. if platform != 'win32': command = shlex.split("env -i sh -c '. houdini_setup >/dev/null && env'") @@ -84,4 +96,14 @@ if __name__ == '__main__': environ[key] = value print(key, '=', value) proc.communicate() + + +if __name__ == '__main__': + enter_hfs() + init_faststart() + init_opencl() + init_redshift() + init_remote_gl() + # init_env is not needed anymore + #init_env() call(['./bin/houdini'], env=environ)