From 597f8c3291a42361739d37b9054fae405c56b7a2 Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Sun, 30 Oct 2016 17:06:38 -0500 Subject: [PATCH 1/9] subprocess.call on windows --- pgxnclient/cli.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pgxnclient/cli.py b/pgxnclient/cli.py index a884380..f1a42d4 100644 --- a/pgxnclient/cli.py +++ b/pgxnclient/cli.py @@ -114,7 +114,27 @@ def command_dispatch(argv=None): # through the current executable. argv.insert(0, sys.executable) - os.execv(argv[0], argv) + import platform + if platform.system() == 'Windows': + # + # On Windows, the [Popen] class uses the Windows CreateProcess() function. + # + # If env is not None, it must be a mapping that defines the environment variables + # for the new process; these are used instead of the default behavior of + # inheriting the current process’ environment. + # + # https://docs.python.org/3.3/library/subprocess.html#replacing-the-os-spawn-family + # + # os.exec on Windows + # http://stackoverflow.com/questions/7004687/os-exec-on-windows + # + # sys.executable: get current /path/to/python.exe that is being used + # + import subprocess + all_argv = [sys.executable] + argv + subprocess.call(all_argv) + else: + os.execv(argv[0], argv) def _get_exec(cmd): fn = find_script('pgxn-' + cmd) From cb47a2858070d12d54fefab80c105d8aaeecea50 Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Sun, 30 Oct 2016 17:10:56 -0500 Subject: [PATCH 2/9] pg_config.exe on windows --- pgxnclient/commands/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pgxnclient/commands/__init__.py b/pgxnclient/commands/__init__.py index 9b0fedb..fe99692 100644 --- a/pgxnclient/commands/__init__.py +++ b/pgxnclient/commands/__init__.py @@ -458,9 +458,15 @@ def customize_parser(self, parser, subparsers, **kwargs): subp = super(WithPgConfig, self).customize_parser( parser, subparsers, **kwargs) - subp.add_argument('--pg_config', metavar="PROG", default='pg_config', - help = _("the pg_config executable to find the database" - " [default: %(default)s]")) + import platform + if platform.system() == 'Windows': + subp.add_argument('--pg_config', metavar="PROG", default='pg_config.exe', + help = _("the pg_config executable to find the database" + " [default: %(default)s]")) + else: + subp.add_argument('--pg_config', metavar="PROG", default='pg_config', + help = _("the pg_config executable to find the database" + " [default: %(default)s]")) return subp From 748b2495272fdb6380fc082a9a08e65be736e242 Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Sun, 30 Oct 2016 17:14:03 -0500 Subject: [PATCH 3/9] gmake.exe and make.exe on windows --- pgxnclient/commands/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pgxnclient/commands/__init__.py b/pgxnclient/commands/__init__.py index fe99692..33ac1c6 100644 --- a/pgxnclient/commands/__init__.py +++ b/pgxnclient/commands/__init__.py @@ -593,10 +593,17 @@ def get_make(self, _cache=[]): @classmethod def _find_default_make(self): - for make in ('gmake', 'make'): - path = find_executable(make) - if path: - return make + import platform + if platform.system() == 'Windows': + for make in ('gmake.exe', 'make.exe'): + path = find_executable(make) + if path: + return make + else: + for make in ('gmake', 'make'): + path = find_executable(make) + if path: + return make # if nothing was found, fall back on 'gmake'. If it was missing we # will give an error when attempting to use it From 290a3ad58419687187c20e805bb17cd03230c25e Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Sun, 30 Oct 2016 17:15:48 -0500 Subject: [PATCH 4/9] python spacing check --- pgxnclient/commands/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pgxnclient/commands/__init__.py b/pgxnclient/commands/__init__.py index 33ac1c6..4ffe042 100644 --- a/pgxnclient/commands/__init__.py +++ b/pgxnclient/commands/__init__.py @@ -460,13 +460,13 @@ def customize_parser(self, parser, subparsers, **kwargs): import platform if platform.system() == 'Windows': - subp.add_argument('--pg_config', metavar="PROG", default='pg_config.exe', - help = _("the pg_config executable to find the database" - " [default: %(default)s]")) + subp.add_argument('--pg_config', metavar="PROG", default='pg_config.exe', + help = _("the pg_config executable to find the database" + " [default: %(default)s]")) else: - subp.add_argument('--pg_config', metavar="PROG", default='pg_config', - help = _("the pg_config executable to find the database" - " [default: %(default)s]")) + subp.add_argument('--pg_config', metavar="PROG", default='pg_config', + help = _("the pg_config executable to find the database" + " [default: %(default)s]")) return subp From 791676f57a532c1cd733ddee4ac21fafc3801846 Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Fri, 4 Nov 2016 05:09:09 -0500 Subject: [PATCH 5/9] change pg_config slash dir & ./configure --- pgxnclient/commands/__init__.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/pgxnclient/commands/__init__.py b/pgxnclient/commands/__init__.py index 4ffe042..7b95cb2 100644 --- a/pgxnclient/commands/__init__.py +++ b/pgxnclient/commands/__init__.py @@ -217,6 +217,18 @@ def popen(self, cmd, *args, **kwargs): """ logger.debug("running command: %s", cmd) try: + import platform + if platform.system() == 'Windows': + import re + if isinstance(cmd, (list, tuple)): + if re.search('configure$', cmd[0]): + cmd[0] = 'sh ./configure' + if isinstance(cmd, str): + if re.search('configure$', cmd): + cmd = 'sh ./configure' + else: + cmd = cmd + return Popen(cmd, *args, **kwargs) except OSError, e: if not isinstance(cmd, basestring): @@ -546,7 +558,17 @@ def run_make(self, cmd, dir, env=None, sudo=None): if sudo: cmdline.extend(shlex.split(sudo)) - cmdline.extend([self.get_make(), 'PG_CONFIG=%s' % self.get_pg_config()]) + import platform + if platform.system() == 'Windows': + # remove colons ':' + # if a character exists at the beginning and if it is upper case, then make it lowercase + # append a backslash '/' to the beginning of the line + # replace occurances of '\\' with '/' + import re + new_pg_config = ('/' + re.sub("^[A-Z]", lambda m: m.group(0).lower(),self.get_pg_config().replace(":",""))).replace("\\","/") + cmdline.extend([self.get_make(), 'PG_CONFIG=%s' % new_pg_config]) + else: + cmdline.extend([self.get_make(), 'PG_CONFIG=%s' % self.get_pg_config()]) if isinstance(cmd, basestring): cmdline.append(cmd) From b293b20afcc8405bed943cdcd50a53b25993275a Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Fri, 4 Nov 2016 05:27:45 -0500 Subject: [PATCH 6/9] fix git verticle spacing --- pgxnclient/commands/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pgxnclient/commands/__init__.py b/pgxnclient/commands/__init__.py index 7b95cb2..bf092ac 100644 --- a/pgxnclient/commands/__init__.py +++ b/pgxnclient/commands/__init__.py @@ -230,6 +230,7 @@ def popen(self, cmd, *args, **kwargs): cmd = cmd return Popen(cmd, *args, **kwargs) + except OSError, e: if not isinstance(cmd, basestring): cmd = ' '.join(cmd) From 6cd97a5a4964bef671c698e60f7870b8b9c37503 Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Wed, 23 Nov 2016 22:42:10 -0600 Subject: [PATCH 7/9] update command comments --- pgxnclient/commands/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pgxnclient/commands/__init__.py b/pgxnclient/commands/__init__.py index bf092ac..ae136d5 100644 --- a/pgxnclient/commands/__init__.py +++ b/pgxnclient/commands/__init__.py @@ -564,7 +564,7 @@ def run_make(self, cmd, dir, env=None, sudo=None): # remove colons ':' # if a character exists at the beginning and if it is upper case, then make it lowercase # append a backslash '/' to the beginning of the line - # replace occurances of '\\' with '/' + # replace many occurances of '\\' with '/' import re new_pg_config = ('/' + re.sub("^[A-Z]", lambda m: m.group(0).lower(),self.get_pg_config().replace(":",""))).replace("\\","/") cmdline.extend([self.get_make(), 'PG_CONFIG=%s' % new_pg_config]) @@ -629,7 +629,7 @@ def _find_default_make(self): return make # if nothing was found, fall back on 'gmake'. If it was missing we - # will give an error when attempting to use it + # will give an error when attempting to use it. return 'gmake' @@ -704,4 +704,3 @@ def get_psql_env(self): if self.opts.port: rv['PGPORT'] = str(self.opts.port) if self.opts.username: rv['PGUSER'] = self.opts.username return rv - From 6366a4e0b5fb68203e2338c00e13079ef86bc3ed Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Wed, 23 Nov 2016 22:43:25 -0600 Subject: [PATCH 8/9] Update cli comments --- pgxnclient/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgxnclient/cli.py b/pgxnclient/cli.py index f1a42d4..4c70a15 100644 --- a/pgxnclient/cli.py +++ b/pgxnclient/cli.py @@ -121,11 +121,11 @@ def command_dispatch(argv=None): # # If env is not None, it must be a mapping that defines the environment variables # for the new process; these are used instead of the default behavior of - # inheriting the current process’ environment. + # inheriting the current process’ environment. # # https://docs.python.org/3.3/library/subprocess.html#replacing-the-os-spawn-family # - # os.exec on Windows + # os.exec on all Windows versions # http://stackoverflow.com/questions/7004687/os-exec-on-windows # # sys.executable: get current /path/to/python.exe that is being used From eab24c4f133bc3c50a7b1e43104c81e75d7f25c5 Mon Sep 17 00:00:00 2001 From: AndreMikulec Date: Mon, 9 Oct 2017 14:29:37 -0500 Subject: [PATCH 9/9] removed UTF character --- pgxnclient/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgxnclient/cli.py b/pgxnclient/cli.py index 4c70a15..84f4066 100644 --- a/pgxnclient/cli.py +++ b/pgxnclient/cli.py @@ -121,7 +121,7 @@ def command_dispatch(argv=None): # # If env is not None, it must be a mapping that defines the environment variables # for the new process; these are used instead of the default behavior of - # inheriting the current process’ environment. + # inheriting the current process environment. # # https://docs.python.org/3.3/library/subprocess.html#replacing-the-os-spawn-family #