steeve / python-lz4

LZ4 bindings for python
http://github.com/steeve/python-lz4
105 stars 31 forks source link

compiling using msvc #27

Open totaam opened 10 years ago

totaam commented 10 years ago

For compiling with MSVC on win32, you have to remove the extra_compile_args, or better still replace it with one suited for MSVC like this one:

extra_compile_args=["/Ot", "/Wall", "/DLZ4_VERSION=\"r119\""]

More information on those flags can be found here: http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx

(not sure how you would go about detecting which compiler is going to be used by distutils - I guess checking for environment variables like VCINSTALLDIR is a good bet? or maybe checking if CL.exe is on the PATH but GCC isn't?)

keeely commented 9 years ago

I would try: from distutils import ccompiler if ccompiler.get_default_compiler() == "msvc":

But that wasn't enough for vs2008. Still need stdint.h.

rutsky commented 8 years ago

lz4 fails to build on Windows on Travis:

  Running setup.py install for lz4
    Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\appveyor\\appdata\\local\\temp\\1\\pip-build-ggvw3t\\lz4\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\appveyor\appdata\local\temp\1\pip-frp1ws-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'lz4' extension
    creating build
    creating build\temp.win32-2.7
    creating build\temp.win32-2.7\Release
    creating build\temp.win32-2.7\Release\src
    C:\Users\appveyor\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcsrc/lz4.c /Fobuild\temp.win32-2.7\Release\src/lz4.obj -std=c99 -O3 -Wall -W -Wundef -DLZ4_VERSION="r119"
    cl : Command line error D8004 : '/W' requires an argument
    error: command 'C:\\Users\\appveyor\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\appveyor\\appdata\\local\\temp\\1\\pip-build-ggvw3t\\lz4\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\appveyor\appdata\local\temp\1\pip-frp1ws-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\appveyor\appdata\local\temp\1\pip-build-ggvw3t\lz4

If this library is still maintained it's easy to add AppVeyor configuration to run lz4 tests on Windows to prevent issues like this.