-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
80 lines (63 loc) · 2.49 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
from os import path, pardir
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as build_ext_orig
# Get the long description
cwd = path.abspath(path.dirname(__file__))
with open(path.join(cwd, 'docs', 'python_package.md'), encoding='utf-8') as f:
long_description = f.read()
HM_DB_VERSION = "1.1.1"
class build_ext(build_ext_orig):
def write_version_file(self):
with open('src/version.hpp.in', 'r') as f:
fdata = f.read()
fdata = fdata.replace('@hm_VERSION@', HM_DB_VERSION)
with open('src/version.hpp', 'w') as f:
f.write(fdata)
def build_extension(self, ext):
sources = ext.sources
# sort to make the resulting .so file build reproducible
sources = sorted(sources)
ext_path = self.get_ext_fullpath(ext.name)
par_ext_dir = path.abspath(path.join(ext_path, pardir))
self.write_version_file()
extra_args = ["-fPIC", "-fpic", "-O3",
"-DSQLITE_OMIT_LOAD_EXTENSION", "-DSQLITE_MAX_WORKER_THREADS=0", "-DSQLITE_ENABLE_FTS5"]
objects = self.compiler.compile(sources,
output_dir=self.build_temp,
include_dirs=ext.include_dirs,
extra_postargs=extra_args,
depends=ext.depends)
self.compiler.link_executable(
objects, path.join(par_ext_dir, ext.name),
extra_postargs=extra_args,
target_lang="c++")
setup(name='history-manager',
version=HM_DB_VERSION,
description='Command line history manager for bash',
long_description=long_description,
long_description_content_type='text/markdown',
url='http://github.com/dkolmakov/hm',
author='Dmitrii Kolmakov',
author_email='dimannadivane@gmail.com',
license='Apache 2.0',
packages=['hm_initializer'],
ext_modules=[
Extension(
name='hm-db',
sources=[
"src/main.cpp",
"thirdparty/sqlite3/sqlite3.c"
],
include_dirs=[
"src",
"thirdparty/sqlite3",
"thirdparty/apathy",
"thirdparty/clipp"
]
)
],
cmdclass={'build_ext': build_ext},
entry_points={
'console_scripts': ['hm-init=hm_initializer:main'],
},
zip_safe=False)