mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Code to find an executable on the current PATH refactored
This commit is contained in:
parent
9a7aee3d05
commit
57a6cf3144
16
setup.py
16
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user