annotate DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/distutils/command/install.py @ 133:4acb5d8d80b6 tip

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