def getEnviron(): """ Load the environment variables needed for Spider. If SPIDER_DIR is defined, the bin, man and proc folders will be defined from it. If not, each of them should be defined separately. """ global SPIDER env = Environ(os.environ) SPIDER_DIR = env.get('SPIDER_DIR', None) # Scipion definition if SPIDER_DIR is None: errors = '' for var in ['SPBIN_DIR', 'SPMAN_DIR', 'SPPROC_DIR']: if not var in env: errors += "\n Missing SPIDER variable: '%s'" % var if len(errors): print "ERRORS: " + errors else: env.update({'SPBIN_DIR': join(SPIDER_DIR, 'bin') + '/', # Spider needs this extra slash at the end 'SPMAN_DIR': join(SPIDER_DIR, 'man') + '/', 'SPPROC_DIR': join(SPIDER_DIR, 'proc') + '/' }) # Get the executable or 'spider' by default SPIDER = join(env['SPBIN_DIR'], env.get('SPIDER', 'spider_linux_mp_intel64')) # expand ~ and vars SPIDER = abspath(os.path.expanduser(os.path.expandvars(SPIDER))) env.set('PATH', env['SPBIN_DIR'], env.END) return env
def getEnviron(cls, gpuId='0'): """ Setup the environment variables needed to launch cryocare. """ environ = Environ(os.environ) if 'PYTHONPATH' in environ: # this is required for python virtual env to work del environ['PYTHONPATH'] environ.update({'CUDA_VISIBLE_DEVICES': gpuId}) cudaLib = environ.get(CRYOCARE_CUDA_LIB, pwem.Config.CUDA_LIB) environ.addLibrary(cudaLib) return environ