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):
def get_schedulers():
modules = []
# Special case when using PyInstaller:
if getattr(sys, 'frozen', False):
import pyi_importers
importer = None
for obj in sys.meta_path:
if isinstance(obj, pyi_importers.FrozenImporter):
importer = obj
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.
Authors: Maxime Chéramy and Stefan Junker
Authors: Maxime Cheramy and Stefan Junker
"""
from simso.core import Scheduler, Timer
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