Skip to content

Commit c226759

Browse files
committed
Try to find pg_config from system PATH
1 parent 80a3e55 commit c226759

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

testgres/utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from contextlib import contextmanager
1313
from distutils.version import LooseVersion
14+
from distutils.spawn import find_executable
1415
from six import iteritems
1516

1617
from .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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy