Cute silent failure building pycurl

I was trying to build and install pycurl, but it never actually installed properly. import pycurl just complained that the module was missing, and sure enough, I couldn’t find it anywhere, despite that ./setup.py install kept succeeding.

Peeking into an rpm for pycurl verified that pycurl.so was missing. So why wasn’t it getting installed? It wasn’t even in the build directory. It turns out that I had missed the key error message in the jumble below:

$ python setup.py build 2>&1|fmt -sw50
Using curl-config (libcurl 7.19.6)
running build
running build_py
running build_ext
building 'pycurl' extension
creating build/temp.linux-x86_64-2.6
creating build/temp.linux-x86_64-2.6/src
gcc -pthread -fno-strict-aliasing
-DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC -DHAVE_CURL_SSL=1
-I/toast/pkg/python/v2.6.4/1/root/include/python2.6
-c src/pycurl.c -o
build/temp.linux-x86_64-2.6/src/pycurl.o
src/pycurl.c:85:4: warning: #warning "libcurl was
compiled with SSL support, but configure could
not determine which " "library was used; thus no
SSL crypto locking callbacks will be set, which
may " "cause random crashes on SSL requests"
src/pycurl.c: In function
‘multi_socket_callback’:
src/pycurl.c:2355: warning: call to
‘_curl_easy_getinfo_err_string’ declared with
attribute warning: curl_easy_getinfo expects a
pointer to char * for this info
In function ‘util_curl_unsetopt’,
    inlined from ‘do_curl_unsetopt’ at
    src/pycurl.c:1551:
src/pycurl.c:1476: warning: call to
‘_curl_easy_setopt_err_CURLSH’ declared with
attribute warning: curl_easy_setopt expects a
CURLSH* argument for this option
src/pycurl.c: In function
‘do_multi_info_read’:
src/pycurl.c:2843: warning: call to
‘_curl_easy_getinfo_err_string’ declared with
attribute warning: curl_easy_getinfo expects a
pointer to char * for this info
gcc -pthread -shared
build/temp.linux-x86_64-2.6/src/pycurl.o
-L. -lcurl -lpython2.6 -o
build/lib.linux-x86_64-2.6/pycurl.so unknown
option: --static-libs Usage: curl-config [OPTION]
Available values for OPTION include: --ca ca
bundle install path --cc compiler --cflags
pre-processor and compiler flags --checkfor
[version] check for (lib)curl of the specified
version --features newline separated list
of enabled features --help display this help
and exit --libs library linking information
--prefix curl install prefix --protocols newline
separated list of enabled protocols --version
output version information --vernum output the
version information as a number (hexadecimal)
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for
copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.

Turns out: setup.py was running curl-config --static-libs and feeding the output directly to gcc as a command-line argument. However, this box had curl-config 7.19.5, which apparently doesn’t understand --static-libs, causing it to produce a bunch of usage help. Buried in the garbage was --version, which is gcc’s ticket to exit with 0 nearly regardless of what else is on its command line—and, thus, a “successful” installation. (There’s also --help, but --verbose came later.)

Follow me on Twitter for stuff far more interesting than what I blog.