[gdal-dev] python 2.7 bindings with trunk (2.3)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] python 2.7 bindings with trunk (2.3)

Gregory, Matthew
Hi all,

I'm sure to show my ignorance here, but I've been periodically building both the 2.2 and trunk branches on Windows using MSVC for Python 2.7 (as I think the compiler version needs to match how Python itself was built [MSC v.1500 32 bit (Intel)]).  With the recent update in trunk requiring C++11, MSVC for Python 2.7 now errors out:

  c:\foss4g\gdal_trunk\gdal\port\cpl_port.h(187) : fatal error C1189:
    #error :  Must have C++11 or newer.

Is there a way to compile the GDAL python bindings with still using MSVC for Python 2.7 -or- if I update to MSVC 14, can I still build bindings that will work with 2.7?

Sorry if I've missed discussion around this topic.  I reviewed RFC 68, but didn't see any reference to this issue.

thanks, matt
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: python 2.7 bindings with trunk (2.3)

Even Rouault-2

On vendredi 5 janvier 2018 17:51:26 CET Gregory, Matthew wrote:

> Hi all,

>

> I'm sure to show my ignorance here, but I've been periodically building both

> the 2.2 and trunk branches on Windows using MSVC for Python 2.7 (as I think

> the compiler version needs to match how Python itself was built [MSC v.1500

> 32 bit (Intel)]). With the recent update in trunk requiring C++11, MSVC

> for Python 2.7 now errors out:

>

> c:\foss4g\gdal_trunk\gdal\port\cpl_port.h(187) : fatal error C1189:

> #error : Must have C++11 or newer.

>

> Is there a way to compile the GDAL python bindings with still using MSVC for

> Python 2.7 -or- if I update to MSVC 14, can I still build bindings that

> will work with 2.7?

 

Define

SET DISTUTILS_USE_SDK=1

SET MSSdk=1

 

so that the active MSVC version is used when building the Python bindings. This is what is used in gisinternals builds & appveyor builds

 

We should likely document that somewhere appropriate. Perhaps in

https://trac.osgeo.org/gdal/wiki/BuildingOnWindows

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: python 2.7 bindings with trunk (2.3)

Gregory, Matthew
Thanks Even,

Even Rouault wrote:
> Define
> SET DISTUTILS_USE_SDK=1
> SET MSSdk=1
>  
> so that the active MSVC version is used when building the Python
> bindings. This is what is used in gisinternals builds & appveyor builds

That worked for me (although I would have never found it, so I appreciate your help).  I've put these two lines in gdal/swig/makefile.vc, e.g.

--- a/gdal/swig/makefile.vc
+++ b/gdal/swig/makefile.vc
@@ -20,6 +20,8 @@ python: gdalvars
         $(SWIG) -c++ -python -modern -new_repr -I../include/python -I../include/python/docs -o extensions/ogr_wrap.cpp -outdir osgeo ..\include\ogr.i
         $(SWIG) -c++ -python -modern -new_repr -I../include/python -I../include/python/docs -o extensions/gnm_wrap.cpp -outdir osgeo ..\include\gnm.i
         $(SWIG) -c++ -python -modern -new_repr -I../include/python -I../include/python/docs -o extensions/gdal_array_wrap.cpp -outdir osgeo ..\include\gdal_array.i
+        set DISTUTILS_USE_SDK=1
+        set MSSdk=1
         $(PYDIR)\python.exe setup.py build
  cd ..

Is this a solution that would work across all branches and compilers?

thanks, matt
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: python 2.7 bindings with trunk (2.3)

Even Rouault-2

> That worked for me (although I would have never found it, so I appreciate

> your help). I've put these two lines in gdal/swig/makefile.vc, e.g.

>

> --- a/gdal/swig/makefile.vc

> +++ b/gdal/swig/makefile.vc

> @@ -20,6 +20,8 @@ python: gdalvars

> $(SWIG) -c++ -python -modern -new_repr -I../include/python

> -I../include/python/docs -o extensions/ogr_wrap.cpp -outdir osgeo

> ..\include\ogr.i $(SWIG) -c++ -python -modern -new_repr -I../include/python

> -I../include/python/docs -o extensions/gnm_wrap.cpp -outdir osgeo

> ..\include\gnm.i $(SWIG) -c++ -python -modern -new_repr -I../include/python

> -I../include/python/docs -o extensions/gdal_array_wrap.cpp -outdir osgeo

> ..\include\gdal_array.i

> + set DISTUTILS_USE_SDK=1

> + set MSSdk=1

> $(PYDIR)\python.exe setup.py build

> cd ..

>

> Is this a solution that would work across all branches and compilers?

 

Would indeed be a better solution that a documentation hint. CC'ing Tamas Szekeres if he sees any issue with that approach (since I stole the trick from his gisinternals build recipees)

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev