Commits

Ronny Pfannschmidt committed 9ac918d

make script entry flexible

Comments (0)

Files changed (3)

genscript/pkgpacker.py

     tmpl = py.path.local(__file__).dirpath().join('standalonetemplate.py')
     exe = tmpl.read()
     exe = exe.replace('@SOURCES@', data)
+    exe = exe.replace('@ENTRY@', entry)
     return exe
 
 

genscript/standalonetemplate.py

     importer = DictImporter(sources)
     sys.meta_path.append(importer)
 
-    import py
-    py.test.cmdline.main()
+    entry = "@ENTRY@"
+    do_exec(entry, locals())
 from genscript.pkgpacker import generate_script
 
+script = generate_script(
+    entry='import py;py.test.cmdline.main()',
+    packages=['py', 'pytest'],
+)
+
 with open('script.py', 'w') as f:
-    f.write(generate_script(None, ['py', 'pytest']))
+    f.write(script)