summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorSteve Lacy <slacy@slacy.com>2011-06-07 09:50:52 -0700
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-06-07 22:18:56 +0100
commit57a6cf3144d3278a4a7f3a5fc0553975a4013764 (patch)
treeded002c6aa9e9c3f6dca7287bd43f6b1d05ae4df /setup.py
parent9a7aee3d05fa0df73a2e6bf792b6c3f2bb2a81b9 (diff)
downloadpsycopg2-57a6cf3144d3278a4a7f3a5fc0553975a4013764.tar.gz
Code to find an executable on the current PATH refactored
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/setup.py b/setup.py
index ae4d297..277be61 100644
--- a/setup.py
+++ b/setup.py
@@ -116,6 +116,15 @@ or with the pg_config option in 'setup.cfg'.
result = result.decode('ascii')
return result
+ def find_on_path(self, exename, path_directories=None):
+ if not path_directories:
+ path_directories = os.environ['PATH'].split(os.pathsep)
+ for dir_name in path_directories:
+ fullpath = os.path.join(dir_name, exename)
+ if os.path.isfile(fullpath):
+ return fullpath
+ return None
+
def autodetect_pg_config_path(self):
"""Find and return the path to the pg_config executable."""
if PLATFORM_IS_WINDOWS:
@@ -125,12 +134,7 @@ or with the pg_config option in 'setup.cfg'.
def autodetect_pg_config_path_posix(self):
"""Return pg_config from the current PATH"""
- exename = 'pg_config'
- for dir_name in os.environ['PATH'].split(os.pathsep):
- fullpath = os.path.join(dir_name, exename)
- if os.path.isfile(fullpath):
- return fullpath
- return None
+ return self.find_on_path('pg_config')
def autodetect_pg_config_path_windows(self):
"""Attempt several different ways of finding the pg_config