Example #1
0
def get_config():
    from setup_common import get_metadata_and_options, create_release_file

    metadata, options = get_metadata_and_options()

    connector = options["connector"]

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

    extra_compile_args = ["/Zl", "/D_CRT_SECURE_NO_WARNINGS"]
    extra_link_args = ["/MANIFEST"]

    name = "mysqlclient"
    metadata["name"] = name

    define_macros = [
        ("version_info", metadata["version_info"]),
        ("__version__", metadata["version"]),
    ]
    create_release_file(metadata)
    del metadata["version_info"]
    ext_options = dict(
        library_dirs=library_dirs,
        libraries=libraries,
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )
    return metadata, ext_options
Example #2
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    interpreter_arch = get_build_architecture()
    machine_arch = platform.machine()
    metadata, options = get_metadata_and_options()

    connector = options.get('connector')
    if not connector and machine_arch == 'AMD64' and interpreter_arch == 'Intel':
        connector = 'C:\Program Files (x86)\MySQL\MySQL Connector C 6.1'
    elif not connector:
        connector = 'C:\Program Files\MySQL\MySQL Connector C 6.1'

    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', 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')]

    extra_compile_args = ['/Zl', '/D_CRT_SECURE_NO_WARNINGS']
    extra_link_args = ['/MANIFEST']

    name = "mysqlclient"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
    ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        library_dirs=library_dirs,
        libraries=libraries,
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )
    return metadata, ext_options
Example #3
0
def get_config():
    from setup_common import get_metadata_and_options, create_release_file

    metadata, options = get_metadata_and_options()

    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 = []

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

    name = "mysqlclient"
    metadata["name"] = name

    define_macros = [
        ("version_info", metadata["version_info"]),
        ("__version__", metadata["version"]),
    ]
    create_release_file(metadata)
    del metadata["version_info"]
    ext_options = dict(
        library_dirs=library_dirs,
        libraries=libraries,
        extra_link_args=extra_link_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )
    return metadata, ext_options
Example #4
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    connector = options["connector"]

    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', 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')]

    extra_compile_args = ['/Zl', '/D_CRT_SECURE_NO_WARNINGS']
    extra_link_args = ['/MANIFEST']

    name = "mysqlclient"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
    ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        library_dirs=library_dirs,
        libraries=libraries,
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )
    return metadata, ext_options
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    connector = options["connector"]

    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', 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')]

    extra_compile_args = ['/Zl', '/D_CRT_SECURE_NO_WARNINGS' ]
    extra_link_args = ['/MANIFEST']

    name = "mysqlclient"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
        ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        library_dirs = library_dirs,
        libraries = libraries,
        extra_compile_args = extra_compile_args,
        extra_link_args = extra_link_args,
        include_dirs = include_dirs,
        extra_objects = extra_objects,
        define_macros = define_macros,
    )
    return metadata, ext_options
def get_config():
    import os, sys, _winreg
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
                                options['registry_key'])
    mysql_root, dummy = _winreg.QueryValueEx(serverKey, 'Location')

    extra_objects = []
    static = enabled(options, 'static')
    # XXX static doesn't actually do anything on Windows
    if enabled(options, 'embedded'):
        client = "mysqld"
    else:
        client = "mysqlclient"

    library_dirs = [os.path.join(mysql_root, r'lib\opt')]
    libraries = ['kernel32', 'advapi32', 'wsock32', client]
    include_dirs = [os.path.join(mysql_root, r'include')]
    extra_compile_args = ['/Zl']

    name = "MySQL-python"
    if enabled(options, 'embedded'):
        name = name + "-embedded"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
    ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        name="_mysql",
        library_dirs=library_dirs,
        libraries=libraries,
        extra_compile_args=extra_compile_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )
    return metadata, ext_options
