[gdal-dev] building python bindings after cmake compilation

Saulteau Don sault.don at gmail.com
Thu Jun 2 16:28:15 PDT 2022


Thanks Greg,

I'm attempting to update the gdal PKGBUILD from Arch Linux at
https://github.com/archlinux/svntogit-community/blob/packages/gdal/trunk/PKGBUILD
and making revisions as I go along.

It's a split package that breaks python-gdal apart from gdal so not sure
how to compile the python bindings separately at this moment.

I managed to patch the setup.cfg file:

> --- a/gdal/swig/python/setup.cfg        2022-06-02 16:08:22.113109320 -0700
> +++ b/gdal/swig/python/setup.cfg        2022-06-02 16:10:26.913826620 -0700
> @@ -3,8 +3,7 @@
> max-line-length=100
>
> [build_ext]
> -#include_dirs = ../../port:../../gcore:../../alg:../../ogr/
> -#library_dirs = ../../.libs:../../
> +include_dirs =
> ../../../build/port:../../../build/gcore:../../../build/alg:../../../build/ogr/
> +library_dirs = ../../.libs:../../build
> #libraries = gdal
> -gdal_config=../../apps/gdal-config
> -
> +gdal_config=../../../build/apps/gdal-config


If there's a preferred packaging way to build out the python bindings
separately then I'm all ears cause this says it can't find the header files
which are there in the paths patched:

> running build
> running build_py
> running build_ext
> building 'osgeo._gdal' extension
> building 'osgeo._gdalconst' extension
> building 'osgeo._osr' extension
> building 'osgeo._gnm' extension
> building 'osgeo._ogr' extension
> building 'osgeo._gdal_array' extension
> extensions/ogr_wrap.cpp:2838:10: fatal error: gdal.h: No such file or
> directory
> 2838 | #include "gdal.h"
>      |          ^~~~~~~~
> compilation terminated.
> extensions/osr_wrap.cpp:2879:10: fatal error: cpl_string.h: No such file
> or directory
> 2879 | #include "cpl_string.h"
>      |          ^~~~~~~~~~~~~~
> compilation terminated.
> extensions/gdal_array_wrap.cpp:2829:10: fatal error: gdal.h: No such file
> or directory
> 2829 | #include "gdal.h"
>      |          ^~~~~~~~
> compilation terminated.
> extensions/gdalconst_wrap.c:2703:10: fatal error: gdal.h: No such file or
> directory
> 2703 | #include "gdal.h"
>      |          ^~~~~~~~
> compilation terminated.
> extensions/gdal_wrap.cpp:2883:10: fatal error: cpl_port.h: No such file or
> directory
> 2883 | #include "cpl_port.h"
>      |          ^~~~~~~~~~~~
> compilation terminated.
> extensions/gnm_wrap.cpp:2820:10: fatal error: gdal.h: No such file or
> directory
> 2820 | #include "gdal.h"
>      |          ^~~~~~~~
> compilation terminated.
> error: command '/usr/bin/gcc' failed with exit code 1


saultdon

On Thu, Jun 2, 2022 at 4:03 PM Greg Troxel <gdt at lexort.com> wrote:

>
> Saulteau Don <sault.don at gmail.com> writes:
>
> > I have gdal 3.5.0 built using the new cmake system.
> > /chroot/src/build <- cmake build directory
> > /chroot/src/gdal <- src directory
> > /chroot/src/gdal/swig/python
> >
> > My cmake is ran from the /chroot directory:
> >
> >> cmake -B build -S gdal \
> >>       -DCMAKE_BUILD_TYPE='None' \
> >>       -DCMAKE_INSTALL_PREFIX='/usr' \
> >>       -DBUILD_PYTHON_BINDINGS='OFF' \
> >>       -Wno-dev
> >> cmake --build build
> >
> >
> > Then to make the python bindings via swig:
> >
> >> cd gdal/swig/python
> >> python setup.py build
> >
> >
> > When the `python setup.py build` is running it can't find gdal-config
> with
> > the following errors:
>
> This may not be how you want to do this, but if you install the lib and
> then build python as a separate step, it will probably go better.    I
> am unclear on how this is supposed to work; pkgsrc builds non-python
> libs and then python as separate packages.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220602/a3a4817d/attachment-0001.htm>


More information about the gdal-dev mailing list