mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-07-27 13:01:19 +00:00
Coding style fixes (PEP8)
Fixed various coding style stuff detected by flake8. Added .pre-commit-config.yaml: With command pre_commit install a hook for flake8 will be installed.
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
|
||||
import subprocess
|
||||
from distutils.version import StrictVersion
|
||||
import sys, os
|
||||
# from packaging import version
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
class MariaDBConfiguration():
|
||||
@ -28,13 +28,13 @@ def mariadb_config(config, option):
|
||||
raise EnvironmentError(
|
||||
"""mariadb_config not found.
|
||||
|
||||
This error typically indicates that MariaDB Connector/C, a dependency which must be preinstalled,
|
||||
is not found.
|
||||
This error typically indicates that MariaDB Connector/C, a dependency which
|
||||
must be preinstalled, is not found.
|
||||
If MariaDB Connector/C is not installed, see installation instructions
|
||||
at: https://github.com/mariadb-corporation/mariadb-connector-c/wiki/install.md.
|
||||
If MariaDB Connector/C is installed, either set the environment variable MARIADB_CONFIG or edit
|
||||
the configuration file 'site.cfg' to set the 'mariadb_config' option to the file location of the
|
||||
mariadb_config utility.""")
|
||||
If MariaDB Connector/C is installed, either set the environment variable
|
||||
MARIADB_CONFIG or edit the configuration file 'site.cfg' to set the
|
||||
'mariadb_config' option to the file location of the mariadb_config utility.
|
||||
""")
|
||||
|
||||
return data
|
||||
|
||||
@ -47,12 +47,11 @@ def dequote(s):
|
||||
|
||||
def get_config(options):
|
||||
required_version = "3.2.4"
|
||||
no_env = 0
|
||||
static = options["link_static"]
|
||||
|
||||
try:
|
||||
try:
|
||||
config_prg= os.environ["MARIADB_CONFIG"]
|
||||
config_prg = os.environ["MARIADB_CONFIG"]
|
||||
except KeyError:
|
||||
config_prg = options["mariadb_config"]
|
||||
subprocess.call([config_prg, "--version"])
|
||||
@ -62,15 +61,15 @@ def get_config(options):
|
||||
|
||||
cc_version = mariadb_config(config_prg, "cc_version")
|
||||
if StrictVersion(cc_version[0]) < StrictVersion(required_version):
|
||||
print ('MariaDB Connector/Python requires MariaDB Connector/C >= %s, found version %s' % (
|
||||
required_version, cc_version[0]))
|
||||
print('MariaDB Connector/Python requires MariaDB Connector/C '
|
||||
'>= %s, found version %s' % required_version, cc_version[0])
|
||||
sys.exit(2)
|
||||
cfg = MariaDBConfiguration()
|
||||
cfg.version = cc_version[0]
|
||||
|
||||
plugindir= mariadb_config(config_prg, "plugindir")
|
||||
plugindir = mariadb_config(config_prg, "plugindir")
|
||||
libs = mariadb_config(config_prg, "libs")
|
||||
extra_libs= mariadb_config(config_prg, "libs_sys")
|
||||
extra_libs = mariadb_config(config_prg, "libs_sys")
|
||||
cfg.lib_dirs = [dequote(i[2:]) for i in libs if i.startswith("-L")]
|
||||
|
||||
cfg.libs = [dequote(i[2:]) for i in libs if i.startswith("-l")]
|
||||
@ -78,9 +77,11 @@ def get_config(options):
|
||||
mariadb_includes = [dequote(i[2:]) for i in includes if i.startswith("-I")]
|
||||
mariadb_includes.extend(["./include"])
|
||||
if static.lower() == "on":
|
||||
cfg.extra_link_args= ["-u mysql_ps_fetch_functions"]
|
||||
cfg.extra_objects = ['{}/lib{}.a'.format(cfg.lib_dirs[0], l) for l in ["mariadbclient"]]
|
||||
cfg.libs = [dequote(i[2:]) for i in extra_libs if i.startswith("-l")]
|
||||
cfg.extra_link_args = ["-u mysql_ps_fetch_functions"]
|
||||
cfg.extra_objects = ['{}/lib{}.a'.format(cfg.lib_dirs[0], lib)
|
||||
for lib in ["mariadbclient"]]
|
||||
cfg.libs = [dequote(i[2:])
|
||||
for i in extra_libs if i.startswith("-l")]
|
||||
cfg.includes = mariadb_includes
|
||||
cfg.extra_compile_args= ["-DDEFAULT_PLUGINS_SUBDIR=\"%s\"" % plugindir[0]]
|
||||
cfg.extra_compile_args = ["-DDEFAULT_PLUGINS_SUBDIR=\"%s\"" % plugindir[0]]
|
||||
return cfg
|
||||
|
Reference in New Issue
Block a user