"""numarray: array processing for numbers, strings, records and objects. Numarray is an array processing package designed to efficiently manipulate large multi-dimensional arrays. Numarray is modelled after Numeric and features c-code generated from python template scripts, the capacity to operate directly on arrays in files, and improved type promotions. Numarray provides support for manipulating arrays consisting of numbers, strings, records, or objects using the same basic infrastructure and syntax. """ DOCLINES = __doc__.split("\n") from distutils.core import setup from distutils.command.install_data import install_data from distutils.command.config import config from distutils.sysconfig import get_config_var, customize_compiler from distutils.cygwinccompiler import CygwinCCompiler, Mingw32CCompiler from distutils.bcppcompiler import BCPPCompiler from distutils.msvccompiler import MSVCCompiler try: from distutils.command.config import log except: pass import sys, os, os.path import glob from generate import VERSION, EXTRA_COMPILE_ARGS, EXTRA_LINK_ARGS, SELFTEST from generate import NUMARRAY_PACKAGES, NUMARRAY_PACKAGE_DIRS, NUMARRAY_EXTENSIONS, NUMARRAY_DATA_FILES from cfg_examples import EXAMPLES_PACKAGES, EXAMPLES_PACKAGE_DIRS, EXAMPLES_EXTENSIONS, EXAMPLES_DATA_FILES from cfg_packages import ADDONS_PACKAGES, ADDONS_PACKAGE_DIRS, ADDONS_EXTENSIONS, ADDONS_DATA_FILES PACKAGE_DIRS = {} PACKAGE_DIRS.update(NUMARRAY_PACKAGE_DIRS) PACKAGE_DIRS.update(EXAMPLES_PACKAGE_DIRS) PACKAGE_DIRS.update(ADDONS_PACKAGE_DIRS) # ================================================================= # Configuration: # Running "python setup.py config" determines some machine # parameters that are used in dlapack_lite.c and zlapack_lite.c. def prepend_path(p): try: os.environ["PATH"] = p + os.pathsep + os.environ["PATH"] except KeyError: pass class config_numarray(config): def run (self): # Get a compiler self._check_compiler() try: log.set_verbosity(0) except: pass self.dump_source = 0 # Switch off optimization if isinstance(self.compiler, BCPPCompiler): self.compiler.compile_options.remove('/O2') elif isinstance(self.compiler, MSVCCompiler): if sys.version_info < (2,4): self.compiler.compile_options.remove('/Ox') self.compiler.compile_options.remove('/GX') else: if isinstance(self.compiler, CygwinCCompiler): cc = 'gcc' elif isinstance(self.compiler, Mingw32CCompiler): cc = 'gcc -mno-cygwin' else: # UnixCCompiler cc = get_config_var('CC') if os.environ.has_key('CC'): cc = os.environ['CC'] self.compiler.set_executable('compiler_so',cc) directory = os.path.join("Packages","LinearAlgebra2","Src") testcode = """\ #include "%s" """ % os.path.join(directory,"config.c") prepend_path(".") if sys.version_info < (2,3): self.compiler.exe_extension = "" if self.try_run(testcode, include_dirs=[directory]): print "Wrote config.h" if os.path.isfile(os.path.join(directory,"config.h")): os.remove(os.path.join(directory,"config.h")) os.rename("config.h",os.path.join(directory,"config.h")) else: print "Configuration failed, using default compilation" if os.path.isfile(os.path.join(directory,"config.h")): os.remove(os.path.join(directory,"config.h")) # Restore usual compiler flags if isinstance(self.compiler, BCPPCompiler): self.compiler.compile_options.append('/O2') elif isinstance(self.compiler, MSVCCompiler): self.compiler.compile_options.append('/Ox') self.compiler.compile_options.append('/GX') else: customize_compiler(self.compiler) try: log.set_verbosity(1) except: pass # ================================================================= # Pete Shinner's distutils data file fix... from distutils-sig #data installer with improved intelligence over distutils #data files are copied into the project directory instead #of willy-nilly class smart_install_data(install_data): def run(self): #need to change self.install_dir to the library dir install_cmd = self.get_finalized_command('install') self.install_dir = getattr(install_cmd, 'install_lib') return install_data.run(self) # ================================================================= def headers(): return glob.glob(os.path.join("Include","numarray","*.h")) def dolocal(): """Adds a command line parameter --local=