cannot build on Windows using Microsoft Visual C

Bug #695127 reported by Bryan Buck
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
PylibLZMA
New
Undecided
Unassigned

Bug Description

I've been trying to build pyliblzma on Windows using the compiler from Visual Studio 2010, and have encountered some issues. I had to make some changes to get it to build - I've attached a patch that contains my changes. The issues it addresses are:

- On Windows, the subprocess module won't allow you to specify close_fds=True when creating a new process if you are also redirecting stdin/stdout/stderr. I just took out the close_fds=True; it doesn't seem strictly necessary.
- The VERSION macro that is to be passed to the compiler with the -D option is defined as "%s" % version, but this results in passing -DVERSION=<version> when we really want to pass -DVERSION="<version>". So I added an extra set of escaped quotes.
- We need to pass the name of the library to the Microsoft linker as "liblzma" instead of just "lzma."
- Since there's no default place to install liblzma, we need to be able to tell setup.py where to find it. To do this, I added variables "include_dirs" and "library_dirs," and pass those to Extension(). A user can edit the setup.py to add the appropriate locations to these variables. (This isn't the most elegant solution, but it's the way most of the Python modules I've used do it.)
- Microsoft Visual C doesn't have inttypes.h. I created an msvc_inttypes.h and added ifdefs to include this instead of inttypes.h if we are building in Visual C.
- The __inline__ keyword is not defined in MS Visual C; the equivalent is __inline - I added an ifdef for this.
- The __attribute__ keyword is, as far as I know, specific to GCC; in any case MS Visual C doesn't have it. I added an ifdef that defines this to nothing if not building on GCC.

With those changes, pyliblzma seems to build and work fine on Windows with Visual C (I've been using it).

Let me know if you have any questions about my patch or about compiling with MSVC. Thanks!

Revision history for this message
Bryan Buck (bbuck) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.