mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-14 04:56:33 +03:00
Unify the way the MSVC compiler is detected
And do it only once in __init__ instead of different ways and in different places.
This commit is contained in:
parent
c826446ff8
commit
ef18915396
19
setup.py
19
setup.py
|
@ -53,10 +53,7 @@ from distutils.command.build_ext import build_ext
|
||||||
from distutils.sysconfig import get_python_inc
|
from distutils.sysconfig import get_python_inc
|
||||||
from distutils.ccompiler import get_default_compiler
|
from distutils.ccompiler import get_default_compiler
|
||||||
from distutils.util import get_platform
|
from distutils.util import get_platform
|
||||||
try:
|
|
||||||
from distutils.msvc9compiler import MSVCCompiler
|
|
||||||
except ImportError:
|
|
||||||
MSVCCompiler = None
|
|
||||||
try:
|
try:
|
||||||
from distutils.command.build_py import build_py_2to3 as build_py
|
from distutils.command.build_py import build_py_2to3 as build_py
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -242,6 +239,9 @@ class psycopg_build_ext(build_ext):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
build_ext.__init__(self, *args, **kwargs)
|
build_ext.__init__(self, *args, **kwargs)
|
||||||
self.pg_config = PostgresConfig()
|
self.pg_config = PostgresConfig()
|
||||||
|
compiler_name = self.get_compiler_name().lower()
|
||||||
|
self.compiler_is_msvc = compiler_name.startswith('msvc')
|
||||||
|
self.compiler_is_mingw = compiler_name.startswith('mingw')
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
build_ext.initialize_options(self)
|
build_ext.initialize_options(self)
|
||||||
|
@ -271,7 +271,7 @@ class psycopg_build_ext(build_ext):
|
||||||
|
|
||||||
def get_export_symbols(self, extension):
|
def get_export_symbols(self, extension):
|
||||||
# Fix MSVC seeing two of the same export symbols.
|
# Fix MSVC seeing two of the same export symbols.
|
||||||
if self.get_compiler_name().lower().startswith('msvc'):
|
if self.compiler_is_msvc:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
return build_ext.get_export_symbols(self, extension)
|
return build_ext.get_export_symbols(self, extension)
|
||||||
|
@ -281,7 +281,7 @@ class psycopg_build_ext(build_ext):
|
||||||
|
|
||||||
# For Python versions that use MSVC compiler 2008, re-insert the
|
# For Python versions that use MSVC compiler 2008, re-insert the
|
||||||
# manifest into the resulting .pyd file.
|
# manifest into the resulting .pyd file.
|
||||||
if MSVCCompiler and isinstance(self.compiler, MSVCCompiler):
|
if self.compiler_is_msvc:
|
||||||
platform = get_platform()
|
platform = get_platform()
|
||||||
# Default to the x86 manifest
|
# Default to the x86 manifest
|
||||||
manifest = '_psycopg.vc9.x86.manifest'
|
manifest = '_psycopg.vc9.x86.manifest'
|
||||||
|
@ -301,10 +301,7 @@ class psycopg_build_ext(build_ext):
|
||||||
# Add compiler-specific arguments:
|
# Add compiler-specific arguments:
|
||||||
extra_compiler_args = []
|
extra_compiler_args = []
|
||||||
|
|
||||||
compiler_name = self.get_compiler_name().lower()
|
if self.compiler_is_mingw:
|
||||||
compiler_is_msvc = compiler_name.startswith('msvc')
|
|
||||||
compiler_is_mingw = compiler_name.startswith('mingw')
|
|
||||||
if compiler_is_mingw:
|
|
||||||
# Default MinGW compilation of Python extensions on Windows uses
|
# Default MinGW compilation of Python extensions on Windows uses
|
||||||
# only -O:
|
# only -O:
|
||||||
extra_compiler_args.append('-O3')
|
extra_compiler_args.append('-O3')
|
||||||
|
@ -332,7 +329,7 @@ class psycopg_build_ext(build_ext):
|
||||||
|
|
||||||
self.libraries.append("ws2_32")
|
self.libraries.append("ws2_32")
|
||||||
self.libraries.append("advapi32")
|
self.libraries.append("advapi32")
|
||||||
if compiler_is_msvc:
|
if self.compiler_is_msvc:
|
||||||
# MSVC requires an explicit "libpq"
|
# MSVC requires an explicit "libpq"
|
||||||
self.libraries.remove("pq")
|
self.libraries.remove("pq")
|
||||||
self.libraries.append("secur32")
|
self.libraries.append("secur32")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user