forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py.in
executable file
·144 lines (117 loc) · 4.74 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
#!/usr/bin/env python
"""
setup.py for installing the VTK-Python bindings using distutils.
Created by Prabhu Ramachandran, June 2002.
Updated for install with configuration types by Brad King, August 2005.
"""
import sys
import string
import os
import os.path
from types import StringType
from distutils.core import setup
from distutils.command.install_data import install_data
from distutils.sysconfig import get_config_var
# Support for Python Eggs:
# http://peak.telecommunity.com/DevCenter/PythonEggs
# http://peak.telecommunity.com/DevCenter/EasyInstall
has_setup_tools = 0
try:
from setuptools import setup
except ImportError:
pass
else:
has_setup_tools = 1
# VTK build configuration settings.
vtk_version = "@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@"
vtk_lib_dir = "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@"
vtk_bin_dir = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@"
vtk_has_configuration_types = @VTK_PYTHON_HAS_CONFIG_TYPES@
vtk_modules = """@VTK_PYTHON_MODULES@""".split(';')
# The build type ('Release', 'Debug' etc.). If vtk_has_configuration_types
# is true this must be set. It may be set on the command line by something
# like 'BUILD_TYPE=Release'. For example::
# python setup.py install --prefix=D:\\Python23 BUILD_TYPE=Release
vtk_build_type = @VTK_PYTHON_BUILD_TYPE@
# Construct the list of executable names to be installed.
vtk_exe_names = ['vtkpython']
def get_libs():
"""Returns a list of libraries to be installed. """
libs = []
# Select platform-specific components of the module file names.
if os.name == 'posix':
dir = vtk_lib_dir
suffix = get_config_var('SO')
else:
dir = vtk_bin_dir.replace('/', '\\')
suffix = '.pyd'
# If this build has configuration types append the selected configuration.
if vtk_has_configuration_types:
dir = os.path.join(dir, vtk_build_type)
# Enumerate the list of module files.
for mod in vtk_modules:
libs.append(os.path.abspath(os.path.join(dir, mod+'Python'+suffix)))
return libs
def get_scripts():
"""Returns the appropriate vtkpython executable and pvtkpython
that is to be installed."""
scripts = []
# Select platform-specific components of the executable file names.
if os.name == 'posix':
dir = vtk_lib_dir
suffix = ''
else:
dir = vtk_bin_dir.replace('/', '\\')
suffix = '.exe'
# If this build has configuration types append the selected configuration.
if vtk_has_configuration_types:
dir = os.path.join(dir, vtk_build_type)
# Enumerate the list of executable files.
for exe in vtk_exe_names:
scripts.append(os.path.abspath(os.path.join(dir, exe+suffix)))
return scripts
class my_install_data (install_data):
def finalize_options (self):
"""Needed to make this thing work properly."""
self.set_undefined_options ('install',
('install_lib', 'install_dir'),
('root', 'root'),
('force', 'force'),
)
if __name__ == '__main__':
# Get the optional build type argument.
for x in sys.argv[:]:
if string.find(x, 'BUILD_TYPE') > -1:
vtk_build_type = string.strip(string.split(x, '=')[1])
sys.argv.remove(x)
break
# Make sure a build type was specified if it is required.
if vtk_has_configuration_types:
if not vtk_build_type:
raise "ERROR: Must specify BUILD_TYPE=<config-name> on command line."
def mk_dict(**kw):
# Unnecessary in recent Pythons but handy for earlier
# versions.
return kw
# The options for setup.
opts = mk_dict(name = "VTK",
version = vtk_version,
description = "The Visualization Toolkit",
maintainer = "VTK Developers",
maintainer_email = "vtk-developers@vtk.org",
license = "BSD",
long_description = "A high level visualization library",
url = "http://www.vtk.org/",
platforms = ['Any'],
cmdclass = {'install_data': my_install_data},
packages = ['vtk', 'vtk.gtk', 'vtk.qt4',
'vtk.tk', 'vtk.util', 'vtk.wx',
'vtk.test'],
#scripts = get_scripts(),
data_files = [('vtk', get_libs())]
)
# If setup_tools is available, then add an extra option to disable
# creation of a ZIP file.
if has_setup_tools:
opts['zip_safe'] = 0
setup(**opts)