-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathsetup.py
64 lines (51 loc) · 1.69 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
#!usr/bin/env python
import os
import platform
import sys
import glob
###########################################################################
# Check Python's version info and exit early if it is too old
if sys.version_info < (3, 7):
print("This module requires Python >= 3.7")
sys.exit(0)
###########################################################################
from setuptools import setup, Extension
try:
from wheel.bdist_wheel import bdist_wheel
except ImportError:
bdist_wheel = None
if bdist_wheel is not None:
class bdist_wheel_abi3(bdist_wheel):
def get_tag(self):
python, abi, plat = super().get_tag()
if python.startswith("cp"):
# on CPython, our wheels are abi3 and compatible back to 3.5
return "cp38", "abi3", plat
return python, abi, plat
else:
bdist_wheel_abi3 = None
should_build_abi3_wheel = (
bdist_wheel_abi3 and
platform.python_implementation() == "CPython" and
sys.version_info >= (3, 8)
)
# Define the extension
macros = []
if should_build_abi3_wheel:
macros.append(("Py_LIMITED_API", "0x03090000"))
cmdclass = {}
if should_build_abi3_wheel:
cmdclass["bdist_wheel"] = bdist_wheel_abi3
setup(
ext_modules = [
Extension('leidenalg._c_leiden',
sources = glob.glob(os.path.join('src', 'leidenalg', '*.cpp')),
py_limited_api=should_build_abi3_wheel,
define_macros=macros,
libraries = ['libleidenalg', 'igraph'],
include_dirs=['include', 'build-deps/install/include'],
library_dirs=['build-deps/install/lib']
)
],
cmdclass=cmdclass
)