|
11 | 11 |
|
12 | 12 | fromcontextlibimportcontextmanager |
13 | 13 | fromdistutils.versionimportLooseVersion |
| 14 | +fromdistutils.spawnimportfind_executable |
14 | 15 | fromsiximportiteritems |
15 | 16 |
|
16 | 17 | from .configimporttestgres_config |
@@ -116,10 +117,15 @@ def get_bin_path(filename): |
116 | 117 | ifpg_bin: |
117 | 118 | returnos.path.join(pg_bin,filename) |
118 | 119 |
|
| 120 | +pg_config_path=find_executable('pg_config') |
| 121 | +ifpg_config_path: |
| 122 | +bindir=get_pg_config(pg_config_path)["BINDIR"] |
| 123 | +returnos.path.join(bindir,filename) |
| 124 | + |
119 | 125 | returnfilename |
120 | 126 |
|
121 | 127 |
|
122 | | -defget_pg_config(): |
| 128 | +defget_pg_config(pg_config_path=None): |
123 | 129 | """ |
124 | 130 | Return output of pg_config (provided that it is installed). |
125 | 131 | NOTE: this fuction caches the result by default (see GlobalConfig). |
@@ -150,8 +156,8 @@ def cache_pg_config_data(cmd): |
150 | 156 | if_pg_config_data: |
151 | 157 | return_pg_config_data |
152 | 158 |
|
153 | | -# try PG_CONFIG |
154 | | -pg_config=os.environ.get("PG_CONFIG") |
| 159 | +# tryspecified pg_config path orPG_CONFIG |
| 160 | +pg_config=pg_config_pathoros.environ.get("PG_CONFIG") |
155 | 161 | ifpg_config: |
156 | 162 | returncache_pg_config_data(pg_config) |
157 | 163 |
|
|