51 lines
1.2 KiB
Python
Executable File
51 lines
1.2 KiB
Python
Executable File
#! /usr/bin/env python
|
|
|
|
sources = """
|
|
@SOURCES@"""
|
|
|
|
import sys
|
|
import cPickle
|
|
import base64
|
|
import zlib
|
|
import imp
|
|
|
|
sources = cPickle.loads(zlib.decompress(base64.decodestring(sources)))
|
|
|
|
class DictImporter(object):
|
|
sources = sources
|
|
def find_module(self, fullname, path=None):
|
|
if fullname in self.sources:
|
|
return self
|
|
if fullname+'.__init__' in self.sources:
|
|
return self
|
|
return None
|
|
|
|
def load_module(self, fullname):
|
|
# print "load_module:", fullname
|
|
import new
|
|
|
|
try:
|
|
s = self.sources[fullname]
|
|
is_pkg = False
|
|
except KeyError:
|
|
s = self.sources[fullname+'.__init__']
|
|
is_pkg = True
|
|
|
|
co = compile(s, fullname, 'exec')
|
|
module = sys.modules.setdefault(fullname, new.module(fullname))
|
|
module.__file__ = "%s/%s" % (__file__, fullname)
|
|
module.__loader__ = self
|
|
if is_pkg:
|
|
module.__path__ = [fullname]
|
|
|
|
exec co in module.__dict__
|
|
return sys.modules[fullname]
|
|
|
|
importer = DictImporter()
|
|
|
|
sys.meta_path.append(importer)
|
|
|
|
if __name__ == "__main__":
|
|
import py
|
|
py.cmdline.pytest()
|