Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for building on Windows #484

Merged
merged 2 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ Or when you have question about MySQL:
Building mysqlclient on Windows is very hard.
But there are some binary wheels you can install easily.

If binary wheels do not exist for your version of Python, it may be possible to
build from source, but if this does not work, **do not come asking for support.**
To build from source, download the
[MariaDB C Connector](https://mariadb.com/downloads/#connectors) and install
it. It must be installed in the default location
(usually "C:\Program Files\MariaDB\MariaDB Connector C" or
"C:\Program Files (x86)\MariaDB\MariaDB Connector C" for 32-bit). If you
build the connector yourself or install it in a different location, set the
environment variable `MYSQLCLIENT_CONNECTOR` before installing. Once you have
the connector installed and an appropriate version of Visual Studio for your
version of Python:

```
$ pip install mysqlclient
```

### macOS (Homebrew)

Install MySQL and mysqlclient:
Expand Down
52 changes: 25 additions & 27 deletions setup_windows.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
import os
import sys
from distutils.msvccompiler import get_build_version


def get_config():
from setup_common import get_metadata_and_options, create_release_file

metadata, options = get_metadata_and_options()

connector = options["connector"]
client = "mariadbclient"
connector = os.environ.get("MYSQLCLIENT_CONNECTOR", options.get("connector"))
if not connector:
connector = os.path.join(
os.environ["ProgramFiles"], "MariaDB", "MariaDB Connector C"
)

extra_objects = []

# client = "mysqlclient"
client = "mariadbclient"

vcversion = int(get_build_version())
if client == "mariadbclient":
library_dirs = [os.path.join(connector, "lib", "mariadb")]
libraries = [
"kernel32",
"advapi32",
"wsock32",
"shlwapi",
"Ws2_32",
"crypt32",
"secur32",
"bcrypt",
client,
]
include_dirs = [os.path.join(connector, "include", "mariadb")]
else:
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")]
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
2 changes: 1 addition & 1 deletion site.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +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.
connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.1
connector =