Commit a80e5063 by Maxime Chéramy

Fix import for PyInstaller.

Also remove a Non-ASCII character for Python2...
parent f3eb8594
...@@ -241,14 +241,37 @@ class Scheduler(object): ...@@ -241,14 +241,37 @@ class Scheduler(object):
def get_schedulers(): def get_schedulers():
package = importlib.import_module('simso.schedulers') modules = []
for importer, modname, ispkg in pkgutil.walk_packages(
path=package.__path__, # Special case when using PyInstaller:
prefix=package.__name__ + '.', if getattr(sys, 'frozen', False):
onerror=lambda x: None): import pyi_importers
m = importlib.import_module(modname) importer = None
for name in dir(m): for obj in sys.meta_path:
c = m.__getattribute__(name) if isinstance(obj, pyi_importers.FrozenImporter):
if inspect.isclass(c) and issubclass(c, Scheduler): importer = obj
yield modname
break break
for name in importer.toc:
if name.startswith('simso.schedulers.'):
modules.append(name)
# Normal case:
else:
package = importlib.import_module('simso.schedulers')
for importer, modname, ispkg in pkgutil.walk_packages(
path=package.__path__,
prefix=package.__name__ + '.',
onerror=lambda x: None):
modules.append(modname)
for modname in sorted(modules):
try:
m = importlib.import_module(modname)
for name in dir(m):
c = m.__getattribute__(name)
if inspect.isclass(c) and issubclass(c, Scheduler):
yield modname
break
except (ImportError, SyntaxError):
print("Import error: ", modname)
""" """
Implementation of the BF algorithm. Implementation of the BF algorithm.
Authors: Maxime Chéramy and Stefan Junker Authors: Maxime Cheramy and Stefan Junker
""" """
from simso.core import Scheduler, Timer from simso.core import Scheduler, Timer
from fractions import Fraction from fractions import Fraction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment