Skip to content

Commit

Permalink
Remove support for building against MySQL Connector/C on Windows
Browse files Browse the repository at this point in the history
MySQL Connector/C is not longer published since 2017. New builds are always
done against MariaDB Connector/C. Dropping support for the deprecated
MySQL Connector simplifies the Windows build process.
  • Loading branch information
sparkyb committed Mar 8, 2021
1 parent 83ce631 commit 8d49297
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 73 deletions.
95 changes: 23 additions & 72 deletions setup_windows.py
Original file line number Diff line number Diff line change
@@ -1,89 +1,40 @@
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():
from setup_common import get_metadata_and_options, create_release_file

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"]

Expand Down
1 change: 0 additions & 1 deletion site.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 =

0 comments on commit 8d49297

Please sign in to comment.