osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to install Python package from source on Windows


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.

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. 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.