You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ariatosca.apache.org by mx...@apache.org on 2017/11/02 15:13:07 UTC
[5/5] incubator-ariatosca git commit: ARIA-392 Failing to load
ruamel.yaml
ARIA-392 Failing to load ruamel.yaml
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/f805204c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/f805204c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/f805204c
Branch: refs/heads/ARIA-392-Failing-to-load-ruamel.yaml
Commit: f805204c89fd7a13c927d78d23695b1b09ba3619
Parents: b1f03ef
Author: max-orlov <ma...@gigaspaces.com>
Authored: Mon Oct 23 15:58:14 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Thu Nov 2 17:12:54 2017 +0200
----------------------------------------------------------------------
aria/__init__.py | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f805204c/aria/__init__.py
----------------------------------------------------------------------
diff --git a/aria/__init__.py b/aria/__init__.py
index 9fe8b3d..a4ea403 100644
--- a/aria/__init__.py
+++ b/aria/__init__.py
@@ -17,14 +17,45 @@
The ARIA root package provides entry points for extension and storage initialization.
"""
+import os
import sys
+import types
from pkgutil import iter_modules
import pkg_resources
-
aria_package_name = 'apache-ariatosca'
__version__ = pkg_resources.get_distribution(aria_package_name).version
+
+
+
+try:
+ import ruamel # noqa: F401
+except ImportError:
+ if sys.version_info[0] > 2:
+ raise
+
+ # Traverse all of the site-packages and try to load ruamel.
+ for packages_dir in sys.path:
+ ruamel_path = os.path.join(packages_dir, 'ruamel')
+ if not os.path.exists(ruamel_path):
+ continue
+
+ # If the top dir has an __init__.py file, the loading should have
+ # succeeded automatically
+ if os.path.exists(os.path.join(ruamel_path, '__init__.py')):
+ raise
+
+ # Dynamically create mapping to the ruamel package
+ ruamel_module = sys.modules.setdefault(
+ 'ruamel',
+ types.ModuleType('ruamel')
+ )
+ # add path to the mapped package
+ ruamel_module.__dict__.setdefault('__path__', []).append(ruamel_path)
+
+
+
from .orchestrator.decorators import workflow, operation # pylint: disable=wrong-import-position
from . import ( # pylint: disable=wrong-import-position
extension,