Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure the same pg_config is used both by the current user and by …

…sudo

Partial solution of the problem discussed in the ticket #13.
  • Loading branch information...
commit 2be8d7f563bd5a9e165291c064d2811126ec2cb4 1 parent cb93224
@dvarrazzo authored
Showing with 28 additions and 8 deletions.
  1. +7 −0 CHANGES
  2. +21 −8 pgxnclient/commands/__init__.py
View
7 CHANGES
@@ -3,6 +3,13 @@
PGXN Client changes log
-----------------------
+pgxnclient 1.0.4
+================
+
+- Make sure the same ``pg_config`` is used both by the current user and by
+ sudo (ticket #13).
+
+
pgxnclient 1.0.3
================
View
29 pgxnclient/commands/__init__.py
@@ -460,7 +460,7 @@ def call_pg_config(self, what, _cache={}):
return _cache[what]
logger.debug("running pg_config --%s", what)
- cmdline = [self.opts.pg_config, "--%s" % what]
+ cmdline = [self.get_pg_config(), "--%s" % what]
p = self.popen(cmdline, stdout=PIPE)
out, err = p.communicate()
if p.returncode:
@@ -471,6 +471,25 @@ def call_pg_config(self, what, _cache={}):
rv = _cache[what] = out
return rv
+ def get_pg_config(self):
+ """
+ Return the absolute path of the pg_config binary.
+ """
+ pg_config = self.opts.pg_config
+ if os.path.split(pg_config)[0]:
+ pg_config = os.path.abspath(pg_config)
+ else:
+ for dir in os.environ.get('PATH', '').split(os.pathsep):
+ if not dir: continue
+ fn = os.path.abspath(os.path.join(dir, pg_config))
+ if os.path.exists(fn):
+ pg_config = os.path.abspath(fn)
+ break
+ else:
+ raise PgxnClientException(_("pg_config executable not found"))
+
+ return pg_config
+
import shlex
@@ -500,13 +519,7 @@ def run_make(self, cmd, dir, env=None, sudo=None):
if sudo:
cmdline.extend(shlex.split(sudo))
- # convert to absolute path for makefile, or else it may miss it
- # if the cwd is changed during execution
- pg_config = self.opts.pg_config
- if os.path.split(pg_config)[0]:
- pg_config = os.path.abspath(pg_config)
-
- cmdline.extend(['make', 'PG_CONFIG=%s' % pg_config])
+ cmdline.extend(['make', 'PG_CONFIG=%s' % self.get_pg_config()])
if isinstance(cmd, basestring):
cmdline.append(cmd)
Please sign in to comment.
Something went wrong with that request. Please try again.