AttributeError: 'list' object has no attribute 'lower'

647 views
Skip to first unread message

AJ Friend

unread,
Nov 3, 2015, 12:25:49 AM11/3/15
to cython-users
I can install my Cython wrapper, https://github.com/ajfriend/scs_python, just fine on OSX with

python setup.py install --cython

(which I'm not entirely sure is best practice, btw).

However, when I try to install the package on Travis-CI or on an Ubuntu virtual machine, I get an error with the traceback

....
  File "/usr/local/lib/python2.7/dist-packages/Cython/Distutils/build_ext.py", line 221, in cython_sources
    (extension.language and extension.language.lower() == 'c++')
AttributeError: 'list' object has no attribute 'lower'

The full traceback can be seen here: https://travis-ci.org/ajfriend/scs_python/jobs/88937838

Any idea what's going wrong and how I can get it working?

Thanks,
AJ

AJ Friend

unread,
Nov 3, 2015, 6:01:34 PM11/3/15
to cython-users
A little more info: 

To try and tease out the error, I run the cython compile step on my OSX machine to produce the appropriate .c extension files. I use that output on a linux machine and run

python setup.py install

which runs without Cython to try and install the package. But I get a very similar error on Linux (which I don't get on OSX):

...
running build_ext
Traceback (most recent call last):
  File "/usr/lib/python2.7/pdb.py", line 1314, in main
    pdb._runscript(mainpyfile)
...
  File "/usr/local/lib/python2.7/dist-packages/setuptools/extension.py", line 45, in _convert_pyx_sources_to_lang
    target_ext = '.cpp' if lang.lower() == 'c++' else '.c'
AttributeError: 'list' object has no attribute 'lower'
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /usr/local/lib/python2.7/dist-packages/setuptools/extension.py(45)_convert_pyx_sources_to_lang()
-> target_ext = '.cpp' if lang.lower() == 'c++' else '.c'
(Pdb) p lang
['f', '7', '7', 'f', '7', '7']

Running the setup.py script under Pdb suggests that the variable `lang` should be a string instead of a list, so I'm not sure why that's happening. I'm also not sure if its reasonable that Fortran
is in the conversation, since my module is in C (although it does use blas and lapack).

Could this possibly be a Cython bug? More likely, I'm doing something wrong, but any help tracking it down would be appreciated.

Thanks,
AJ

AJ Friend

unread,
Nov 4, 2015, 6:06:13 AM11/4/15
to cython-users
Ah, I figured out what I was doing wrong.

I was building up a dictionary of keyword arguments to instantiate the Extension modules, and part of that included appending the output of numpy.distutils.system_info.get_info
for the blas/lapack info. Almost all of the keys match up correctly (define_macros, library_dirs, ...), except the 'language' key, which is exactly what was causing my error.

Sorry to debug out loud! :)

AJ 
Reply all
Reply to author
Forward
0 new messages