curl-and-python

Re: Building curl/pycurl from source for Python 2.6--sorting out dependencies

From: Nathan E. Moore <nate_at_redtetrahedron.org>
Date: Thu, 05 Nov 2009 19:52:37 -0500

Nathan's Glorious Guide to Building pycurl on windows

This guide builds a monolithic dll, everything (except for the crt) is
statically linked.

This first part of this guide explain how to build libcurl, if you
already know how to do that skip to the end.

Things you will need
(other versions of these programs may work, this is what I have)
1) Visual Studio C++ 2008 Express (aka vc9)
2) perl (openssl's build system requires this)
3) python

Download the source code and unpack it:
zlib -> http://www.zlib.net/ (Optional)
openssl -> http://www.openssl.org/source/ (Optional)
curl -> http://curl.haxx.se/download.html
pycurl -> http://pycurl.sourceforge.net/download/

Versions I am using:
zlib 1.2.3
openssl 0.9.8k
curl-7.19.7
pycurl 7.19.0

At this point you should have a directory that looks like:
curl-7.19.7\
openssl-0.9.8k\
pycurl-7.19.0\
zlib-1.2.3\

The rest of this should be done from the visual C++ command line: This
can be opened from the start menu or from in visual C++ under the Tools
menu.

[if your not sure if you have the right thing, try running cl. You
should see a copyright notice from Microsoft's C/C++ Optimizing Compiler]

Curl, zlib and openssl include direction to build from source on
windows. However I will give a brief description here.

To build zlib from the zlib source dir run:
nmake -f win32\MakeFile.msc

You should now have a zlib.lib in the zlib source dir

Building openssl is more involved. There are several alternatives for
the some of the steps too see INSTALL.W32 in the openssl source for the
details.
1) change to the openssl source dir (for me this is
d:\pycurl\openssl-0.9.8k)
2) run "perl Configure VC-WIN32"
3) run "ms\do_masm"
4) run "nmake -f ms\nt.mak"
5) wait a short while
6) Done. the out32 directory should now contain a bunch of exe and 2 libs

To build libcurl change to the curl directory (for me this is
d:\pycurl\curl-7.19.7). Then run (it is all one line):

nmake vc-ssl-zlib WINDOWS_SSPI=1 VC=vc9
OPENSSL_PATH=D:\pycurl\openssl-0.9.8k ZLIB_PATH=D:\pycurl\zlib-1.2.3

or if building without openssl and zlib

nmake vc VC=vc9 WINDOWS_SSPI=1

The breakdown of that command is
vc-ssl-zlib:
    build curl with visual c, ssl, zlib, staticlly linking everything
WINDOWS_SSPI=1
    use windows' code for NTLM auth rather than openssl
VC=vc9
    using visual c 9 ( this defaults to vc6)
OPENSSL_PATH & ZLIB_PATH
    paths to the source directorys of this librarys, so curl can find
headers and libs. You can use relative paths here but they must be
relative to curl-7.19.7\lib rather than curl-7.19.7.

When that completes you should have a libcurl.lib in curl-7.19.7\lib\

*******

Building PyCurl without ssl and zlib:
Change the pycurl directory and run
python setup.py --curl-dir=..\curl-7.19.7 bdist_msi
and then the dist subdirectory should contain
"pycurl-7-19.0.win32-py2.6.msi" and your done.

[Note if you don't want a msi you can also make an exe with
bdist_wininst a zip with bdist or just install it with install]

*******

Building PyCurl with ssl and zlib
the setup_win32_ssl.py file that pycurl ships doesn't work. This file is
specific to one person's system. I have modified it so that it will work
get a copy at
http://www.longsincefaded.com/curl/setup_win32_ssl_2.txt
and save it to the pycurl directory (Note the txt extensions is because
my webhost is brain damaged, you can rename it to a .py if you wish)

Then change to the pycurl directory and run
python setup_win32_ssl_2.py --curl-dir=..\curl-7.19.7
--openssl-dir=..\openssl-0.9.8k --zlib-dir=..\zlib-1.2.3 bdist_msi
substitution you directories for curl, zlib, and openssl if they are not
as above. The dist subdirectory should contain
"pycurl-ssl-7-19.0.win32-py2.6.msi" and you are done.

[Note if you don't want a msi you can also make an exe with
bdist_winnist a zip with bdist or just install it with install]

Also here is a build log of my build of pycurl with ssl and zlib for
curl 7.19.7
http://www.longsincefaded.com/curl/buildlog.txt
And here is the my msi for 7.19.7 (I have renamed this from what
setup.py creates to indicate what curl release it is)
http://www.longsincefaded.com/curl/pycurl-ssl-7.19.0-libcurl7.19.7.win32-py2.6.msi

Hopefully I (or someone else) will at some point become motivated enough
to do over the setup.py windows support, so I doesn't need to be
monkeypatched to do ssl.

Hope this works for you.

Nathan Moore
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2009-11-06