Skip to content

Commit

Permalink
Never check process environment in stand-alone mode. (#13)
Browse files Browse the repository at this point in the history
As pointed out by @shomikverma, this check gets in the way when
setting `DYLD_FALLBACK_LIBRARY_PATH` instead of `DYLD_LIBRARY_PATH`,
which may be the better setup. It is the user's reponsibiliy to
correctly configure the environment, we should not interfere with
that as long as we're unsure if we have the best solution. The
sanity check of environment variables was therefore removed.
  • Loading branch information
john-hen committed May 21, 2022
1 parent 2b967b7 commit 593f52a
Showing 1 changed file with 0 additions and 62 deletions.
62 changes: 0 additions & 62 deletions mph/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ def __init__(self, cores=None, version=None, port=None, host='localhost'):
if cores:
os.environ['COMSOL_NUM_THREADS'] = str(cores)

# Check correct setup of process environment if on Linux/macOS.
check_environment(backend)

# Initialize the environment with GUI support disabled.
# See `initStandalone()` method in [1].
java.initStandalone(False)
Expand Down Expand Up @@ -441,62 +438,3 @@ def disconnect(self):
error = 'The client is not connected to a server.'
log.error(error)
raise RuntimeError(error)


########################################
# Environment #
########################################

def check_environment(backend):
"""Checks the process environment required for a stand-alone client."""
system = platform.system()
root = backend['root']
help = 'Refer to chapter "Limitations" in the documentation for help.'
if system == 'Windows':
pass
elif system == 'Linux':
var = 'LD_LIBRARY_PATH'
if var not in os.environ:
error = f'Library search path {var} not set in environment.'
log.error(error)
raise RuntimeError(error + '\n' + help)
path = os.environ[var].split(os.pathsep)
lib = root/'lib'/'glnxa64'
if str(lib) not in path:
error = f'Folder "{lib}" missing in library search path.'
log.error(error)
raise RuntimeError(error + '\n' + help)
gcc = root/'lib'/'glnxa64'/'gcc'
if gcc.exists() and str(gcc) not in path:
log.warning(f'Folder "{gcc}" missing in library search path.')
gra = str(root/'ext'/'graphicsmagick'/'glnxa64')
if str(gra) not in path:
error = f'Folder "{gra}" missing in library search path.'
log.error(error)
raise RuntimeError(error + '\n' + help)
cad = root/'ext'/'cadimport'/'glnxa64'
if cad.exists() and str(cad) not in path:
log.warning(f'Folder "{cad}" missing in library search path.')
elif system == 'Darwin':
var = 'DYLD_LIBRARY_PATH'
if var not in os.environ:
error = f'Library search path {var} not set in environment.'
log.error(error)
raise RuntimeError(error + '\n' + help)
if var in os.environ:
path = os.environ[var].split(os.pathsep)
else:
path = []
lib = root/'lib'/'maci64'
if str(lib) not in path:
error = f'Folder "{lib}" missing in library search path.'
log.error(error)
raise RuntimeError(error + '\n' + help)
gra = root/'ext'/'graphicsmagick'/'maci64'
if str(gra) not in path:
error = f'Folder "{gra}" missing in library search path.'
log.error(error)
raise RuntimeError(error + '\n' + help)
cad = root/'ext'/'cadimport'/'maci64'
if cad.exists() and str(cad) not in path:
log.warning(f'Folder "{cad}" missing in library search path.')

0 comments on commit 593f52a

Please sign in to comment.