annotate DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/random/setup.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, print_function
Chris@87 2
Chris@87 3 from os.path import join, split, dirname
Chris@87 4 import os
Chris@87 5 import sys
Chris@87 6 from distutils.dep_util import newer
Chris@87 7 from distutils.msvccompiler import get_build_version as get_msvc_build_version
Chris@87 8
Chris@87 9 def needs_mingw_ftime_workaround():
Chris@87 10 # We need the mingw workaround for _ftime if the msvc runtime version is
Chris@87 11 # 7.1 or above and we build with mingw ...
Chris@87 12 # ... but we can't easily detect compiler version outside distutils command
Chris@87 13 # context, so we will need to detect in randomkit whether we build with gcc
Chris@87 14 msver = get_msvc_build_version()
Chris@87 15 if msver and msver >= 8:
Chris@87 16 return True
Chris@87 17
Chris@87 18 return False
Chris@87 19
Chris@87 20 def configuration(parent_package='',top_path=None):
Chris@87 21 from numpy.distutils.misc_util import Configuration, get_mathlibs
Chris@87 22 config = Configuration('random', parent_package, top_path)
Chris@87 23
Chris@87 24 def generate_libraries(ext, build_dir):
Chris@87 25 config_cmd = config.get_config_cmd()
Chris@87 26 libs = get_mathlibs()
Chris@87 27 tc = testcode_wincrypt()
Chris@87 28 if config_cmd.try_run(tc):
Chris@87 29 libs.append('Advapi32')
Chris@87 30 ext.libraries.extend(libs)
Chris@87 31 return None
Chris@87 32
Chris@87 33 # enable unix large file support on 32 bit systems
Chris@87 34 # (64 bit off_t, lseek -> lseek64 etc.)
Chris@87 35 defs = [('_FILE_OFFSET_BITS', '64'),
Chris@87 36 ('_LARGEFILE_SOURCE', '1'),
Chris@87 37 ('_LARGEFILE64_SOURCE', '1')]
Chris@87 38 if needs_mingw_ftime_workaround():
Chris@87 39 defs.append(("NPY_NEEDS_MINGW_TIME_WORKAROUND", None))
Chris@87 40
Chris@87 41 libs = []
Chris@87 42 # Configure mtrand
Chris@87 43 config.add_extension('mtrand',
Chris@87 44 sources=[join('mtrand', x) for x in
Chris@87 45 ['mtrand.c', 'randomkit.c', 'initarray.c',
Chris@87 46 'distributions.c']]+[generate_libraries],
Chris@87 47 libraries=libs,
Chris@87 48 depends=[join('mtrand', '*.h'),
Chris@87 49 join('mtrand', '*.pyx'),
Chris@87 50 join('mtrand', '*.pxi'),],
Chris@87 51 define_macros=defs,
Chris@87 52 )
Chris@87 53
Chris@87 54 config.add_data_files(('.', join('mtrand', 'randomkit.h')))
Chris@87 55 config.add_data_dir('tests')
Chris@87 56
Chris@87 57 return config
Chris@87 58
Chris@87 59 def testcode_wincrypt():
Chris@87 60 return """\
Chris@87 61 /* check to see if _WIN32 is defined */
Chris@87 62 int main(int argc, char *argv[])
Chris@87 63 {
Chris@87 64 #ifdef _WIN32
Chris@87 65 return 0;
Chris@87 66 #else
Chris@87 67 return 1;
Chris@87 68 #endif
Chris@87 69 }
Chris@87 70 """
Chris@87 71
Chris@87 72 if __name__ == '__main__':
Chris@87 73 from numpy.distutils.core import setup
Chris@87 74 setup(configuration=configuration)