geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
483 stars 258 forks source link

Running Unit Tests - Error: apps/gdal-config Missing #309

Closed geekdenz closed 4 years ago

geekdenz commented 4 years ago

I would like to run unit tests so that I can contribute my enhancements and bug fixes.

When I run: pytest tests I get ` ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.7.3, pytest-5.3.0, py-1.8.0, pluggy-0.13.1 rootdir: /home/heuert/projects/landcare/pygeoapi/pygeoapi, inifile: pytest.ini plugins: cov-2.8.1, env-0.6.2 collected 34 items / 4 errors / 30 selected

========================================================================================== ERRORS =========================================================================================== _ ERROR collecting tests/test_ogr_gpkg_provider.py __ ImportError while importing test module '/home/heuert/projects/landcare/pygeoapi/pygeoapi/tests/test_ogr_gpkg_provider.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: tests/test_ogr_gpkg_provider.py:36: in from pygeoapi.provider.ogr import OGRProvider pygeoapi/provider/ogr.py:33: in from osgeo import gdal as osgeo_gdal E ModuleNotFoundError: No module named 'osgeo' _ ERROR collecting tests/test_ogr_shapefile_provider.py _____ ImportError while importing test module '/home/heuert/projects/landcare/pygeoapi/pygeoapi/tests/test_ogr_shapefile_provider.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: tests/test_ogr_shapefile_provider.py:36: in from pygeoapi.provider.ogr import OGRProvider pygeoapi/provider/ogr.py:33: in from osgeo import gdal as osgeo_gdal E ModuleNotFoundError: No module named 'osgeo' ERROR collecting tests/test_ogr_sqliteprovider.py ____ ImportError while importing test module '/home/heuert/projects/landcare/pygeoapi/pygeoapi/tests/test_ogr_sqlite_provider.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: tests/test_ogr_sqlite_provider.py:36: in from pygeoapi.provider.ogr import OGRProvider pygeoapi/provider/ogr.py:33: in from osgeo import gdal as osgeo_gdal E ModuleNotFoundError: No module named 'osgeo' __ ERROR collecting tests/test_ogr_wfs_provider.py __ ImportError while importing test module '/home/heuert/projects/landcare/pygeoapi/pygeoapi/tests/test_ogr_wfs_provider.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: tests/test_ogr_wfs_provider.py:35: in from pygeoapi.provider.ogr import OGRProvider pygeoapi/provider/ogr.py:33: in from osgeo import gdal as osgeo_gdal E ModuleNotFoundError: No module named 'osgeo' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 4 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ===================================================================================== 4 errors in 0.26s ===================================================================================== `

I then run pip install -r requirements-provider.txt with ` Requirement already satisfied: elasticsearch==7.0.4 in /home/heuert/miniconda3/lib/python3.7/site-packages (from -r requirements-provider.txt (line 1)) (7.0.4) Collecting GDAL<3.0,>=2.2 (from -r requirements-provider.txt (line 2)) Using cached https://files.pythonhosted.org/packages/40/36/1a170d95275eb25316a0c12b24e2a2d6ebb1c8cdfa7e9eaf0a7c901822ad/GDAL-2.4.3.tar.gz ERROR: Complete output from command python setup.py egg_info: ERROR: running egg_info creating pip-egg-info/GDAL.egg-info
writing pip-egg-info/GDAL.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/GDAL.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/GDAL.egg-info/toplevel.txt
writing manifest file 'pip-egg-info/GDAL.egg-info/SOURCES.txt'
Traceback (most recent call last):
File "/tmp/pip-install-ozhmbs2
/GDAL/setup.py", line 151, in fetch_config
p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
File "/home/heuert/miniconda3/lib/python3.7/subprocess.py", line 775, in init
restore_signals, start_new_session)
File "/home/heuert/miniconda3/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../../apps/gdal-config': '../../apps/gdal-config'

During handling of the above exception, another exception occurred:                                                                                                                      

Traceback (most recent call last):                                                                                                                                                       
  File "/tmp/pip-install-ozhmbs2_/GDAL/setup.py", line 237, in get_gdal_config                                                                                                           
    return fetch_config(option, gdal_config=self.gdal_config)                                                                                                                            
  File "/tmp/pip-install-ozhmbs2_/GDAL/setup.py", line 154, in fetch_config                                                                                                              
    raise gdal_config_error(e)                                                                                                                                                           
__main__.gdal_config_error: [Errno 2] No such file or directory: '../../apps/gdal-config': '../../apps/gdal-config'                                                                      

During handling of the above exception, another exception occurred:                                                                                                                      

Traceback (most recent call last):
  File "/tmp/pip-install-ozhmbs2_/GDAL/setup.py", line 151, in fetch_config
    p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
  File "/home/heuert/miniconda3/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/home/heuert/miniconda3/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-ozhmbs2_/GDAL/setup.py", line 431, in <module>
    setup(**setup_kwargs)
  File "/home/heuert/miniconda3/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/home/heuert/miniconda3/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/heuert/miniconda3/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/home/heuert/miniconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/heuert/miniconda3/lib/python3.7/site-packages/setuptools/command/egg_info.py", line 296, in run
    self.find_sources()
  File "/home/heuert/miniconda3/lib/python3.7/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
    mm.run()
  File "/home/heuert/miniconda3/lib/python3.7/site-packages/setuptools/command/egg_info.py", line 534, in run
    self.add_defaults()
  File "/home/heuert/miniconda3/lib/python3.7/site-packages/setuptools/command/egg_info.py", line 570, in add_defaults
    sdist.add_defaults(self)
  File "/home/heuert/miniconda3/lib/python3.7/distutils/command/sdist.py", line 228, in add_defaults
    self._add_defaults_ext()
  File "/home/heuert/miniconda3/lib/python3.7/distutils/command/sdist.py", line 311, in _add_defaults_ext
    build_ext = self.get_finalized_command('build_ext')
  File "/home/heuert/miniconda3/lib/python3.7/distutils/cmd.py", line 299, in get_finalized_command
    cmd_obj.ensure_finalized()
  File "/home/heuert/miniconda3/lib/python3.7/distutils/cmd.py", line 107, in ensure_finalized
    self.finalize_options()
  File "/tmp/pip-install-ozhmbs2_/GDAL/setup.py", line 287, in finalize_options
    self.gdaldir = self.get_gdal_config('prefix')
  File "/tmp/pip-install-ozhmbs2_/GDAL/setup.py", line 243, in get_gdal_config
    return fetch_config(option)
  File "/tmp/pip-install-ozhmbs2_/GDAL/setup.py", line 154, in fetch_config
    raise gdal_config_error(e)
__main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'
----------------------------------------

ERROR: Command "python setup.py egginfo" failed with error code 1 in /tmp/pip-install-ozhmbs2/GDAL/ ` as output, which I believe is a dependency for running unit tests.

Expected behavior Tests run somewhat successfully.

Environment

Additional context Trying to help develop PyGeoAPI

justb4 commented 4 years ago

Thanks for contributing @geekdenz ! Looks like installing GDAL python bindings failed. For running all unit tests you will need all Provider components, including native, like GDAL/OGR , ES, PG...That is not yet well documented. A good starting point is the Travis file which is basically the sequence of (Linux Deb Ubuntu) actions to get all tests running, see https://github.com/geopython/pygeoapi/blob/master/.travis.yml Can you give that a try first and we'll work from there?

geekdenz commented 4 years ago

Thanks @justb4 ! Now I'm just letting Travis do the work for this.