From 86efda0e4552610a87276c18cfeb90371e7670ba Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 1 Aug 2017 12:30:34 +0300 Subject: Add: run setup.py directly if executable --- bumper | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bumper b/bumper index b847f94..bcf8899 100755 --- a/bumper +++ b/bumper @@ -17,7 +17,9 @@ # =*= License: GPL-3+ =*= +import os import re +import stat import time import cliapp @@ -104,7 +106,17 @@ class Bumper(cliapp.Application): return version_files[0] def run_setup(self, *args): - return cliapp.runcmd(['python', 'setup.py'] + list(args)).strip() + prefix = None + + # If we can run setup.py directly, we do. This takes care of Py2 vs Py3. + st = os.lstat('setup.py') + if (stat.S_IMODE(st.st_mode) & stat.S_IXUSR) == stat.S_IXUSR: + prefix = ['./setup.py'] + + if prefix is None: + prefix = ['python', 'setup.py'] + + return cliapp.runcmd(prefix + list(args)).strip() def get_current_version(self): return self.run_setup('--version') -- cgit v1.2.1