annotate lib/swig/swigwin-2.0.11/Tools/setup.py.tmpl @ 2575:a76d408c5132 tip

DrawTranslucent -> DrawTextureGrayShade Removed old texture drawing stuff
author a.parshin
date Wed, 09 Mar 2016 01:39:52 +0200
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 #!@PYTHON@
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2 '''A setup.py script with better SWIG support. To use it, either
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3 rename it to setup.py.in and have it pe processed by your configure
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 script (you will need to define @PYTHON@), or replace the @*@ strings
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5 by hand.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7 Copyright 2001, Anthony Joseph Seward'''
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10 from distutils.core import setup, Extension
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12 ###############################################################################
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13 ## Start of better Swig support
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14 ###############################################################################
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15 from distutils.command.build_ext import build_ext
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16 import os
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17 import string
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18 class build_swig_ext(build_ext):
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 '''Better swig support for Distutils'''
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21 ## __ Tell Distutils about the options
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22 user_options = build_ext.user_options
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 boolean_options = build_ext.boolean_options
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25 user_options.append(
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26 ('swig-doc=', None,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27 'what type of documentation should SWIG produce (default: none)')
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28 )
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29 user_options.append(
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 ('swig-inc=', None,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31 'a list of directories to add to the SWIG include path'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32 + "(separated by ':')(default: SWIG)")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33 )
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34 user_options.append(
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35 ('swig-shadow', None,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 'have SWIG create shadow classes'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37 + ' (also adds docstrings to the shadow classes')
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38 )
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40 boolean_options.append('swig-shadow')
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42 def initialize_options(self):
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 '''Initialize the new options after the inherited ones'''
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44 build_ext.initialize_options(self)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45 self.swig_doc = 'none'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 self.swig_inc = 'SWIG'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47 self.swig_shadow = None
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49 def swig_sources(self, sources):
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50 """Override the definition of 'swig_sources' in build_ext. This
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 is essentially the same function but with better swig support.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52 I will now quote the original docstring:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54 Walk the list of source files in 'sources', looking for SWIG
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55 interface (.i) files. Run SWIG on all that are found, and
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
56 return a modified 'sources' list with SWIG source files replaced
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
57 by the generated C (or C++) files.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
58 """
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
59
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
60 new_sources = []
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
61 swig_sources = []
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
62 swig_targets = {}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
63
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
64 # XXX this drops generated C/C++ files into the source tree, which
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
65 # is fine for developers who want to distribute the generated
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
66 # source -- but there should be an option to put SWIG output in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
67 # the temp dir.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
68
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
69 if self.swig_cpp:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
70 target_ext = '.cpp'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
71 else:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
72 target_ext = '.c'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
73
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
74 for source in sources:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
75 (base, ext) = os.path.splitext(source)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
76 if ext == ".i": # SWIG interface file
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
77 new_sources.append(base + target_ext)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
78 swig_sources.append(source)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
79 swig_targets[source] = new_sources[-1]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
80 else:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
81 new_sources.append(source)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
82
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
83 if not swig_sources:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
84 return new_sources
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
85
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
86 includes = self.swig_inc
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
87 if type(includes) is type(''):
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
88 includes = string.split(includes, ':')
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
89 includes = map(lambda x: '-I'+x, includes)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
90 includes = string.join(includes)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
91
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
92 swig = self.find_swig()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
93 ## swig_cmd = [swig, "-python", "-d%s" % self.swig_doc, includes]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
94 swig_cmd = [swig, '-v', '-python', '-d%s' % self.swig_doc, includes]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
95 if self.swig_cpp:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
96 swig_cmd.append('-c++')
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
97
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
98 if self.swig_shadow:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
99 swig_cmd.append('-shadow')
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
100 ## swig1.1 swig_cmd.append('-docstring')
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
101
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
102 for source in swig_sources:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
103 target = swig_targets[source]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
104 self.announce('swigging %s to %s' % (source, target))
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
105 self.spawn(swig_cmd + ['-o', target, source])
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
106
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
107 return new_sources
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
108
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
109 # swig_sources ()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
110 ###############################################################################
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
111 ## End of improved swig support
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
112 ###############################################################################
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
113
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
114 package = '@PACKAGE@'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
115 version = '@VERSION@'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
116 include_dirs = ['@top_srcdir@']
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
117 lib_dirs = ['@top_srcdir@/@PACKAGE@']
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
118 libraries = ['@PACKAGE@', 'stdc++']
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
119
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
120 setup(name = package,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
121 version = version,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
122 description = '',
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
123 author = '',
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
124 author_email = '',
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
125 url = 'http://',
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
126
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
127 cmdclass = {'build_ext': build_swig_ext},
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
128 ext_modules = [Extension(package+'cmodule',
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
129 [package+'.i'],
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
130 include_dirs=include_dirs,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
131 library_dirs=lib_dirs,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
132 libraries=libraries,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
133 )],
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
134 options = {'build_ext':
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
135 {'swig_doc': 'html',
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
136 'swig_cpp': not None,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
137 'swig_shadow': not None}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
138 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
139 )