-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
92 lines (75 loc) · 2.83 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# -*- coding: ISO-8859-1 -*-
# setup.py: the distutils script
#
import os
import setuptools
import shutil
import sys
from distutils import log
from distutils.command.build_ext import build_ext
from setuptools import Extension
# If you need to change anything, it should be enough to change setup.cfg.
PACKAGE_NAME = 'octodb'
VERSION = '0.5.0'
# define sqlite sources
sources = [os.path.join('src', source)
for source in ["module.c", "connection.c", "cursor.c", "cache.c",
"microprotocols.c", "prepare_protocol.c",
"statement.c", "util.c", "row.c", "blob.c"]]
# define packages
packages = [PACKAGE_NAME]
EXTENSION_MODULE_NAME = "._sqlite3"
# Work around clang raising hard error for unused arguments
if sys.platform == "darwin":
os.environ['CFLAGS'] = "-Qunused-arguments"
log.info("CFLAGS: " + os.environ['CFLAGS'])
def quote_argument(arg):
q = '"' #if sys.platform == 'win32' and sys.version_info < (3, 8) else '"'
return q + arg + q
define_macros = [('MODULE_NAME', quote_argument(PACKAGE_NAME + '.dbapi2'))]
with open("README.md", "r") as fh:
long_description = fh.read()
class SystemLibSqliteBuilder(build_ext):
description = "Builds a C extension linking against the OctoDB library"
def build_extension(self, ext):
log.info(self.description)
ext.libraries.append('octodb')
if sys.platform == "win32":
ext.include_dirs.append(".")
build_ext.build_extension(self, ext)
def get_setup_args():
return dict(
name=PACKAGE_NAME,
version=VERSION,
description="DB-API 2.0 interface for OctoDB",
long_description=long_description,
long_description_content_type="text/markdown",
author="Bernardo Ramos",
author_email="contact@octodb.io",
license="zlib/libpng",
platforms="ALL",
url="https://github.com/octodb/octodb-python3",
package_dir={PACKAGE_NAME: "octodb"},
packages=packages,
ext_modules=[Extension(
name=PACKAGE_NAME + EXTENSION_MODULE_NAME,
sources=sources,
define_macros=define_macros)
],
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: zlib/libpng License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: C",
"Programming Language :: Python",
"Topic :: Database :: Database Engines/Servers",
"Topic :: Software Development :: Libraries :: Python Modules"],
cmdclass={
"build_ext": SystemLibSqliteBuilder
}
)
if __name__ == "__main__":
setuptools.setup(**get_setup_args())