mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 15:20:16 +00:00
update py command
This commit is contained in:
@@ -28,6 +28,18 @@ class PyCommand(Command):
|
||||
default=False,
|
||||
help="Show the running python version."
|
||||
)
|
||||
self.parser.add_option(
|
||||
"-b", "--bin",
|
||||
dest="bin",
|
||||
default='python',
|
||||
help="Use the specified script in python's bin directory."
|
||||
)
|
||||
self.parser.add_option(
|
||||
"-o", "--options",
|
||||
dest="options",
|
||||
default='',
|
||||
help="Options passed directly to runs script."
|
||||
)
|
||||
|
||||
def run_command(self, options, args):
|
||||
if not args:
|
||||
@@ -37,16 +49,18 @@ class PyCommand(Command):
|
||||
|
||||
pythons = self._get_pythons(options.pythons)
|
||||
for d in pythons:
|
||||
path = os.path.join(PATH_PYTHONS, d, 'bin', 'python')
|
||||
path = os.path.join(PATH_PYTHONS, d, 'bin', options.bin)
|
||||
if os.path.isfile(path) and os.access(path, os.X_OK):
|
||||
if options.verbose:
|
||||
logger.info('*** %s ***' % d)
|
||||
p = Popen("%s %s" % (path, python_file), shell=True)
|
||||
p = Popen("%s %s %s" % (path, options.options, python_file), shell=True)
|
||||
p.wait()
|
||||
else:
|
||||
logger.info('%s: No such file or directory.' % path)
|
||||
|
||||
def _get_pythons(self, _pythons):
|
||||
pythons = [Package(p).name for p in _pythons]
|
||||
return [d for d in sorted(os.listdir(PATH_PYTHONS))
|
||||
return [d for d in sorted(os.listdir(PATH_PYTHONS))
|
||||
if not pythons or d in pythons]
|
||||
|
||||
PyCommand()
|
||||
|
||||
@@ -3,6 +3,8 @@ from tests import TESTPY_FILE
|
||||
class PyOptions(object):
|
||||
pythons = []
|
||||
verbose = False
|
||||
bin = "python"
|
||||
options = ""
|
||||
|
||||
def _create_pyfile():
|
||||
fp = open(TESTPY_FILE, 'w')
|
||||
|
||||
Reference in New Issue
Block a user