-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
91 lines (74 loc) · 3.22 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
from setuptools import setup, Extension
from pathlib import Path
_C_DIRECTORIES = ['src/libift',
'src/pyift_c_ext',
]
# https://stackoverflow.com/questions/54117786/add-numpy-get-include-argument-to-setuptools-without-preinstalled-numpy
def _my_build_ext(params):
from setuptools.command.build_ext import build_ext
class BuildExt(build_ext):
def finalize_options(self):
build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
import builtins
builtins.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
return BuildExt(params)
def _get_includes():
includes = _C_DIRECTORIES
return includes
def _get_sources():
sources = []
for directory in _C_DIRECTORIES:
sources += [str(c_files) for c_files in Path(directory).glob('*.c')]
return sources
def setup_package():
build_requires = ['setuptools_scm']
try:
import numpy
except ImportError:
build_requires.append('numpy')
exts = [Extension('_pyift',
sources=_get_sources(),
include_dirs=_get_includes(),
extra_compile_args=['-std=gnu11', '-O3'])
]
meta_data = dict(name='pyift',
author='Jordao Bragantini',
author_email='[email protected]',
description='Python Image Foresting Transform Library',
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
url='https://github.com/pyift/pyift',
license='MIT',
packages=['pyift'],
cmdclass={'build_ext': _my_build_ext},
use_scm_version={'write_to': 'src/pyift/_version.py'},
setup_requires=build_requires,
install_requires=[
'numpy',
'scipy',
],
python_requires=">=3.8",
package_dir={'': 'src'},
ext_modules=exts,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: C',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Scientific/Engineering',
'Topic :: Software Development :: Libraries :: Python Modules',
],
)
setup(**meta_data)
if __name__ == '__main__':
setup_package()