Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions easybuild/framework/easyconfig/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ def get_paths_for(subdir=EASYCONFIGS_PKG_SUBDIR, robot_path=None):
path = os.path.join(path, "easybuild", subdir)
_log.debug("Checking for easybuild/%s at %s" % (subdir, path))
try:
# FIXME: will not work on paths in zipped egg
if os.path.exists(path):
paths.append(os.path.abspath(path))
_log.debug("Added %s to list of paths for easybuild/%s" % (path, subdir))
Expand Down
32 changes: 20 additions & 12 deletions easybuild/tools/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"""
import glob
import os
import pkgutil
import string
import sys
from vsc.utils import fancylogger

import easybuild.tools.environment as env
from easybuild.tools.build_log import EasyBuildError


Expand Down Expand Up @@ -109,18 +109,26 @@ def import_available_modules(namespace):

@param namespace: The namespace to import modules from.
"""
modules = []
# determine list of paths where top-level package name is available
top_pkg = namespace.split('.')[0]
paths = []
for path in sys.path:
for module in sorted(glob.glob(os.path.sep.join([path] + namespace.split('.') + ['*.py']))):
if not module.endswith('__init__.py'):
mod_name = module.split(os.path.sep)[-1].split('.')[0]
modpath = '.'.join([namespace, mod_name])
_log.debug("importing module %s" % modpath)
try:
mod = __import__(modpath, globals(), locals(), [''])
except ImportError as err:
raise EasyBuildError("import_available_modules: Failed to import %s: %s", modpath, err)
modules.append(mod)
mod_names = [name for (_, name, _) in pkgutil.iter_modules(path=[path])]
if any([name.split('.')[0] == top_pkg for name in mod_names]):
paths.append(os.path.join(os.path.abspath(path), *namespace.split('.')))

# determine all (unique) module names
modnames = [mod for (_, mod, ispkg) in pkgutil.walk_packages(path=paths, prefix='%s.' % namespace) if not ispkg]

# import all modules found
modules = []
for modname in modnames:
try:
mod = __import__(modname, globals(), locals(), [''])
except ImportError as err:
raise EasyBuildError("import_available_modules: Failed to import %s: %s", modname, err)
modules.append(mod)

return modules


Expand Down
19 changes: 12 additions & 7 deletions easybuild/tools/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ def get_git_revision():

relies on GitPython (see http://gitorious.org/git-python)
"""
res = UNKNOWN
try:
import git
# __file__ may contain path in a zipped egg
if os.path.exists(__file__):
path = os.path.dirname(__file__)
try:
gitrepo = git.Git(path)
res = gitrepo.rev_list("HEAD").splitlines()[0]
except git.GitCommandError:
pass
except ImportError:
return UNKNOWN
try:
path = os.path.dirname(__file__)
gitrepo = git.Git(path)
return gitrepo.rev_list("HEAD").splitlines()[0]
except git.GitCommandError:
return UNKNOWN
pass

return res

git_rev = get_git_revision()
if git_rev == UNKNOWN:
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[bdist_rpm]
requires = environment-modules, bash, python >= 2.6, python < 3

[easy_install]

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def find_rel_test():
platforms="Linux",
provides=["eb"] + easybuild_packages,
test_suite="test.framework.suite",
zip_safe=False,
install_requires=["vsc-base >= 2.2.4"],
zip_safe=True,
install_requires=["vsc-base >= 2.3.0"],
extras_require = {
'yeb': ["PyYAML >= 3.11"],
},
Expand Down
Loading