diff --git a/setup_windows.py b/setup_windows.py index 6e50e0ac..b2feb7d2 100644 --- a/setup_windows.py +++ b/setup_windows.py @@ -1,37 +1,5 @@ import os import sys -from distutils.msvccompiler import get_build_version - - -def get_default_connector(client): - if client == "mariadbclient": - return os.path.join( - os.environ["ProgramFiles"], "MariaDB", "MariaDB Connector C" - ) - elif client == "mysqlclient": - return os.path.join( - os.environ["ProgramFiles"], "MySQL", "MySQL Connector C 6.1" - ) - else: - raise ValueError("Unknown client library") - - -def find_library(client, connector=None): - if not connector: - connector = get_default_connector(client) - paths = [] - if client == "mariadbclient": - paths.append(os.path.join(connector, "lib", "mariadb", client + ".lib")) - paths.append(os.path.join(connector, "lib", client + ".lib")) - elif client == "mysqlclient": - vcversion = int(get_build_version()) - paths.append(os.path.join(connector, "lib", "vs%d" % vcversion)) - else: - raise ValueError("Unknown client library") - for path in paths: - if os.path.exists(path): - return path - return None def get_config(): @@ -39,51 +7,34 @@ def get_config(): metadata, options = get_metadata_and_options() - client = os.environ.get("MYSQLCLIENT_CLIENT", options.get("client")) + client = "mariadbclient" connector = os.environ.get("MYSQLCLIENT_CONNECTOR", options.get("connector")) - - if not client: - for client in ("mariadbclient", "mysqlclient"): - if find_library(client, connector): - break - else: - raise RuntimeError("Couldn't find MySQL or MariaDB Connector") - if not connector: - connector = get_default_connector(client) + connector = os.path.join( + os.environ["ProgramFiles"], "MariaDB", "MariaDB Connector C" + ) extra_objects = [] - vcversion = int(get_build_version()) - if client == "mariadbclient": - library_dirs = [ - os.path.join(connector, "lib", "mariadb"), - os.path.join(connector, "lib"), - ] - libraries = [ - "kernel32", - "advapi32", - "wsock32", - "shlwapi", - "Ws2_32", - "crypt32", - "secur32", - "bcrypt", - client, - ] - include_dirs = [ - os.path.join(connector, "include", "mariadb"), - os.path.join(connector, "include"), - ] - elif client == "mysqlclient": - library_dirs = [ - os.path.join(connector, r"lib\vs%d" % vcversion), - os.path.join(connector, "lib"), - ] - libraries = ["kernel32", "advapi32", "wsock32", client] - include_dirs = [os.path.join(connector, r"include")] - else: - raise ValueError("Unknown client library") + library_dirs = [ + os.path.join(connector, "lib", "mariadb"), + os.path.join(connector, "lib"), + ] + libraries = [ + "kernel32", + "advapi32", + "wsock32", + "shlwapi", + "Ws2_32", + "crypt32", + "secur32", + "bcrypt", + client, + ] + include_dirs = [ + os.path.join(connector, "include", "mariadb"), + os.path.join(connector, "include"), + ] extra_link_args = ["/MANIFEST"] diff --git a/site.cfg b/site.cfg index e9cbeb03..08a14b0e 100644 --- a/site.cfg +++ b/site.cfg @@ -9,5 +9,4 @@ static = False # http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip # Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build. -client = connector =