forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py.in
148 lines (133 loc) · 4.63 KB
/
setup.py.in
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
145
146
147
148
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
from io import open as io_open
import os
import re
import shutil
import subprocess
import sys
import vtk_features
CMAKE_EXE = os.environ.get('CMAKE_EXE', shutil.which('cmake'))
BUILD_DIR = os.path.dirname(os.path.abspath(__file__))
if not CMAKE_EXE or not os.path.exists(CMAKE_EXE):
print('cmake is required to build from source.', file=sys.stderr)
print('Please install cmake or set CMAKE_EXE environment variable.', file=sys.stderr)
sys.exit(1)
class ConfiguredCMakeExtension(Extension):
def __init__(self, name, target=None):
Extension.__init__(self, name, sources=[])
if target is None:
self.target = name
else:
self.target = target
class CMakeBuildExt(build_ext):
def build_extension(self, ext):
if isinstance(ext, ConfiguredCMakeExtension):
output_dir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
subprocess.check_call([CMAKE_EXE, '--build', BUILD_DIR, '--target', ext.target],
cwd=BUILD_DIR)
else:
super().build_extension(ext)
vtk_reqs_path = os.path.join(BUILD_DIR, 'requirements.txt')
with open(vtk_reqs_path, 'r') as fin:
reqs = [
line
for line in [
rawline.strip()
for rawline in fin
]
if not line.startswith('#')
]
vtk_readme_path = os.path.join(BUILD_DIR, 'README.md')
with io_open(vtk_readme_path, encoding='utf-8') as fin:
readme = fin.read()
# Convert all local references to global references to master
readme = re.sub(r'\[(.*?)\]: ((?!https://).*)$',
r'[\1]: https://gitlab.kitware.com/vtk/vtk/-/raw/master/\2',
readme, flags=re.MULTILINE)
readme = re.sub(r'raw/master/(.*).md', r'blob/master/\1.md', readme, flags=re.MULTILINE)
python_code_features = {
'gtk': [],
'numpy': ['numpy>=1.9'],
'qt': [],
'tk': [],
'wx': [],
}
features = python_code_features
features.update(vtk_features.FEATURES)
setup(
name='vtk',
version='@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@.@VTK_BUILD_VERSION@',
author='VTK developers',
packages=[
'vtkmodules',
'vtkmodules.gtk',
'vtkmodules.numpy_interface',
'vtkmodules.qt',
'vtkmodules.test',
'vtkmodules.tk',
'vtkmodules.util',
'vtkmodules.wx',
],
py_modules=[
'vtk',
],
ext_package='vtkmodules',
ext_modules=[
# https://gitlab.kitware.com/cmake/cmake/-/issues/19145
#ConfiguredCMakeExtension('vtkmodules', target='vtkpythonmodules'),
ConfiguredCMakeExtension('vtkCommonCorePython', target='vtkCommonCorePython'),
],
package_data={
'vtkmodules': [
# Linux modules.
'*-linux-gnu.so',
# Unix shared libraries.
'lib*.so*',
# macOS modules.
'*-darwin.so',
# macOS shared libraries.
'.dylibs',
# Windows modules.
'*.pyd',
# Windows shared libraries.
'*.dll',
],
},
cmdclass={
'build_ext': CMakeBuildExt,
},
url='https://vtk.org',
download_url='https://vtk.org/download/',
license='BSD',
classifiers=[
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: C++",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Healthcare Industry",
"Intended Audience :: Science/Research",
"Topic :: Multimedia :: Graphics",
"Topic :: Multimedia :: Graphics :: 3D Modeling",
"Topic :: Multimedia :: Graphics :: 3D Rendering",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering :: Medical Science Apps.",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Visualization",
"Topic :: Software Development :: Libraries",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS"
],
description='VTK is an open-source toolkit for 3D computer graphics, image processing, and visualization',
long_description=readme,
long_description_content_type='text/markdown',
install_requires=reqs,
extras_require=features,
include_package_data=True,
zip_safe=False,
)