forked from leyuanCv/pymeshfix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
144 lines (121 loc) · 4.88 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
"""Setup for pymeshfix"""
from io import open as io_open
import sys
import os
import builtins
# workaround for *.toml https://github.com/pypa/pip/issues/7953
import site
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext
filepath = os.path.dirname(__file__)
# Define macros for cython
macros = []
if os.name == 'nt': # windows
extra_compile_args = ['/openmp', '/O2', '/w', '/GS']
extra_link_args = []
elif os.name == 'posix': # linux org mac os
if sys.platform == 'linux':
extra_compile_args = ['-std=gnu++11', '-O3', '-w']
else: # probably mac os
extra_compile_args = ['-O3', '-w']
else:
raise Exception('Unsupported OS %s' % os.name)
# Check if 64-bit
if sys.maxsize > 2**32:
macros.append(('IS64BITPLATFORM', None))
# Get version from version info
__version__ = None
version_file = os.path.join(filepath, 'pymeshfix', '_version.py')
with io_open(version_file, mode='r') as fd:
exec(fd.read())
# readme file
readme_file = os.path.join(filepath, 'README.rst')
def needs_cython():
"""Check if cython source exist"""
tgt_path = os.path.join('pymeshfix', 'cython')
has_cython_src = any(['_meshfix.cpp' in fname for fname in os.listdir(tgt_path)])
if not has_cython_src:
try:
import cython
except:
raise ImportError('Please install cython to build ``pymeshfix``')
return not has_cython_src
def needs_numpy():
"""Check if cython source exist"""
tgt_path = os.path.join('pymeshfix')
has_cython_src = any(['_meshfix' in fname for fname in os.listdir(tgt_path)])
return not has_cython_src
# for: the cc1plus: warning: command line option '-Wstrict-prototypes'
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# prevent numpy from thinking it is still in its setup process:
try:
del builtins.__NUMPY_SETUP__
except AttributeError:
pass
import numpy
self.include_dirs.append(numpy.get_include())
def build_extensions(self):
try:
self.compiler.compiler_so.remove("-Wstrict-prototypes")
except (AttributeError, ValueError):
pass
_build_ext.build_extensions(self)
setup_requires = []
if needs_cython():
setup_requires.extend(['cython'])
if needs_numpy():
setup_requires.extend(['numpy'])
setup(
name='pymeshfix',
packages=['pymeshfix', 'pymeshfix/examples'],
version=__version__,
description='Repairs triangular meshes',
long_description=open(readme_file).read(),
author='Alex Kaszynski',
author_email='akascap@gmail.com',
license='MIT',
classifiers=['Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8'
],
url='https://github.com/pyvista/pymeshfix',
# Build cython modules
cmdclass={'build_ext': build_ext},
ext_modules=[Extension("pymeshfix._meshfix",
['pymeshfix/cython/meshfix.cpp',
'pymeshfix/cython/tin.cpp',
'pymeshfix/cython/checkAndRepair.cpp',
'pymeshfix/cython/coordinates.cpp',
'pymeshfix/cython/detectIntersections.cpp',
'pymeshfix/cython/edge.cpp',
'pymeshfix/cython/graph.cpp',
'pymeshfix/cython/heap.cpp',
'pymeshfix/cython/holeFilling.cpp',
'pymeshfix/cython/io.cpp',
'pymeshfix/cython/jqsort.cpp',
'pymeshfix/cython/list.cpp',
'pymeshfix/cython/marchIntersections.cpp',
'pymeshfix/cython/matrix.cpp',
'pymeshfix/cython/orientation.c',
'pymeshfix/cython/point.cpp',
'pymeshfix/cython/tmesh.cpp',
'pymeshfix/cython/triangle.cpp',
'pymeshfix/cython/vertex.cpp',
'pymeshfix/cython/_meshfix.pyx'],
language='c++',
extra_compile_args=extra_compile_args,
define_macros=macros)],
keywords='meshfix',
package_data={'pymeshfix/examples': ['StanfordBunny.ply',
'planar_mesh.ply']},
install_requires=['numpy>1.11.0',
'pyvista>=0.23.0'],
setup_requires=setup_requires,
)