Commits

Anonymous committed 1d501f9

Added a python runner.

Comments (0)

Files changed (2)

     entry_points={
         'console_scripts': [
             'xe = xenv.main:xe',
+            'xepython = xenv.main:xepython', 
             ]
         }
     )
 definition describes the usage and UI for interacting with an xenv.
 '''
 import os
+import sys
 from subprocess import call
 
 from argparse import ArgumentParser
                                The default is the current directory')
         install_pkg.set_defaults(func=install_package_cmd)
 
-        # install a package
+        # uninstall a package
         uninstall_pkg = self.subs.add_parser('uninstall',
                                              help='Install a package in an xenv')
         uninstall_pkg.add_argument('name', help='The package to uninstall')
         uninstall_pkg.set_defaults(func=uninstall_package_cmd)
 
     def run(self, args=None):
-        if not args:
-            args = self.parser.parse_known_args()
-        else:
-            args = self.parser.parse_args(args)
-        return args
+        if args:
+            return self.parser.parse_args(args)
+        return self.parser.parse_known_args()
     
 
-def xe():
-    cli = CLI()
-    args, extras = cli.run()
+def _run(args):
     if args.root:
         args.root = os.path.abspath(args.root)
     if args.func:
         args.func(args)
+    
+def xe():
+    cli = CLI()
+    args, extras = cli.run()
+    _run(args)
         
+def xepython():
+    cli = CLI()
+    cargs = ['run', 'python']
+    if len(sys.argv) > 1:
+        cargs.extend(sys.argv[1:])
+    args = cli.run(cargs)
+    _run(args)    
+