def get_config():
    import os, sys, _winreg
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    #serverKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, options['registry_key'])
    #mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')

    extra_objects = []
    static = enabled(options, 'static')
    # XXX static doesn't actually do anything on Windows
    if enabled(options, 'embedded'):
        client = "mysqld"
    else:
        client = "mysqlclient"

    library_dirs = [ os.path.join(options['connector'], r'lib\\vs9'), os.path.join(options['mysql_root'], r'lib') ]
    libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
    include_dirs = [ os.path.join(options['connector'], r'include'),  os.path.join(options['mysql_root'], r'include') ]
    extra_compile_args = [ '/Zl' ]
    
    name = "MySQL-python"
    if enabled(options, 'embedded'):
        name = name + "-embedded"
    metadata['name'] = name
    
    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
        ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        name = "_mysql",
        library_dirs = library_dirs,
        libraries = libraries,
        extra_compile_args = extra_compile_args,
        include_dirs = include_dirs,
        extra_objects = extra_objects,
        define_macros = define_macros,
        )
    return metadata, ext_options
Example #8
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    connector = options["connector"]

    extra_objects = []

    if enabled(options, 'embedded'):
        client = "mysqld"
    else:
        client = "mysqlclient"

    vcversion = int(get_build_version())
    library_dirs = [ os.path.join(connector, r'lib\vs%d' % vcversion) ]
    libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
    include_dirs = [ os.path.join(connector, r'include') ]
    extra_compile_args = [ '/Zl' ]
    extra_link_args = ['/MANIFEST']

    name = "mysqlclient"
    if enabled(options, 'embedded'):
        name = name + "-embedded"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
        ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        name = "_mysql",
        library_dirs = library_dirs,
        libraries = libraries,
        extra_compile_args = extra_compile_args,
        extra_link_args = extra_link_args,
        include_dirs = include_dirs,
        extra_objects = extra_objects,
        define_macros = define_macros,
        )
    return metadata, ext_options
def get_config():
    import os, sys
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    mysql_root = options['mysql_location']

    extra_objects = []
    static = enabled(options, 'static')
    # XXX static doesn't actually do anything on Windows
    if enabled(options, 'embedded'):
        client = "mysqld"
    else:
        client = "mysqlclient"

    library_dirs = [ os.path.join(mysql_root, r'lib') ]
    libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
    include_dirs = [ os.path.join(mysql_root, r'include') ]
    extra_compile_args = [ '/Zl' ]
    
    name = "MySQL-python"
    if enabled(options, 'embedded'):
        name = name + "-embedded"
    metadata['name'] = name
    
    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
        ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        name = "_mysql",
        library_dirs = library_dirs,
        libraries = libraries,
        extra_compile_args = extra_compile_args,
        include_dirs = include_dirs,
        extra_objects = extra_objects,
        define_macros = define_macros,
        )
    return metadata, ext_options
Example #10
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    if 'mysql_config' in options:
        mysql_config.path = options['mysql_config']

    extra_objects = []
    static = enabled(options, 'static')
    if enabled(options, 'embedded'):
        libs = mysql_config("libmysqld-libs")
        client = "mysqld"
    elif enabled(options, 'threadsafe'):
        libs = mysql_config("libs_r")
        client = "mysqlclient_r"
        if not libs:
            libs = mysql_config("libs")
            client = "mysqlclient"
    else:
        libs = mysql_config("libs")
        client = "mysqlclient"

    library_dirs = [
        dequote(i[2:]) for i in libs if i.startswith(compiler_flag("L"))
    ]
    libraries = [
        dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l"))
    ]

    removable_compile_args = [compiler_flag(f) for f in "ILl"]
    extra_compile_args = [
        i.replace("%", "%%") for i in mysql_config("cflags")
        if i[:2] not in removable_compile_args
    ]

    # Copy the arch flags for linking as well
    extra_link_args = list()
    for i in range(len(extra_compile_args)):
        if extra_compile_args[i] == '-arch':
            extra_link_args += ['-arch', extra_compile_args[i + 1]]

    include_dirs = [
        dequote(i[2:]) for i in mysql_config('include')
        if i.startswith(compiler_flag('I'))
    ]
    if not include_dirs:  # fix for MySQL-3.23
        include_dirs = [
            dequote(i[2:]) for i in mysql_config('cflags')
            if i.startswith(compiler_flag('I'))
        ]

    if static:
        extra_objects.append(os.path.join(library_dirs[0], 'lib%s.a' % client))

    name = "MySQL-python"
    if enabled(options, 'embedded'):
        name = name + "-embedded"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
    ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        name="_mysql",
        library_dirs=library_dirs,
        libraries=libraries,
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )
    return metadata, ext_options
