Appliet Jasons patch to fix win32 build glitches.

This commit is contained in:
Federico Di Gregorio 2007-04-13 01:14:01 +00:00
parent f57920b0dd
commit ee44315ff2
3 changed files with 47 additions and 21 deletions

View File

@ -1,3 +1,7 @@
2007-04-12 Federico Di Gregorio <fog@initd.org>
* Applied patch from Jason Erickson to fix win32 build glitches.
2007-04-11 Federico Di Gregorio <fog@initd.org> 2007-04-11 Federico Di Gregorio <fog@initd.org>
* Release 2.0.6b2. * Release 2.0.6b2.

View File

@ -21,6 +21,11 @@ use_decimal=0
# uncommenting the following line and setting its value to the right path. # uncommenting the following line and setting its value to the right path.
#mx_include_dir= #mx_include_dir=
# For Windows only
# Set to 1 if the PostgreSQL library was built with OpenSSL
# Required to link in OpenSSL libraries and dependencies
have_ssl=0
# "pg_config" is the preferred method to locate PostgreSQL headers and # "pg_config" is the preferred method to locate PostgreSQL headers and
# libraries needed to build psycopg2. If pg_config is not in the path or # libraries needed to build psycopg2. If pg_config is not in the path or
# is installed under a different name uncomment the following option and # is installed under a different name uncomment the following option and

View File

@ -90,10 +90,12 @@ class psycopg_build_ext(build_ext):
"The name of the pg_config binary and/or full path to find it"), "The name of the pg_config binary and/or full path to find it"),
('use-decimal', None, ('use-decimal', None,
"Use Decimal type even on Python 2.3 if the module is provided."), "Use Decimal type even on Python 2.3 if the module is provided."),
('have-ssl', None,
"Compile with OpenSSL built PostgreSQL libraries (Windows only)."),
]) ])
boolean_options = build_ext.boolean_options[:] boolean_options = build_ext.boolean_options[:]
boolean_options.extend(('use-pydatetime', 'use-decimal')) boolean_options.extend(('use-pydatetime', 'use-decimal', 'have-ssl'))
DEFAULT_PG_CONFIG = "pg_config" DEFAULT_PG_CONFIG = "pg_config"
@ -179,6 +181,11 @@ class psycopg_build_ext(build_ext):
if os.path.isfile(os.path.join(path, "ms", "libpq.lib")): if os.path.isfile(os.path.join(path, "ms", "libpq.lib")):
self.library_dirs.append(os.path.join(path, "ms")) self.library_dirs.append(os.path.join(path, "ms"))
break break
if have_ssl:
self.libraries.append("libeay32")
self.libraries.append("ssleay32")
self.libraries.append("user32")
self.libraries.append("gdi32")
def finalize_darwin(self): def finalize_darwin(self):
"""Finalize build system configuration on darwin platform.""" """Finalize build system configuration on darwin platform."""
@ -256,29 +263,34 @@ class psycopg_build_ext(build_ext):
pg_config_path = None pg_config_path = None
reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
pg_inst_list_key = _winreg.OpenKey(reg,
'SOFTWARE\\PostgreSQL\\Installations'
)
try: try:
# Determine the name of the first subkey, if any: pg_inst_list_key = _winreg.OpenKey(reg,
try: 'SOFTWARE\\PostgreSQL\\Installations'
first_sub_key_name = _winreg.EnumKey(pg_inst_list_key, 0) )
except EnvironmentError: except EnvironmentError:
first_sub_key_name = None pg_inst_list_key = None
if first_sub_key_name is not None: if pg_inst_list_key is not None:
pg_first_inst_key = _winreg.OpenKey(reg, try:
'SOFTWARE\\PostgreSQL\\Installations\\' # Determine the name of the first subkey, if any:
+ first_sub_key_name
)
try: try:
pg_inst_base_dir = _winreg.QueryValueEx( first_sub_key_name = _winreg.EnumKey(pg_inst_list_key, 0)
pg_first_inst_key, 'Base Directory' except EnvironmentError:
)[0] first_sub_key_name = None
finally:
_winreg.CloseKey(pg_first_inst_key) if first_sub_key_name is not None:
finally: pg_first_inst_key = _winreg.OpenKey(reg,
_winreg.CloseKey(pg_inst_list_key) 'SOFTWARE\\PostgreSQL\\Installations\\'
+ first_sub_key_name
)
try:
pg_inst_base_dir = _winreg.QueryValueEx(
pg_first_inst_key, 'Base Directory'
)[0]
finally:
_winreg.CloseKey(pg_first_inst_key)
finally:
_winreg.CloseKey(pg_inst_list_key)
if pg_inst_base_dir and os.path.exists(pg_inst_base_dir): if pg_inst_base_dir and os.path.exists(pg_inst_base_dir):
pg_config_path = os.path.join(pg_inst_base_dir, 'bin', pg_config_path = os.path.join(pg_inst_base_dir, 'bin',
@ -384,6 +396,11 @@ if not PLATFORM_IS_WINDOWS:
else: else:
define_macros.append(('PSYCOPG_VERSION', '\\"'+PSYCOPG_VERSION_EX+'\\"')) define_macros.append(('PSYCOPG_VERSION', '\\"'+PSYCOPG_VERSION_EX+'\\"'))
if parser.has_option('build_ext', 'have_ssl'):
have_ssl = int(parser.get('build_ext', 'have_ssl'))
else:
have_ssl = 0
# build the extension # build the extension
sources = map(lambda x: os.path.join('psycopg', x), sources) sources = map(lambda x: os.path.join('psycopg', x), sources)