File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1111
1212from contextlib import contextmanager
1313from distutils .version import LooseVersion
14+ from distutils .spawn import find_executable
1415from six import iteritems
1516
1617from .config import testgres_config
@@ -116,10 +117,15 @@ def get_bin_path(filename):
116117 if pg_bin :
117118 return os .path .join (pg_bin , filename )
118119
120+ pg_config_path = find_executable ('pg_config' )
121+ if pg_config_path :
122+ bindir = get_pg_config (pg_config_path )["BINDIR" ]
123+ return os .path .join (bindir , filename )
124+
119125 return filename
120126
121127
122- def get_pg_config ():
128+ def get_pg_config (pg_config_path = None ):
123129 """
124130 Return output of pg_config (provided that it is installed).
125131 NOTE: this fuction caches the result by default (see GlobalConfig).
@@ -150,8 +156,8 @@ def cache_pg_config_data(cmd):
150156 if _pg_config_data :
151157 return _pg_config_data
152158
153- # try PG_CONFIG
154- pg_config = os .environ .get ("PG_CONFIG" )
159+ # try specified pg_config path or PG_CONFIG
160+ pg_config = pg_config_path or os .environ .get ("PG_CONFIG" )
155161 if pg_config :
156162 return cache_pg_config_data (pg_config )
157163
You can’t perform that action at this time.
0 commit comments