Example #11
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file
    global _mysql_config_path

    metadata, options = get_metadata_and_options()

    if 'mysql_config' in options:
        _mysql_config_path = options['mysql_config']

    extra_objects = []
    static = enabled(options, 'static')

    # allow a command-line option to override the base config file to permit
    # a static build to be created via requirements.txt
    #
    if '--static' in sys.argv:
        static = True
        sys.argv.remove('--static')

    libs = mysql_config("libs")
    library_dirs = [dequote(i[2:]) for i in libs if i.startswith('-L')]
    libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
    extra_link_args = [x for x in libs if not x.startswith(('-l', '-L'))]

    removable_compile_args = ('-I', '-L', '-l')
    extra_compile_args = [i.replace("%", "%%") for i in mysql_config("cflags")
                          if i[:2] not in removable_compile_args]

    # Copy the arch flags for linking as well
    for i in range(len(extra_compile_args)):
        if extra_compile_args[i] == '-arch':
            extra_link_args += ['-arch', extra_compile_args[i + 1]]

    include_dirs = [dequote(i[2:])
                    for i in mysql_config('include') if i.startswith('-I')]

    if static:
        # properly handle mysql client libraries that are not called libmysqlclient
        client = None
        CLIENT_LIST = ['mysqlclient', 'mysqlclient_r', 'mysqld', 'mariadb',
                       'perconaserverclient', 'perconaserverclient_r']
        for c in CLIENT_LIST:
            if c in libraries:
                client = c
                break

        if client == 'mariadb':
            client = 'mariadbclient'
        if client is None:
            raise ValueError("Couldn't identify mysql client library")

        extra_objects.append(os.path.join(library_dirs[0], 'lib%s.a' % client))
        if client in libraries:
            libraries.remove(client)

    name = "mysqlclient"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
        ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        library_dirs = library_dirs,
        libraries = libraries,
        extra_compile_args = extra_compile_args,
        extra_link_args = extra_link_args,
        include_dirs = include_dirs,
        extra_objects = extra_objects,
        define_macros = define_macros,
    )

    # newer versions of gcc require libstdc++ if doing a static build
    if static:
        ext_options['language'] = 'c++'

    return metadata, ext_options
Example #12
0
def get_config():
    import os, sys
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    if 'mysql_config' in options:
        mysql_config.path = options['mysql_config']

    extra_objects = []
    static = enabled(options, 'static')
    if enabled(options, 'embedded'):
        libs = mysql_config("libmysqld-libs")
        client = "mysqld"
    elif enabled(options, 'threadsafe'):
        libs = mysql_config("libs_r")
        client = "mysqlclient_r"
        if not libs:
            libs = mysql_config("libs")
            client = "mysqlclient"
    else:
        libs = mysql_config("libs")
        client = "mysqlclient"

    library_dirs = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("L")) ]
    libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]

    removable_compile_args = [ compiler_flag(f) for f in "ILl" ]
    extra_compile_args = [ i.replace("%", "%%") for i in mysql_config("cflags")
                           if i[:2] not in removable_compile_args ]
    include_dirs = [ dequote(i[2:])
                     for i in mysql_config('include')
                     if i.startswith(compiler_flag('I')) ]
    if not include_dirs: # fix for MySQL-3.23
        include_dirs = [ dequote(i[2:])
                         for i in mysql_config('cflags')
                         if i.startswith(compiler_flag('I')) ]

    if static:
        extra_objects.append(os.path.join(
            library_dirs[0],'lib%s.a' % client))

    name = "MySQL-python"
    if enabled(options, 'embedded'):
        name = name + "-embedded"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
        ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        name = "_mysql",
        library_dirs = library_dirs,
        libraries = libraries,
        extra_compile_args = extra_compile_args,
        include_dirs = include_dirs,
        extra_objects = extra_objects,
        define_macros = define_macros,
        )
    return metadata, ext_options
