RFC: including zlib.dll on Win32
Alexander Belchenko
bialix at ukr.net
Wed Apr 22 11:04:26 BST 2009
Here is my results so far:
1) I ned to change setup.py to use zlib1 instead of z:
add_pyrex_extension('bzrlib._chk_map_pyx', libraries=['zlib1'])
2) If I put files from zlib123-dll.zip/include to MSVC system include
dir then it can be found by setup.py. But setup.py does not honor
INCLUDE env variable at my win32
3) If I put zdll.lib from zlib123-dll.zip/lib as zlib1.lib to MSVC
system library dir then setup.py can successfully build resulting pyd.
But setup.py does not honor LIB env variable at my win32.
Regarding John proposal:
I think setup.py should set both "include_dirs" and "include_libs"
arguments to build chk_map extension in addition to libraries=['zlib1']
on Windows. Any way is fine if this will be documented way.
setup.py can use env variables INCLUDE/LIB or BZR_INCLUDE/BZR_LIB,
in my opinion both variants are good enough.
Regarding py2exe: zlib1.dll should be in $PATH so py2exe will find it
without problem.
BTW, USAGE.txt suggests to install zlib1.dll to Windows system directory:
Installing ZLIB1.DLL
====================
Copy ZLIB1.DLL to the SYSTEM or the SYSTEM32 directory.
HTH
Alexander Belchenko пишет:
> John, what the version of zlib.dll you are using? Are you using official
> zlib1.dll from http://www.zlib.net?
>
> Here is quote from the USAGE.txt (found in zlib123-dll.zip):
>
> Using ZLIB1.DLL with Microsoft Visual C++
> =========================================
> 1. Install the supplied header files "zlib.h" and "zconf.h"
> into a directory found in the INCLUDE path list.
>
> 2. Install the supplied library files "zdll.exp" and "zdll.lib"
> into a directory found in the LIB path list.
>
> 3. Add "zdll.exp" or "zdll.lib" to your project.
>
> Notes:
> - Usually, you don't need both the .exp file and the .lib file.
> - If you wish, you may rename "zdll.exp" to "zlib1.exp", and/or
> rename "zdll.lib" to "zlib1.lib".
>
>
> Using ZLIB1.DLL with gcc/MinGW
> ==============================
> 1. Install the supplied header files "zlib.h" and "zconf.h"
> into the INCLUDE directory.
>
> 2. Build the import library from the supplied "zlib.def":
> dlltool -D zlib1.dll -d lib/zlib.def -l lib/libzdll.a
>
> OR
>
> 2' Copy the supplied library file "zdll.lib" to "libzdll.a":
> cp lib/zdll.lib lib/libzdll.a
>
> 3. Install "libzdll.a" into the LIB directory.
>
> 4. Add "libzdll.a" to your project, or use the -lzdll option.
>
>
> It seems like bzr's setup.py at least should have include_libs=['zlib1']
>
> Note that official zlib library named zlib1.
>
> I'll try to build_ext on my machine today.
>
>
> John Arbash Meinel пишет:
>> I'm working on building the 1.14rc2 installers for Windows, and I'm
>> running into the problem of not being able to find "zlib.dll" and the
>> "zlib.h" headers.
>>
>> The main problem is that I've done something on my own machine, which
>> means that everything "Just Works" without any extra configuration.
>> However, when I try to compile on Kerguelen, it cannot find the zlib.h
>> header.
>>
>> I can manually add "include_dirs=[]" to the build, and then it starts
>> working. I can then create an environment variable that 'setup.py' looks
>> at, and have it use that to add extra include directories into the build
>> toolchain.
>>
>> However, I'd like to make sure whatever solution is reasonably generic.
>>
>> I would also *really* like to understand why things are found on my
>> machine.
>>
>> The compile commands on my machine seems to be:
>> C:\cygwin\bin\gcc.exe -mno-cygwin -mdll -O -Wall -DWIN32
>> - -Ic:\Python25\include -Ic:\Python25\PC -c bzrlib/_chk_map_pyx.c -o
>> build\temp.win32-2.5\Release\bzrlib\_chk_map_pyx.o
>> writing build\temp.win32-2.5\Release\bzrlib\_chk_map_pyx.def
>>
>> C:\cygwin\bin\gcc.exe -mno-cygwin -shared -s
>> build\temp.win32-2.5\Release\bzrlib\_chk_map_pyx.o
>> build\temp.win32-2.5\Release\bzrlib\_chk_map_pyx.def -Lc:\Python25\libs
>> - -Lc:\Python25\PCBuild -lz -lpython25 -lmsvcr71 -o
>> bzrlib\_chk_map_pyx.pyd
>>
>> And as near as I can tell, there is no 'zlib.h' in any of those
>> directories. I *do* have zlib.h installed into C:/local/include and
>> zlib.lib in C:/local/lib, as a part of some of my other development
>> work. I also installed GTK a while back, which ends up creating C:\GTK
>> and then installing zlib in C:\GTK\INCLUDE, etc. Which also sets an env
>> var "INCLUDE=C:\GTK\INCLUDE".
>>
>> However, if I just:
>>
>> export INCLUDE='C:\home\shared\3rdparty\zlib123\include'
>>
>> doing 'py setup.py build_ext' doesn't seem to find the library.
>>
>>
>> Anyway, I'd like to make a nice simple patch to 'setup.py' so that
>> building will work. And on Windows you'll have to download the zlib.zip
>> file, and configure something like an env variable.
>>
>> What do people think? Should I create new env vars like
>> "BZR_EXTRA_INCLUDE='X;Y;Z'" and then pass that into
>> Extension(include_dirs=[BZR_EXTRA_INCLUDE.split(os.pathsep)]) ?
>>
>> I'd need to have 2 variables, for BZR_EXTRA_INCLUDE and BZR_EXTRA_LIB.
>> (or EXTRA_LIB_DIRS, etc.)
>>
>> Any ideas on a tasteful way to enable linking against a 3rd party on
>> Windows using distutils? I'll also mention that this needs to support
>> both MSVC and Mingw as compilers.
>>
>> John
>> =:->
>
>
>
More information about the bazaar
mailing list