-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
111 lines (94 loc) · 3.37 KB
/
setup.py
File metadata and controls
111 lines (94 loc) · 3.37 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import os
import subprocess
import sys
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
with open("README.md", "r", encoding="utf-8") as fp:
readme = fp.read()
with open("VERSION", "r", encoding="utf-8") as fp:
ista_version = fp.read().strip()
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_ext):
def run(self):
try:
subprocess.check_output(["cmake", "--version"])
except OSError:
raise RuntimeError("CMake must be installed to build C++ extensions")
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
# Create build directory
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
cmake_args = [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
"-DBUILD_PYTHON_BINDINGS=ON",
"-DBUILD_GUI=OFF",
]
cfg = "Debug" if self.debug else "Release"
build_args = ["--config", cfg]
if sys.platform.startswith("win"):
cmake_args += [f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}"]
build_args += ["--", "/m"]
else:
cmake_args += [f"-DCMAKE_BUILD_TYPE={cfg}"]
build_args += ["--", "-j2"]
env = os.environ.copy()
env["CXXFLAGS"] = (
f'{env.get("CXXFLAGS", "")} -DVERSION_INFO="{self.distribution.get_version()}"'
)
subprocess.check_call(
["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env
)
subprocess.check_call(
["cmake", "--build", ".", "--target", "_libista_owl2"] + build_args,
cwd=self.build_temp,
)
setup(
name="ista",
version=ista_version,
author="Joseph D. Romano",
description="A Python/C++ toolkit for building and manipulating knowledge graphs.",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/JDRomano2/ista",
packages=find_packages(),
python_requires=">=3.7",
install_requires=[
"openpyxl",
"pandas",
"tqdm",
"pybind11>=2.6.0",
],
extras_require={
"mysql": ["mysqlclient"],
"neo4j": ["neo4j"],
"graph": ["networkx"],
"dev": ["pytest", "sphinx"],
},
ext_modules=[CMakeExtension("_libista_owl2", sourcedir=".")],
cmdclass={"build_ext": CMakeBuild},
entry_points={
"console_scripts": [
"ista_populate=ista.populate:main",
"owl2memgraph=ista.owl2memgraph:main",
]
},
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: C++",
],
zip_safe=False,
)