Place the new egg config options into the environment at Galaxy startup since

eggs.require() has no access to the config file.
This commit is contained in:
Nate Coraor
2015-02-12 14:27:37 -05:00
parent 6ff8aa97f7
commit 1e07117791
+37 -3
View File
@@ -7,6 +7,11 @@ top level directly.
import os, sys
try:
import configparser
except:
import ConfigParser as configparser
# ensure supported version
from check_python import check_python
try:
@@ -19,15 +24,44 @@ new_path.extend( sys.path[1:] ) # remove scripts/ from the path
sys.path = new_path
from galaxy import eggs
import pkg_resources
if 'LOG_TEMPFILES' in os.environ:
from log_tempfile import TempFile
_log_tempfile = TempFile()
import tempfile
pkg_resources.require( "Paste" )
pkg_resources.require( "PasteDeploy" )
try:
serve = sys.argv.index('serve')
except:
print >>sys.stderr, "Galaxy does not use the real Paste Script, the only supported command is 'serve'"
sys.exit(1)
# eggs.require() can be called inside the app without access to the Galaxy
# config, so we need to push the egg options into the environment so they are
# available to Crate instantiated in require()
# locate the arg containing the path to the config file
config = None
p = configparser.ConfigParser()
for arg in sys.argv:
try:
p.read(arg)
assert 'app:main' in p.sections()
config = arg
break
except (configparser.Error, AssertionError):
pass
# find any egg options set in the config
crate = eggs.Crate(config)
for opt in ('enable_eggs', 'enable_egg_fetch', 'try_dependencies_from_env'):
env = 'GALAXY_CONFIG_' + opt.upper()
# don't overwrite existing env vars configured by the user
if env not in os.environ:
os.environ[env] = str(getattr(crate.galaxy_config, opt))
eggs.require( "Paste" )
eggs.require( "PasteDeploy" )
from galaxy.util.pastescript import serve
serve.run()