Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/distutils/command/install.py @ 87:2a2c65a20a8b
Add Python libs and headers
author | Chris Cannam |
---|---|
date | Wed, 25 Feb 2015 14:05:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:413a9d26189e | 87:2a2c65a20a8b |
---|---|
1 from __future__ import division, absolute_import, print_function | |
2 | |
3 import sys | |
4 if 'setuptools' in sys.modules: | |
5 import setuptools.command.install as old_install_mod | |
6 have_setuptools = True | |
7 else: | |
8 import distutils.command.install as old_install_mod | |
9 have_setuptools = False | |
10 from distutils.file_util import write_file | |
11 | |
12 old_install = old_install_mod.install | |
13 | |
14 class install(old_install): | |
15 | |
16 # Always run install_clib - the command is cheap, so no need to bypass it; | |
17 # but it's not run by setuptools -- so it's run again in install_data | |
18 sub_commands = old_install.sub_commands + [ | |
19 ('install_clib', lambda x: True) | |
20 ] | |
21 | |
22 def finalize_options (self): | |
23 old_install.finalize_options(self) | |
24 self.install_lib = self.install_libbase | |
25 | |
26 def setuptools_run(self): | |
27 """ The setuptools version of the .run() method. | |
28 | |
29 We must pull in the entire code so we can override the level used in the | |
30 _getframe() call since we wrap this call by one more level. | |
31 """ | |
32 from distutils.command.install import install as distutils_install | |
33 | |
34 # Explicit request for old-style install? Just do it | |
35 if self.old_and_unmanageable or self.single_version_externally_managed: | |
36 return distutils_install.run(self) | |
37 | |
38 # Attempt to detect whether we were called from setup() or by another | |
39 # command. If we were called by setup(), our caller will be the | |
40 # 'run_command' method in 'distutils.dist', and *its* caller will be | |
41 # the 'run_commands' method. If we were called any other way, our | |
42 # immediate caller *might* be 'run_command', but it won't have been | |
43 # called by 'run_commands'. This is slightly kludgy, but seems to | |
44 # work. | |
45 # | |
46 caller = sys._getframe(3) | |
47 caller_module = caller.f_globals.get('__name__', '') | |
48 caller_name = caller.f_code.co_name | |
49 | |
50 if caller_module != 'distutils.dist' or caller_name!='run_commands': | |
51 # We weren't called from the command line or setup(), so we | |
52 # should run in backward-compatibility mode to support bdist_* | |
53 # commands. | |
54 distutils_install.run(self) | |
55 else: | |
56 self.do_egg_install() | |
57 | |
58 def run(self): | |
59 if not have_setuptools: | |
60 r = old_install.run(self) | |
61 else: | |
62 r = self.setuptools_run() | |
63 if self.record: | |
64 # bdist_rpm fails when INSTALLED_FILES contains | |
65 # paths with spaces. Such paths must be enclosed | |
66 # with double-quotes. | |
67 f = open(self.record, 'r') | |
68 lines = [] | |
69 need_rewrite = False | |
70 for l in f: | |
71 l = l.rstrip() | |
72 if ' ' in l: | |
73 need_rewrite = True | |
74 l = '"%s"' % (l) | |
75 lines.append(l) | |
76 f.close() | |
77 if need_rewrite: | |
78 self.execute(write_file, | |
79 (self.record, lines), | |
80 "re-writing list of installed files to '%s'" % | |
81 self.record) | |
82 return r |