Example #13
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file
    global _mysql_config_path

    metadata, options = get_metadata_and_options()

    if 'mysql_config' in options:
        _mysql_config_path = options['mysql_config']

    extra_objects = []
    static = enabled(options, 'static')

    # allow a command-line option to override the base config file to permit
    # a static build to be created via requirements.txt
    #
    if '--static' in sys.argv:
        static = True
        sys.argv.remove('--static')

    libs = mysql_config("libs")
    library_dirs = [dequote(i[2:]) for i in libs if i.startswith('-L')]
    libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
    extra_link_args = [x for x in libs if not x.startswith(('-l', '-L'))]

    removable_compile_args = ('-I', '-L', '-l')
    extra_compile_args = [
        i.replace("%", "%%") for i in mysql_config("cflags")
        if i[:2] not in removable_compile_args
    ]

    # Copy the arch flags for linking as well
    for i in range(len(extra_compile_args)):
        if extra_compile_args[i] == '-arch':
            extra_link_args += ['-arch', extra_compile_args[i + 1]]

    include_dirs = [
        dequote(i[2:]) for i in mysql_config('include') if i.startswith('-I')
    ]

    if static:
        # properly handle mysql client libraries that are not called libmysqlclient
        client = None
        CLIENT_LIST = [
            'mysqlclient', 'mysqlclient_r', 'mysqld', 'mariadb',
            'mariadbclient', 'perconaserverclient', 'perconaserverclient_r'
        ]
        for c in CLIENT_LIST:
            if c in libraries:
                client = c
                break

        if client == 'mariadb':
            client = 'mariadbclient'
        if client is None:
            raise ValueError("Couldn't identify mysql client library")

        extra_objects.append(os.path.join(library_dirs[0], 'lib%s.a' % client))
        if client in libraries:
            libraries.remove(client)

    name = "mysqlclient"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
    ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        library_dirs=library_dirs,
        libraries=libraries,
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )

    # newer versions of gcc require libstdc++ if doing a static build
    if static:
        ext_options['language'] = 'c++'

    return metadata, ext_options
