mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-11 02:43:15 +00:00
Merge pull request #2 from rusher/master
[misc] windows setup improvement
This commit is contained in:
@ -1,36 +1,49 @@
|
|||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import string
|
import platform
|
||||||
|
import sys
|
||||||
from winreg import *
|
from winreg import *
|
||||||
|
|
||||||
|
|
||||||
class MariaDBConfiguration():
|
class MariaDBConfiguration():
|
||||||
lib_dirs = ""
|
lib_dirs = ""
|
||||||
libs = ""
|
libs = ""
|
||||||
version = ""
|
version = ""
|
||||||
includes = ""
|
includes = ""
|
||||||
|
|
||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
required_version = "3.1.0"
|
required_version = "3.1.0"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
config_prg= os.environ["MARIADB_CC_DIR"]
|
config_prg = os.environ["MARIADB_CC_INSTALL_DIR"]
|
||||||
cc_version = ["", ""]
|
cc_version = ["", ""]
|
||||||
cc_instdir = [config_prg, ""]
|
cc_instdir = [config_prg, ""]
|
||||||
print("using environment configuration " + config_prg)
|
print("using environment configuration " + config_prg)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
Registry= ConnectRegistry(None, HKEY_LOCAL_MACHINE)
|
|
||||||
Key= OpenKey(Registry, "SOFTWARE\MariaDB Corporation\MariaDB Connector C 64-bit")
|
|
||||||
if Key:
|
|
||||||
cc_version= QueryValueEx(Key, "Version")
|
|
||||||
if cc_version[0] < required_version:
|
|
||||||
print("MariaDB Connector/Python requires MariaDB Connector/C >= %s (found version: %s") % (required_version, cc_version[0])
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
local_reg = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
|
||||||
|
if platform.architecture()[0] == '32bit':
|
||||||
|
connector_key = OpenKey(local_reg,
|
||||||
|
'SOFTWARE\\MariaDB Corporation\\MariaDB Connector C')
|
||||||
|
else:
|
||||||
|
connector_key = OpenKey(local_reg,
|
||||||
|
'SOFTWARE\\MariaDB Corporation\\MariaDB Connector C 64-bit',
|
||||||
|
access=KEY_READ | KEY_WOW64_64KEY)
|
||||||
|
|
||||||
|
cc_version = QueryValueEx(connector_key, "Version")
|
||||||
|
if cc_version[0] < required_version:
|
||||||
|
print(
|
||||||
|
"MariaDB Connector/Python requires MariaDB Connector/C >= %s (found version: %s") \
|
||||||
|
% (required_version, cc_version[0])
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
cc_instdir = QueryValueEx(Key, "InstallDir")
|
cc_instdir = QueryValueEx(Key, "InstallDir")
|
||||||
if cc_instdir is None:
|
|
||||||
print("Could not find InstallationDir of MariaDB Connector/C. Please make sure MariaDB Connector/C is installed or specify the InstallationDir of MariaDB Connector/C by setting the environment variable MARIADB_CC_INSTALL_DIR.")
|
|
||||||
sys.exit(3)
|
|
||||||
|
|
||||||
|
except:
|
||||||
|
print("Could not find InstallationDir of MariaDB Connector/C. "
|
||||||
|
"Please make sure MariaDB Connector/C is installed or specify the InstallationDir of "
|
||||||
|
"MariaDB Connector/C by setting the environment variable MARIADB_CC_INSTALL_DIR.")
|
||||||
|
sys.exit(3)
|
||||||
|
|
||||||
cfg = MariaDBConfiguration()
|
cfg = MariaDBConfiguration()
|
||||||
cfg.version = cc_version[0]
|
cfg.version = cc_version[0]
|
||||||
|
Reference in New Issue
Block a user