How to install Python package from source on Windows

Deborah Swanson python at deborahswanson.net
Mon May 15 00:19:03 EDT 2017


eryk sun wrote, on Sunday, May 14, 2017 7:15 PM
> 
> On Sun, May 14, 2017 at 8:46 PM, Deborah Swanson 
> <python at deborahswanson.net> wrote:
> > I want to install the recordclass package: 
> > https://pypi.python.org/pypi/recordclass
> >
> > But they've only released wheel files for two platforms, macosx and 
> > win_amd64, neither of which will install on my system. I 
> need win_x86 
> > or intel_x86, which they don't provide.
> 
> The tag for 32-bit Windows is "win32". The PyPI page has 
> win32 wheels for 2.7-3.5.

I'll look at the PyPi page again, it's true I skipped over the Python2
builds, but if that turns out tobe my best option, I can rewrite my
project for Python2.

> If you're using 3.6, you'll have to build from source. The 
> package has a single C extension without external 
> dependencies, so it should be a straight-forward build if you 
> have Visual Studio 2015+ installed with the C/C++ compiler 
> for x86. 

Unfortunately I don't have Visual Studio 2015+ installed and I can't
install it on Windows XP SP2 (plus I really don't want to). Probably I
should have mentioned that, but I didn't know I'd need to build C/C++.

> Ideally it should work straight from pip. But I 
> tried and it failed in 3.6.1 due to the new 
> PySlice_GetIndicesEx macro. Apparently MSVC doesn't like 
> preprocessor code like this in
> memoryslots.c:
> 
>     #if PY_MAJOR_VERSION >= 3
>             if (PySlice_GetIndicesEx(item, Py_SIZE(self),
>     #else
>             if (PySlice_GetIndicesEx((PySliceObject*)item, 
> Py_SIZE(self),
>     #endif
>                              &start, &stop, &step, 
> &slicelength) < 0) {
> 
> It fails with a C1057 error (unexpected end of file in macro 
> expansion). The build will succeed if you copy the common 
> line with `&start` to each case and comment out the original 
> line, such that the macro invocation isn't split across an 
> #if / #endif. This is an ugly consequence of making 
> PySlice_GetIndicesEx a macro. I wonder if it could be written 
> differently to avoid this problem.

There isn't any solution or workaround for me if building C/C++ is
required.




More information about the Python-list mailing list