PATCH 1/2 is needed to make addons work.
Martin Sivak (1): Try to import modules the standard way first in collect
Vratislav Podzimek (1): Use %_prefix macro value when calling configure in makeupdates
pyanaconda/addons.py | 6 +++--- pyanaconda/ui/common.py | 29 +++++++++++++++++++++++++++-- scripts/makeupdates | 4 ++-- 3 files changed, 32 insertions(+), 7 deletions(-)
From: Martin Sivak msivak@redhat.com
This ensures that the correct package structure is present in sys.path for modules and addons that make use of it.
The package-less addons will be imported file by file with the package structure ensured by dummy empty modules.
This also changes module masks for addons to make the change work properly.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- pyanaconda/addons.py | 6 +++--- pyanaconda/ui/common.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/pyanaconda/addons.py b/pyanaconda/addons.py index 77792be..7c517c6 100644 --- a/pyanaconda/addons.py +++ b/pyanaconda/addons.py @@ -50,15 +50,15 @@ def collect_addon_paths(toplevel_addon_paths, ui_subdir="gui"): for addon_id in directories: addon_ks_path = os.path.join(path, addon_id, "ks") if os.path.isdir(addon_ks_path): - module_paths["ks"].append(("pyanaconda.addon.%s.ks.%%s" % addon_id, addon_ks_path)) + module_paths["ks"].append(("%s.ks.%%s" % addon_id, addon_ks_path))
addon_spoke_path = os.path.join(path, addon_id, ui_subdir, "spokes") if os.path.isdir(addon_spoke_path): - module_paths["spokes"].append(("pyanaconda.addon.%s.spokes.%%s" % addon_id, addon_spoke_path)) + module_paths["spokes"].append(("%s.%s.spokes.%%s" % (addon_id, ui_subdir), addon_spoke_path))
addon_category_path = os.path.join(path, addon_id, ui_subdir, "categories") if os.path.isdir(addon_spoke_path): - module_paths["categories"].append(("pyanaconda.addon.%s.categories.%%s" % addon_id, addon_category_path)) + module_paths["categories"].append(("%s.%s.categories.%%s" % (addon_id, ui_subdir), addon_category_path))
return module_paths
diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py index c94861e..29c97fe 100644 --- a/pyanaconda/ui/common.py +++ b/pyanaconda/ui/common.py @@ -25,6 +25,7 @@ import imp import inspect import copy import sys +import types
class PathDict(dict): """Dictionary class supporting + operator""" @@ -500,8 +501,32 @@ def collect(module_pattern, path, pred): # do not load module if any module with the same name # is already imported if not module: - module = imp.load_module(module_pattern % mod_name, - fo, module_path, module_flags) + # try importing the module the standard way first + # uses sys.path and the module's full name! + try: + __import__(module_pattern % mod_name) + module = sys.modules[module_pattern % mod_name] + + # if it fails (package-less addon?) try importing single file + # and filling up the package structure voids + except ImportError: + # prepare dummy modules to prevent RuntimeWarnings + module_parts = (module_pattern % mod_name).split(".") + + # remove the last name as it will be inserted by the import + module_parts.pop() + + # make sure all "parent" modules are in sys.modules + for l in range(len(module_parts)): + module_part_name = ".".join(module_parts[:l+1]) + if module_part_name not in sys.modules: + module_part = types.ModuleType(module_part_name) + module_part.__path__ = [path] + sys.modules[module_part_name] = module_part + + # load the collected module + module = imp.load_module(module_pattern % mod_name, + fo, module_path, module_flags)
# get the filenames without the extensions so we can compare those
Otherwise all the paths end up with the /usr/local prefix and e.g. the timezone map doesn't find its images.
Signed-off-by: Vratislav Podzimek vpodzime@redhat.com --- scripts/makeupdates | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/makeupdates b/scripts/makeupdates index 21b25ec..1ffb166 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -218,7 +218,7 @@ def copyUpdatedIsys(updates, cwd): if not os.path.isfile('Makefile'): if not os.path.isfile('configure'): os.system('./autogen.sh') - os.system('./configure') + os.system('./configure --prefix=`rpm --eval %_prefix`')
os.system('make')
@@ -257,7 +257,7 @@ def copyUpdatedWidgets(updates, cwd): if not os.path.isfile('Makefile'): if not os.path.isfile('configure'): os.system('./autogen.sh') - os.system('./configure --enable-gtk-doc --enable-introspection') + os.system('./configure --prefix=`rpm --eval %_prefix` --enable-gtk-doc --enable-introspection')
os.system('make')
PATCH 1/2 is needed to make addons work.
Martin Sivak (1): Try to import modules the standard way first in collect
Vratislav Podzimek (1): Use %_prefix macro value when calling configure in makeupdates
pyanaconda/addons.py | 6 +++--- pyanaconda/ui/common.py | 29 +++++++++++++++++++++++++++-- scripts/makeupdates | 4 ++-- 3 files changed, 32 insertions(+), 7 deletions(-)
These look fine.
- Chris
anaconda-patches@lists.fedorahosted.org