forked from TuragaLab/malis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
89 lines (73 loc) · 2.3 KB
/
setup.py
File metadata and controls
89 lines (73 loc) · 2.3 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
"""Setup script for the MALIS package.
This script builds the malis package with Cython extensions for efficient
computation of MALIS loss and related graph operations.
"""
import os
import sys
import sysconfig
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext as _build_ext
def get_include_dirs():
"""Get include directories for building C extensions."""
include_dirs = [
os.path.join(os.path.dirname(os.path.abspath(__file__)), "malis"),
]
# Add Python include directories
python_inc = sysconfig.get_path('include')
if python_inc:
include_dirs.append(python_inc)
include_dirs.append(os.path.dirname(python_inc))
return include_dirs
def get_library_dirs():
"""Get library directories for building C extensions."""
library_dirs = [
os.path.join(os.path.dirname(os.path.abspath(__file__)), "malis"),
]
# Add system library directory
libdir = sysconfig.get_config_var("LIBDIR")
if libdir:
library_dirs.append(libdir)
return library_dirs
class build_ext(_build_ext):
"""Custom build_ext command that adds numpy include directory."""
def finalize_options(self):
"""Finalize options, adding numpy include directory."""
_build_ext.finalize_options(self)
# Add numpy include directory
import numpy
self.include_dirs.append(numpy.get_include())
setup(
name='malis',
version='1.0',
description='MALIS segmentation loss function',
url='https://github.com/TuragaLab/malis',
author='Srinivas Turaga',
author_email='turagas@janelia.hhmi.org',
cmdclass={'build_ext': build_ext},
license='MIT',
install_requires=[
'cython>=0.29',
'numpy>=1.19',
'h5py>=3.0',
'scipy>=1.5',
],
setup_requires=[
'cython>=0.29',
'numpy>=1.19',
'scipy>=1.5',
],
packages=['malis'],
ext_modules=[
Extension(
"malis.malis",
["malis/malis.pyx", "malis/malis_cpp.cpp"],
include_dirs=get_include_dirs(),
library_dirs=get_library_dirs(),
language='c++',
extra_link_args=["-std=c++11"],
extra_compile_args=["-std=c++11", "-w"],
)
],
zip_safe=False,
python_requires='>=3.8',
)