[SciPy-user] weave issue NEVER MIND

Chris Fonnesbeck fonnesbeck at gmail.com
Thu Dec 15 10:20:11 CST 2005


I'm an idiot. Sorry.

On 12/15/05, Chris Fonnesbeck <fonnesbeck at gmail.com> wrote:
> I am trying to use weave inline to help me calculate the gamma function:
>
> def gamma_function(xx):
>
>     # Returns the value ln[gamma(xx)] for xx > 0
>     gammln = """
>             # Line 10 "likelihood_plots.py"
>             double x,y,tmp,ser;
>             static double cof[6]={76.18009172947146,-86.50532032941677,
>                 24.01409824083091,-1.231739572450155,
>                 0.1208650973866179e-2,-0.5395239384953e-5};
>             int j;
>             y=x=xx;
>             tmp=x+5.5;
>             tmp -= (x+0.5)*log(tmp);
>             ser=1.000000000190015;
>             for (j=0;j<=5;j++) ser += cof[j]/++y;
>             return_val = -tmp+log(2.5066282746310005*ser/x);
>     """
>
>     return weave.inline(gammln,['xx'],headers=['math.h'],compiler='gcc')
>
> As far as I can tell this looks valid. However, it fails:
>
> <weave: compiling>
> /Users/chris/.python24_compiled/sc_2ced629c1dae7b8a8d767dfb199392380.cpp:17:10:
> #include expects "FILENAME" or <FILENAME>
> /Users/chris/.python24_compiled/sc_2ced629c1dae7b8a8d767dfb199392380.cpp:660:23:
> invalid preprocessing directive #Line
> /Users/chris/.python24_compiled/sc_2ced629c1dae7b8a8d767dfb199392380.cpp:17:10:
> #include expects "FILENAME" or <FILENAME>
> /Users/chris/.python24_compiled/sc_2ced629c1dae7b8a8d767dfb199392380.cpp:660:23:
> invalid preprocessing directive #Line
> ---------------------------------------------------------------------------
> scipy.weave.build_tools.CompileError
> Traceback (most recent call last)
>
> /Users/chris/<console>
>
> /Users/chris/likelihood_plots.py in gamma_function(xx=4.0)
>      22     """
>      23
> ---> 24     return weave.inline(gammln,['xx'],headers=['math.h'],compiler='gcc')
>         global weave.inline = <function inline at 0x26aec30>
>         gammln = ' \n            # Line 10 "likelihood_plots.py"\n
>        double x,y,tmp,ser; \n            static double
> cof[6]={76.18009172947146,-86.50532032941677, \n
> 24.01409824083091,-1.231739572450155, \n
> 0.1208650973866179e-2,-0.5395239384953e-5}; \n            int j; \n
>         y=x=xx; \n            tmp=x+5.5; \n            tmp -=
> (x+0.5)*log(tmp); \n            ser=1.000000000190015; \n
> for (j=0;j<=5;j++) ser += cof[j]/++y; \n            return_val =
> -tmp+log(2.5066282746310005*ser/x); \n    '
>         global headers = undefined
>         global compiler = undefined
>      25
>      26 def factln(x):
>
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/inline_tools.py
> in inline(code=' \n            # Line 10 "likelihood_plots.py"\n
> ...n_val = -tmp+log(2.5066282746310005*ser/x); \n    ',
> arg_names=['xx'], local_dict={'__builtins__': {'ArithmeticError':
> <class exceptions.ArithmeticError at 0x7ba0>, 'AssertionError': <class
> exceptions.AssertionError at 0x7ab0>, 'AttributeError': <class
> exceptions.AttributeError at 0x7960>, 'DeprecationWarning': <class
> exceptions.DeprecationWarning at 0x1e120>, 'EOFError': <class
> exceptions.EOFError at 0x7750>, 'Ellipsis': Ellipsis,
> 'EnvironmentError': <class exceptions.EnvironmentError at 0x7630>,
> 'Exception': <class exceptions.Exception at 0x7480>, 'False': False,
> 'FloatingPointError': <class exceptions.FloatingPointError at 0x7cc0>,
> ...}, 'gammln': ' \n            # Line 10 "likelihood_plots.py"\n
> ...n_val = -tmp+log(2.5066282746310005*ser/x); \n    ', 'xx': 4.0},
> global_dict={'ArrayType': <type 'scipy.ndarray'>, 'Character': 'S1',
> 'Complex': 'D', 'Complex0': 'D', 'Complex128': 'G', 'Complex32': 'F',
> 'Complex64': 'D', 'ERR_CALL': 3, 'ERR_DEFAULT': 0, 'ERR_IGNORE': 0,
> ...}, force=0, compiler='gcc', verbose=0, support_code=None,
> headers=['math.h'], customize=None, type_converters=None,
> auto_downcast=1, **kw={})
>     332                                     customize=customize,
>     333                                     type_converters = type_converters,
> --> 334                                     auto_downcast = auto_downcast,
>         auto_downcast = 1
>     335                                     **kw)
>     336
>
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/inline_tools.py
> in compile_function(code=' \n            # Line 10
> "likelihood_plots.py"\n  ...n_val =
> -tmp+log(2.5066282746310005*ser/x); \n    ', arg_names=['xx'],
> local_dict={'__builtins__': {'ArithmeticError': <class
> exceptions.ArithmeticError at 0x7ba0>, 'AssertionError': <class
> exceptions.AssertionError at 0x7ab0>, 'AttributeError': <class
> exceptions.AttributeError at 0x7960>, 'DeprecationWarning': <class
> exceptions.DeprecationWarning at 0x1e120>, 'EOFError': <class
> exceptions.EOFError at 0x7750>, 'Ellipsis': Ellipsis,
> 'EnvironmentError': <class exceptions.EnvironmentError at 0x7630>,
> 'Exception': <class exceptions.Exception at 0x7480>, 'False': False,
> 'FloatingPointError': <class exceptions.FloatingPointError at 0x7cc0>,
> ...}, 'gammln': ' \n            # Line 10 "likelihood_plots.py"\n
> ...n_val = -tmp+log(2.5066282746310005*ser/x); \n    ', 'xx': 4.0},
> global_dict={'ArrayType': <type 'scipy.ndarray'>, 'Character': 'S1',
> 'Complex': 'D', 'Complex0': 'D', 'Complex128': 'G', 'Complex32': 'F',
> 'Complex64': 'D', 'ERR_CALL': 3, 'ERR_DEFAULT': 0, 'ERR_IGNORE': 0,
> ...}, module_dir='likelihood_plots.py', compiler='gcc', verbose=0,
> support_code=None, headers=['math.h'], customize=None,
> type_converters=None, auto_downcast=1, **kw={})
>     440     # setting.  All input keywords are passed through to distutils
>     441     mod.compile(location=storage_dir,compiler=compiler,
> --> 442                 verbose=verbose, **kw)
>         verbose = 0
>         kw = {}
>     443
>     444     # import the module and return the function.  Make sure
>
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/ext_tools.py
> in compile(self=<scipy.weave.inline_tools.inline_ext_module instance
> at 0x4610260>, location='/Users/chris/.python24_compiled',
> compiler='gcc', verbose=0, **kw={'define_macros': [],
> 'extra_compile_args': [], 'extra_link_args': [], 'include_dirs':
> ['/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave',
> '/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/scxx'],
> 'libraries': [], 'library_dirs': [], 'sources':
> ['/Library/Frameworks/Python.framework/Versions/2....n2.4/site-packages/scipy/weave/scxx/weave_imp.cpp']})
>     351         success = build_tools.build_extension(file, temp_dir = temp,
>     352                                               compiler_name = compiler,
> --> 353                                               verbose = verbose, **kw)
>         verbose = 0
>         kw = {'extra_link_args': [], 'define_macros': [], 'libraries':
> [], 'sources': ['/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/scxx/weave_imp.cpp'],
> 'extra_compile_args': [], 'library_dirs': [], 'include_dirs':
> ['/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave',
> '/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/scxx']}
>     354         if not success:
>     355             raise SystemError, 'Compilation failed'
>
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/build_tools.py
> in build_extension(module_path='/Users/chris/.python24_compiled/sc_2ced629c1dae7b8a8d767dfb199392380.cpp',
> compiler_name='unix', build_dir='/Users/chris/.python24_compiled',
> temp_dir='/tmp/chris/python24_intermediate/compiler_d8b3562b82bb4cfa4fea7b37ec5ea6ce',
> verbose=0, **kw={'define_macros': [], 'extra_compile_args': [],
> 'extra_link_args': [], 'include_dirs':
> ['/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave',
> '/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/scxx'],
> 'libraries': [], 'library_dirs': [], 'sources':
> ['/Library/Frameworks/Python.framework/Versions/2....n2.4/site-packages/scipy/weave/scxx/weave_imp.cpp']})
>     272         environ = copy.deepcopy(os.environ)
>     273         try:
> --> 274             setup(name = module_name, ext_modules = [ext],verbose=verb)
>         setup = <function setup at 0x2932530>
>         global name = undefined
>         module_name = 'sc_2ced629c1dae7b8a8d767dfb199392380'
>         global ext_modules = undefined
>         ext = <scipy.distutils.extension.Extension instance at 0x4620b48>
>         verbose = 0
>         verb = 0
>     275         finally:
>     276             # restore state
>
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/distutils/core.py
> in setup(**attr={'ext_modules': [<scipy.distutils.extension.Extension
> instance at 0x4620b48>], 'name':
> 'sc_2ced629c1dae7b8a8d767dfb199392380', 'verbose': 0})
>      91         new_attr['data_files'] = new_data_files
>      92
> ---> 93     return old_setup(**new_attr)
>         global old_setup = <function setup at 0x28a37b0>
>         new_attr = {'cmdclass': {'bdist_rpm': <class
> scipy.distutils.command.bdist_rpm.bdist_rpm at 0x292fc00>, 'sdist':
> <class scipy.distutils.command.sdist.sdist at 0x29182d0>, 'build_src':
> <class scipy.distutils.command.build_src.build_src at 0x290ef00>,
> 'config_fc': <class scipy.distutils.command.config_compiler.config_fc
> at 0x28fe360>, 'build_clib': <class
> scipy.distutils.command.build_clib.build_clib at 0x28fea50>,
> 'build_scripts': <class
> scipy.distutils.command.build_scripts.build_scripts at 0x290ef60>,
> 'build_ext': <class scipy.distutils.command.build_ext.build_ext at
> 0x28fe690>, 'develop': <class setuptools.command.develop.develop at
> 0x292fed0>, 'build_py': <class
> scipy.distutils.command.build_py.build_py at 0x28fe330>,
> 'install_data': <class
> scipy.distutils.command.install_data.install_data at 0x29186f0>,
> 'egg_info': <class setuptools.command.egg_info.egg_info at 0x2b2a8a0>,
> 'install_headers': <class
> scipy.distutils.command.install_headers.install_headers at 0x292f6f0>,
> 'easy_install': <class setuptools.command.easy_install.easy_install at
> 0x295ec90>, 'bdist_egg': <class setuptools.command.bdist_egg.bdist_egg
> at 0x28dffc0>, 'install': <class
> scipy.distutils.command.install.install at 0x292f720>, 'config':
> <class scipy.distutils.command.config.config at 0x28f7f90>, 'build':
> <class scipy.distutils.command.build.build at 0x28fe240>}, 'headers':
> [], 'ext_modules': [<scipy.distutils.extension.Extension instance at
> 0x4620b48>], 'name': 'sc_2ced629c1dae7b8a8d767dfb199392380',
> 'verbose': 0}
>      94
>      95 def _check_append_library(libraries, item):
>
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/distutils/core.py
> in setup(**attrs={'cmdclass': {'bdist_egg': <class
> setuptools.command.bdist_egg.bdist_egg at 0x28dffc0>, 'bdist_rpm':
> <class scipy.distutils.command.bdist_rpm.bdist_rpm at 0x292fc00>,
> 'build': <class scipy.distutils.command.build.build at 0x28fe240>,
> 'build_clib': <class scipy.distutils.command.build_clib.build_clib at
> 0x28fea50>, 'build_ext': <class
> scipy.distutils.command.build_ext.build_ext at 0x28fe690>, 'build_py':
> <class scipy.distutils.command.build_py.build_py at 0x28fe330>,
> 'build_scripts': <class
> scipy.distutils.command.build_scripts.build_scripts at 0x290ef60>,
> 'build_src': <class scipy.distutils.command.build_src.build_src at
> 0x290ef00>, 'config': <class scipy.distutils.command.config.config at
> 0x28f7f90>, 'config_fc': <class
> scipy.distutils.command.config_compiler.config_fc at 0x28fe360>, ...},
> 'ext_modules': [<scipy.distutils.extension.Extension instance at
> 0x4620b48>], 'headers': [], 'name':
> 'sc_2ced629c1dae7b8a8d767dfb199392380', 'script_args': ['build_ext',
> '--compiler=unix', '--build-lib', '/Users/chris/.python24_compiled',
> '--build-temp',
> '/tmp/chris/python24_intermediate/compiler_d8b3562b82bb4cfa4fea7b37ec5ea6ce'],
> 'script_name': '', 'verbose': 0})
>     164                 raise
>     165             else:
> --> 166                 raise SystemExit, "error: " + str(msg)
>         global SystemExit = undefined
>         global str = undefined
>         msg = <distutils.errors.CompileError instance at 0x4625058>
>     167
>     168     return dist
>
> CompileError: error: Command "c++ -fno-strict-aliasing
> -Wno-long-double -no-cpp-precomp -mno-fused-madd -fPIC -fno-common
> -dynamic -DNDEBUG -g -O3 -Wstrict-prototypes
> -I/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave
> -I/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/weave/scxx
> -I/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy/base/include
> -I/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4
> -c /Users/chris/.python24_compiled/sc_2ced629c1dae7b8a8d767dfb199392380.cpp
> -o /tmp/chris/python24_intermediate/compiler_d8b3562b82bb4cfa4fea7b37ec5ea6ce/Users/chris/.python24_compiled/sc_2ced629c1dae7b8a8d767dfb199392380.o"
> failed with exit status 1
>
>
> --
> Chris Fonnesbeck
> Atlanta, GA
>


--
Chris Fonnesbeck
Atlanta, GA



More information about the SciPy-user mailing list