Example #14
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    global _mysql_config_path

    metadata, options = get_metadata_and_options()

    if "mysql_config" in options:
        _mysql_config_path = options["mysql_config"]
    else:
        try:
            mysql_config("version")
        except OSError:
            # try mariadb_config
            _mysql_config_path = "mariadb_config"
            try:
                mysql_config("version")
            except OSError:
                _mysql_config_path = "mysql_config"

    extra_objects = []
    static = enabled(options, "static")

    # allow a command-line option to override the base config file to permit
    # a static build to be created via requirements.txt
    #
    if "--static" in sys.argv:
        static = True
        sys.argv.remove("--static")

    libs = mysql_config("libs")
    library_dirs = [dequote(i[2:]) for i in libs if i.startswith("-L")]
    libraries = [dequote(i[2:]) for i in libs if i.startswith("-l")]
    extra_link_args = [x for x in libs if not x.startswith(("-l", "-L"))]

    removable_compile_args = ("-I", "-L", "-l")
    extra_compile_args = [
        i.replace("%", "%%")
        for i in mysql_config("cflags")
        if i[:2] not in removable_compile_args
    ]

    # Copy the arch flags for linking as well
    for i in range(len(extra_compile_args)):
        if extra_compile_args[i] == "-arch":
            extra_link_args += ["-arch", extra_compile_args[i + 1]]

    include_dirs = [
        dequote(i[2:]) for i in mysql_config("include") if i.startswith("-I")
    ]

    if static:
        # properly handle mysql client libraries that are not called libmysqlclient
        client = None
        CLIENT_LIST = [
            "mysqlclient",
            "mysqlclient_r",
            "mysqld",
            "mariadb",
            "mariadbclient",
            "perconaserverclient",
            "perconaserverclient_r",
        ]
        for c in CLIENT_LIST:
            if c in libraries:
                client = c
                break

        if client == "mariadb":
            client = "mariadbclient"
        if client is None:
            raise ValueError("Couldn't identify mysql client library")

        extra_objects.append(os.path.join(library_dirs[0], "lib%s.a" % client))
        if client in libraries:
            libraries.remove(client)
    else:
        # mysql_config may have "-lmysqlclient -lz -lssl -lcrypto", but zlib and
        # ssl is not used by _mysql.  They are needed only for static build.
        for L in ("crypto", "ssl", "z"):
            if L in libraries:
                libraries.remove(L)

    name = "mysqlclient"
    metadata["name"] = name

    define_macros = [
        ("version_info", metadata["version_info"]),
        ("__version__", metadata["version"]),
    ]
    create_release_file(metadata)
    del metadata["version_info"]
    ext_options = dict(
        library_dirs=library_dirs,
        libraries=libraries,
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )

    # newer versions of gcc require libstdc++ if doing a static build
    if static:
        ext_options["language"] = "c++"

    return metadata, ext_options
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    if 'mysql_config' in options:
        mysql_config.path = options['mysql_config']

    extra_objects = []
    static = enabled(options, 'static')
    if enabled(options, 'embedded'):
        libs = mysql_config("libmysqld-libs")
        client = "mysqld"
    elif enabled(options, 'threadsafe'):
        libs = mysql_config("libs_r")
        client = "mysqlclient_r"
        if not libs:
            libs = mysql_config("libs")
            client = "mysqlclient"
    else:
        libs = mysql_config("libs")
        client = "mysqlclient"

    library_dirs = [dequote(i[2:]) for i in libs if i.startswith('-L')]
    libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
    extra_link_args = [x for x in libs if not x.startswith(('-l', '-L'))]

    removable_compile_args = ('-I', '-L', '-l')
    extra_compile_args = [i.replace("%", "%%") for i in mysql_config("cflags")
                          if i[:2] not in removable_compile_args]

    # Copy the arch flags for linking as well
    for i in range(len(extra_compile_args)):
        if extra_compile_args[i] == '-arch':
            extra_link_args += ['-arch', extra_compile_args[i + 1]]

    include_dirs = [dequote(i[2:])
                    for i in mysql_config('include') if i.startswith('-I')]

    if static:
        extra_objects.append(os.path.join(library_dirs[0], 'lib%s.a' % client))
        if client in libraries:
            libraries.remove(client)

    name = "mysqlclient"
    if enabled(options, 'embedded'):
        name = name + "-embedded"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
        ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        name = "_mysql",
        library_dirs = library_dirs,
        libraries = libraries,
        extra_compile_args = extra_compile_args,
        extra_link_args = extra_link_args,
        include_dirs = include_dirs,
        extra_objects = extra_objects,
        define_macros = define_macros,
        )
    return metadata, ext_options
Example #16
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    global _mysql_config_path

    metadata, options = get_metadata_and_options()

    if "mysql_config" in options:
        _mysql_config_path = options["mysql_config"]
    else:
        try:
            mysql_config("version")
        except OSError:
            # try mariadb_config
            _mysql_config_path = "mariadb_config"
            try:
                mysql_config("version")
            except OSError:
                _mysql_config_path = "mysql_config"

    extra_objects = []
    static = enabled(options, "static")

    # allow a command-line option to override the base config file to permit
    # a static build to be created via requirements.txt
    #
    if "--static" in sys.argv:
        static = True
        sys.argv.remove("--static")

    libs = os.environ.get("MYSQLCLIENT_LDFLAGS")
    if libs:
        libs = libs.strip().split()
    else:
        libs = mysql_config("libs")
    library_dirs = [dequote(i[2:]) for i in libs if i.startswith("-L")]
    libraries = [dequote(i[2:]) for i in libs if i.startswith("-l")]
    extra_link_args = [x for x in libs if not x.startswith(("-l", "-L"))]

    cflags = os.environ.get("MYSQLCLIENT_CFLAGS")
    if cflags:
        use_mysqlconfig_cflags = False
        cflags = cflags.strip().split()
    else:
        use_mysqlconfig_cflags = True
        cflags = mysql_config("cflags")

    include_dirs = []
    extra_compile_args = ["-std=c99"]

    for a in cflags:
        if a.startswith("-I"):
            include_dirs.append(dequote(a[2:]))
        elif a.startswith(("-L", "-l")):  # This should be LIBS.
            pass
        else:
            extra_compile_args.append(a.replace("%", "%%"))

    # Copy the arch flags for linking as well
    try:
        i = extra_compile_args.index("-arch")
        if "-arch" not in extra_link_args:
            extra_link_args += ["-arch", extra_compile_args[i + 1]]
    except ValueError:
        pass

    if static:
        # properly handle mysql client libraries that are not called libmysqlclient
        client = None
        CLIENT_LIST = [
            "mysqlclient",
            "mysqlclient_r",
            "mysqld",
            "mariadb",
            "mariadbclient",
            "perconaserverclient",
            "perconaserverclient_r",
        ]
        for c in CLIENT_LIST:
            if c in libraries:
                client = c
                break

        if client == "mariadb":
            client = "mariadbclient"
        if client is None:
            raise ValueError("Couldn't identify mysql client library")

        extra_objects.append(os.path.join(library_dirs[0], "lib%s.a" % client))
        if client in libraries:
            libraries.remove(client)
    else:
        if use_mysqlconfig_cflags:
            # mysql_config may have "-lmysqlclient -lz -lssl -lcrypto", but zlib and
            # ssl is not used by _mysql.  They are needed only for static build.
            for L in ("crypto", "ssl", "z"):
                if L in libraries:
                    libraries.remove(L)

    name = "mysqlclient"
    metadata["name"] = name

    define_macros = [
        ("version_info", metadata["version_info"]),
        ("__version__", metadata["version"]),
    ]
    create_release_file(metadata)
    del metadata["version_info"]
    ext_options = dict(
        library_dirs=library_dirs,
        libraries=libraries,
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        include_dirs=include_dirs,
        extra_objects=extra_objects,
        define_macros=define_macros,
    )

    # newer versions of gcc require libstdc++ if doing a static build
    if static:
        ext_options["language"] = "c++"

    print("ext_options:")
    for k, v in ext_options.items():
        print("  {}: {}".format(k, v))

    return metadata, ext_options
