[gdal-dev] building python bindings after cmake compilation
Saulteau Don
sault.don at gmail.com
Thu Jun 2 15:37:51 PDT 2022
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:
> running build
> running build_py
> running build_ext
> Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 105, in
> fetch_config
> p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
> File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
> self._execute_child(args, executable, preexec_fn, close_fds,
> File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
> raise child_exception_type(errno_num, err_msg, err_filename)
> FileNotFoundError: [Errno 2] No such file or directory:
> '../../apps/gdal-config'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 187, in
> get_gdal_config
> return fetch_config(option, gdal_config=self.gdal_config)
> File "/build/gdal/src/gdal/swig/python/setup.py", line 108, in
> fetch_config
> raise gdal_config_error(e)
> __main__.gdal_config_error: [Errno 2] No such file or directory:
> '../../apps/gdal-config'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 105, in
> fetch_config
> p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
> File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
> self._execute_child(args, executable, preexec_fn, close_fds,
> File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
> raise child_exception_type(errno_num, err_msg, err_filename)
> FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 194, in
> get_gdal_config
> return fetch_config(option)
> File "/build/gdal/src/gdal/swig/python/setup.py", line 108, in
> fetch_config
> raise gdal_config_error(e)
> __main__.gdal_config_error: [Errno 2] No such file or directory:
> 'gdal-config'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 388, in <module>
> setup(**setup_kwargs)
> File "/usr/lib/python3.10/site-packages/setuptools/__init__.py", line
> 155, in setup
> return distutils.core.setup(**attrs)
> File "/usr/lib/python3.10/site-packages/setuptools/_distutils/core.py",
> line 148, in setup
> return run_commands(dist)
> File "/usr/lib/python3.10/site-packages/setuptools/_distutils/core.py",
> line 163, in run_commands
> dist.run_commands()
> File "/usr/lib/python3.10/site-packages/setuptools/_distutils/dist.py",
> line 967, in run_commands
> self.run_command(cmd)
> File "/usr/lib/python3.10/site-packages/setuptools/_distutils/dist.py",
> line 986, in run_command
> cmd_obj.run()
> File
> "/usr/lib/python3.10/site-packages/setuptools/_distutils/command/build.py",
> line 135, in run
> self.run_command(cmd_name)
> File "/usr/lib/python3.10/site-packages/setuptools/_distutils/cmd.py",
> line 313, in run_command
> self.distribution.run_command(command)
> File "/usr/lib/python3.10/site-packages/setuptools/_distutils/dist.py",
> line 985, in run_command
> cmd_obj.ensure_finalized()
> File "/usr/lib/python3.10/site-packages/setuptools/_distutils/cmd.py",
> line 107, in ensure_finalized
> self.finalize_options()
> File "/build/gdal/src/gdal/swig/python/setup.py", line 257, in
> finalize_options
> self.gdaldir = self.get_gdal_config('prefix')
> File "/build/gdal/src/gdal/swig/python/setup.py", line 200, in
> get_gdal_config
> raise gdal_config_error(traceback_string + '\n' + msg)
> __main__.gdal_config_error: Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 105, in
> fetch_config
> p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
> File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
> self._execute_child(args, executable, preexec_fn, close_fds,
> File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
> raise child_exception_type(errno_num, err_msg, err_filename)
> FileNotFoundError: [Errno 2] No such file or directory:
> '../../apps/gdal-config'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 187, in
> get_gdal_config
> return fetch_config(option, gdal_config=self.gdal_config)
> File "/build/gdal/src/gdal/swig/python/setup.py", line 108, in
> fetch_config
> raise gdal_config_error(e)
> gdal_config_error: [Errno 2] No such file or directory:
> '../../apps/gdal-config'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 105, in
> fetch_config
> p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
> File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
> self._execute_child(args, executable, preexec_fn, close_fds,
> File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
> raise child_exception_type(errno_num, err_msg, err_filename)
> FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
> File "/build/gdal/src/gdal/swig/python/setup.py", line 194, in
> get_gdal_config
> return fetch_config(option)
> File "/build/gdal/src/gdal/swig/python/setup.py", line 108, in
> fetch_config
> raise gdal_config_error(e)
> gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'
> Could not find gdal-config. Make sure you have installed the GDAL native
> library and development headers.
It's searching for it in ../../apps/gdal-config which is /chroot/gdal/apps
but could find it in /chroot/build/apps/gdal-config if it searched there
instead. Any way to point `python setup.py build` to look for gdal-config
in a custom path or the one that cmake built gdal in?
saultdon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220602/5c9cecf2/attachment.htm>
More information about the gdal-dev
mailing list