matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
780 stars 392 forks source link

Build error with Python 3.7 #414

Closed sscherfke closed 6 years ago

sscherfke commented 6 years ago

I am trying to build basemap for Python 3.7 with conda-build. The build fails with the following error:

    In file included from src/_geoslib.c:433:0:
    /opt/emsconda/conda-bld/basemap_1531822202353/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_p
lacehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold
_placehold_placehold_pl/include/geos_c.h:149:22: note: expected ‘GEOSMessageHandler’ but argument is of type ‘void (*)
(char *, char *)’
     extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
                          ^
    src/_geoslib.c: In function ‘__Pyx__ExceptionSave’:
    src/_geoslib.c:5798:19: error: ‘PyThreadState’ has no member named ‘exc_type’
         *type = tstate->exc_type;
                       ^
    src/_geoslib.c:5799:20: error: ‘PyThreadState’ has no member named ‘exc_value’
         *value = tstate->exc_value;
                        ^
    src/_geoslib.c:5800:17: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         *tb = tstate->exc_traceback;
                     ^
    src/_geoslib.c: In function ‘__Pyx__ExceptionReset’:
    src/_geoslib.c:5807:22: error: ‘PyThreadState’ has no member named ‘exc_type’
         tmp_type = tstate->exc_type;
                          ^
    src/_geoslib.c:5808:23: error: ‘PyThreadState’ has no member named ‘exc_value’
         tmp_value = tstate->exc_value;
                           ^
    src/_geoslib.c:5809:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tmp_tb = tstate->exc_traceback;
                        ^
    src/_geoslib.c:5810:11: error: ‘PyThreadState’ has no member named ‘exc_type’
         tstate->exc_type = type;
               ^
    src/_geoslib.c:5811:11: error: ‘PyThreadState’ has no member named ‘exc_value’
         tstate->exc_value = value;
               ^
    src/_geoslib.c:5812:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tstate->exc_traceback = tb;
               ^
    src/_geoslib.c: In function ‘__Pyx__GetException’:
    src/_geoslib.c:5857:22: error: ‘PyThreadState’ has no member named ‘exc_type’
         tmp_type = tstate->exc_type;
                          ^
    src/_geoslib.c:5858:23: error: ‘PyThreadState’ has no member named ‘exc_value’
         tmp_value = tstate->exc_value;
                           ^
    src/_geoslib.c:5859:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tmp_tb = tstate->exc_traceback;
                        ^
    src/_geoslib.c:5860:11: error: ‘PyThreadState’ has no member named ‘exc_type’
         tstate->exc_type = local_type;
               ^
    src/_geoslib.c:5861:11: error: ‘PyThreadState’ has no member named ‘exc_value’
         tstate->exc_value = local_value;
               ^
    src/_geoslib.c:5862:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
         tstate->exc_traceback = local_tb;
               ^
    src/_geoslib.c: In function ‘__Pyx_PyCFunction_FastCall’:
    src/_geoslib.c:5912:5: error: too many arguments to function ‘(struct PyObject * (*)(struct PyObject *, struct PyO
bject * const*, Py_ssize_t))meth’
         return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
         ^
    error: Command "gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -flto -fuse-linker-pl
ugin -ffat-lto-objects -flto-partition=none -fPIC -I/opt/emsconda/conda-bld/basemap_1531822202353/_h_env_placehold_pla
cehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p
lacehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/include -I/opt/emsconda/conda-bld/basemap_1531
822202353/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p
lacehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/si
te-packages/numpy/core/include -I/opt/emsconda/conda-bld/basemap_1531822202353/_h_env_placehold_placehold_placehold_pl
acehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_
placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages/numpy/core/include -I/opt/emsconda/co
nda-bld/basemap_1531822202353/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p
lacehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold
_pl/include/python3.7m -c src/_geoslib.c -o build/temp.linux-x86_64-3.7/src/_geoslib.o -MMD -MF build/temp.linux-x86_6
4-3.7/src/_geoslib.o.d" failed with exit status 1

I have tried the latest release as well as the current master. I tried NumPy 1.14 and the RC for 1.15. I tried using an external libgeos and using the bundled one.

All combinations are working with Python 3.6 but failing with 3.7.

sscherfke commented 6 years ago

It looks like regenerating the C sources with cythonize helps:

# Ensure our geos will be used.
rm -rf $SRC_DIR/geos-3.3.3
export GEOS_DIR=$PREFIX

# Regenerate C sources for Python 3.7
cythonize --force src/_geoslib.pyx

$PYTHON -m pip install -I --no-deps .
lugizmo commented 6 years ago

Thanks @sscherfke that and installing pyproj from source fixed my problem with python 3.7!

WeatherGod commented 6 years ago

I would welcome a PR that updates the cython output.

On Thu, Jul 19, 2018 at 10:22 AM, Lukas Guz notifications@github.com wrote:

Thanks @sscherfke https://github.com/sscherfke that and installing pyproj from source fixed my problem with python 3.7!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/414#issuecomment-406293785, or mute the thread https://github.com/notifications/unsubscribe-auth/AARy-EbpyuzEKxe4NNDbthjc7H-luUj3ks5uIJYsgaJpZM4VSlMz .

milancurcic commented 6 years ago

FWIW, I ran into this issue building my project with Python 3.7.1 and this thread got me on the right track. The only step necessary was to build pyproj from source before installing basemap. If I list pyproj github repo in my requirements.txt, this takes care of itself.

git+https://github.com/jswhit/pyproj
git+https://github.com/matplotlib/basemap

Cythonizing src/_geoslib.pyx was thus not necessary for me.

This is on Fedora 24, basemap-1.2.0, matplotlib-3.0.1, pyproj-1.9.5.1, geos-devel-3.5.0.3.