Example #17
0
def get_config():
    from setup_common import get_metadata_and_options, enabled, create_release_file

    metadata, options = get_metadata_and_options()

    if 'mysql_config' in options:
        mysql_config.path = options['mysql_config']

    extra_objects = []
    static = enabled(options, 'static')
    if enabled(options, 'embedded'):
        static = True
        libs = mysql_config("libmysqld-libs")
        client = "mysqld"
        if platform.system() == 'Linux':  # Tested with mysql 5.6.20
            libs.append('-lstdc++')
    elif enabled(options, 'threadsafe'):
        libs = mysql_config("libs_r")
        client = "mysqlclient_r"
        if not libs:
            libs = mysql_config("libs")
            client = "mysqlclient"
    else:
        libs = mysql_config("libs")
        client = "mysqlclient"

    library_dirs = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("L")) ]
    libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]

    removable_compile_args = [ compiler_flag(f) for f in "ILl" ]
    extra_compile_args = [ i.replace("%", "%%") for i in mysql_config("cflags")
                           if i[:2] not in removable_compile_args ]

    # Copy the arch flags for linking as well
    extra_link_args = list()
    for i in range(len(extra_compile_args)):
        if extra_compile_args[i] == '-arch':
            extra_link_args += ['-arch', extra_compile_args[i + 1]]

    include_dirs = [ dequote(i[2:])
                     for i in mysql_config('include')
                     if i.startswith(compiler_flag('I')) ]
    if not include_dirs: # fix for MySQL-3.23
        include_dirs = [ dequote(i[2:])
                         for i in mysql_config('cflags')
                         if i.startswith(compiler_flag('I')) ]

    if static:
        extra_objects.append(os.path.join(library_dirs[0],'lib%s.a' % client))
        if client in libraries:
            libraries.remove(client)

    name = "MySQL-python"
    if enabled(options, 'embedded'):
        name = name + "-embedded"
    metadata['name'] = name

    define_macros = [
        ('version_info', metadata['version_info']),
        ('__version__', metadata['version']),
        ]
    create_release_file(metadata)
    del metadata['version_info']
    ext_options = dict(
        name = "_mysql_embedded",
        library_dirs = library_dirs,
        libraries = libraries,
        extra_compile_args = extra_compile_args,
        extra_link_args = extra_link_args,
        include_dirs = include_dirs,
        extra_objects = extra_objects,
        define_macros = define_macros,
        )
    return metadata, ext_options