From b9f8dcfdb745c81a437549922f04d03ae7f45614 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Sun, 15 Nov 2015 19:53:54 -0600 Subject: add .exe to the script being invoked if missing on windows fixes #2126 --- pyramid/scripts/pserve.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pyramid/scripts/pserve.py b/pyramid/scripts/pserve.py index efad0cc68..95752a3be 100644 --- a/pyramid/scripts/pserve.py +++ b/pyramid/scripts/pserve.py @@ -428,6 +428,19 @@ a real process manager for your processes like Systemd, Circus, or Supervisor. arg = win32api.GetShortPathName(arg) return arg + def find_script_path(self, name): # pragma: no cover + """ + Return the path to the script being invoked by the python interpreter. + + There's an issue on Windows when running the executable from + a console_script causing the script name (sys.argv[0]) to + not end with .exe or .py and thus cannot be run via popen. + """ + if sys.platform == 'win32': + if not name.endswith('.exe') and not name.endswith('.py'): + name += '.exe' + return name + def daemonize(self): # pragma: no cover pid = live_pidfile(self.options.pid_file) if pid: @@ -573,7 +586,10 @@ a real process manager for your processes like Systemd, Circus, or Supervisor. else: self.out('Starting subprocess with monitor parent') while 1: - args = [self.quote_first_command_arg(sys.executable)] + sys.argv + args = [ + self.quote_first_command_arg(sys.executable), + self.find_script_path(sys.argv[0]), + ] + sys.argv[1:] new_environ = os.environ.copy() if reloader: new_environ[self._reloader_environ_key] = 'true' -- cgit v1.2.3