curl-and-python
Re: Windows builds
Date: Wed, 18 Dec 2013 13:43:03 +0100
"Oleg Pudeyev" <oleg+pycurl_at_bsdpower.com> wrote:
> Doing an "all out" libcurl build with openssl etc. seems to be
> complicated, but it is not necessary if someone can source an already
> built binary.
It would be much easier if setup.py could link against the import-lib
of libcurl. As it is written now (static libcurl.lib), it must link with all
the external libs libcurl depends on. E.g. gdi32.lib, wldap32.lib, winmm.lib
etc. So why isn't 'CURL_STATICLIB' removed by default?
For my own, I've patched setup.py like this:
--- Git-latest/setup.py 2013-12-18 10:20:30 +0000
+++ setup.py 2013-12-18 12:05:35 +0000
@@ -84,14 +84,24 @@
fail("Curl directory is not a directory: %s" % curl_dir)
print("Using curl directory: %s" % curl_dir)
include_dirs.append(os.path.join(curl_dir, "include"))
+
+ if scan_argv("--use-curl-dll", "") != "":
+ extra_compile_args.append("-DPYCURL_USE_LIBCURL_DLL=1")
+ extra_compile_args.append("-D_WIN32_WINNT=0x0501")
+ libcurl_lib_path = os.path.join(curl_dir, "lib", "libcurl_imp.lib")
+ extra_link_args.extend(["ws2_32.lib"])
+ else:
libcurl_lib_path = os.path.join(curl_dir, "lib", "libcurl.lib")
+ extra_link_args.extend(["gdi32.lib", "wldap32.lib", "winmm.lib", "ws2_32.lib",])
+
if not os.path.exists(libcurl_lib_path):
fail("libcurl.lib does not exist at %s.\nCurl directory must point to compiled libcurl (bin/include/lib subdirectories):
%s" %(libcurl_lib_path, curl_dir))
extra_objects.append(libcurl_lib_path)
- extra_link_args.extend(["gdi32.lib", "wldap32.lib", "winmm.lib", "ws2_32.lib",])
add_libdirs("LIB", ";")
+
if str.find(sys.version, "MSC") >= 0:
extra_compile_args.append("-O2")
+ extra_compile_args.append("-MD")
extra_compile_args.append("-GF") # enable read-only string pooling
extra_compile_args.append("-WX") # treat warnings as errors
p = subprocess.Popen(['cl.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
---------------
The "-D_WIN32_WINNT=0x0501" should IMHO be default since inet_ntop()
is not present in ws2_32.dll on Win-XP. Only Vista+. Running any python
script using pycurl now gives this cryptic message:
import sys, socket, pycurl
ImportError: DLL load failed: The given function was not found.
I.e. a missing "inet_ntop" in ws2_32.dll.
--gv
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2013-12-18