prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add a show_versions function
  Similarly to `pandas.show_versions()` and `sklearn.show_versions()`, it would be nice to have a function like that for GeoPandas. We can probably base the code on those examples. 
  
  It could list the versions of the direct python dependencies, but also try to show the versions of the underlying GEOS / GDAL libraries.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `geopandas/tools/_show_versions.py`
  Content:
  ```
  1 import platform
  2 import sys
  3 import importlib
  4 
  5 
  6 def _get_sys_info():
  7     """System information
  8 
  9     Returns
  10     -------
  11     sys_info : dict
  12         system and Python version information
  13     """
  14     python = sys.version.replace('\n', ' ')
  15 
  16     blob = [
  17         ("python", python),
  18         ('executable', sys.executable),
  19         ("machine", platform.platform()),
  20     ]
  21 
  22     return dict(blob)
  23 
  24 
  25 def _get_deps_info():
  26     """Overview of the installed version of main dependencies
  27 
  28     Returns
  29     -------
  30     deps_info: dict
  31         version information on relevant Python libraries
  32     """
  33     deps = [
  34         "geopandas",
  35         "pandas",
  36         "fiona",
  37         "osgeo.gdal",
  38         "numpy",
  39         "shapely",
  40         "rtree",
  41         "pyproj",
  42         "matplotlib",
  43         "mapclassify",
  44         "pysal",
  45         "geopy",
  46         "psycopg2",
  47         "descartes"
  48     ]
  49 
  50     def get_version(module):
  51         return module.__version__
  52 
  53     deps_info = {}
  54 
  55     for modname in deps:
  56         try:
  57             if modname in sys.modules:
  58                 mod = sys.modules[modname]
  59             else:
  60                 mod = importlib.import_module(modname)
  61             ver = get_version(mod)
  62             deps_info[modname] = ver
  63         except ImportError:
  64             deps_info[modname] = None
  65         except AttributeError:
  66             deps_info[modname] = None
  67 
  68     return deps_info
  69 
  70 
  71 def show_versions():
  72     """
  73     Print system information and installed module versions.
  74 
  75     Example
  76     -------
  77     > python -c "import geopandas; geopandas.show_versions()"
  78     """
  79     sys_info = _get_sys_info()
  80     deps_info = _get_deps_info()
  81 
  82     maxlen = max(len(x) for x in deps_info)
  83     tpl = "{{k:<{maxlen}}}: {{stat}}".format(maxlen=maxlen)
  84     print("\nSYSTEM INFO")
  85     print("-----------")
  86     for k, stat in sys_info.items():
  87         print(tpl.format(k=k, stat=stat))
  88     print("\nPYTHON DEPENDENCIES")
  89     print("-------------------")
  90     for k, stat in deps_info.items():
  91         print(tpl.format(k=k, stat=stat))
  92
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/geopandas/tools/_show_versions.py b/geopandas/tools/_show_versions.py
  --- a/geopandas/tools/_show_versions.py
  +++ b/geopandas/tools/_show_versions.py
  @@ -22,6 +22,53 @@
       return dict(blob)
   
   
  +def _get_C_info():
  +    """Information on system PROJ, GDAL, GEOS
  +    Returns
  +    -------
  +    c_info: dict
  +        system PROJ information
  +    """
  +    try:
  +        import pyproj
  +        from pyproj.exceptions import DataDirError
  +        proj = pyproj.proj_version_str
  +        try:
  +            proj_dir = pyproj.datadir.get_data_dir()
  +        except DataDirError:
  +            proj_dir = None
  +    except Exception:
  +        proj = None
  +        proj_dir = None
  +
  +    try:
  +        import shapely._buildcfg
  +        geos = '{}.{}.{}'.format(*shapely._buildcfg.geos_version)
  +        geos_dir = shapely._buildcfg.geos_library_path
  +    except Exception:
  +        geos = None
  +        geos_dir = None
  +
  +    try:
  +        import fiona
  +        gdal = fiona.env.get_gdal_release_name()
  +        gdal_dir = fiona.env.GDALDataFinder().search()
  +    except Exception:
  +        gdal = None
  +        gdal_dir = None
  +
  +    blob = [
  +            ("GEOS", geos),
  +            ("GEOS lib", geos_dir),
  +            ("GDAL", gdal),
  +            ("GDAL dir", gdal_dir),
  +            ("PROJ", proj),
  +            ("PROJ data dir", proj_dir)
  +            ]
  +
  +    return dict(blob)
  +
  +
   def _get_deps_info():
       """Overview of the installed version of main dependencies
   
  @@ -34,7 +81,6 @@
           "geopandas",
           "pandas",
           "fiona",
  -        "osgeo.gdal",
           "numpy",
           "shapely",
           "rtree",
  @@ -43,8 +89,7 @@
           "mapclassify",
           "pysal",
           "geopy",
  -        "psycopg2",
  -        "descartes"
  +        "psycopg2"
       ]
   
       def get_version(module):
  @@ -60,9 +105,7 @@
                   mod = importlib.import_module(modname)
               ver = get_version(mod)
               deps_info[modname] = ver
  -        except ImportError:
  -            deps_info[modname] = None
  -        except AttributeError:
  +        except Exception:
               deps_info[modname] = None
   
       return deps_info
  @@ -78,6 +121,7 @@
       """
       sys_info = _get_sys_info()
       deps_info = _get_deps_info()
  +    proj_info = _get_C_info()
   
       maxlen = max(len(x) for x in deps_info)
       tpl = "{{k:<{maxlen}}}: {{stat}}".format(maxlen=maxlen)
  @@ -85,6 +129,10 @@
       print("-----------")
       for k, stat in sys_info.items():
           print(tpl.format(k=k, stat=stat))
  +    print("\nGEOS, GDAL, PROJ INFO")
  +    print("---------------------")
  +    for k, stat in proj_info.items():
  +        print(tpl.format(k=k, stat=stat))
       print("\nPYTHON DEPENDENCIES")
       print("-------------------")
       for k, stat in deps_info.items():
  
verification_info: {"golden_diff": "diff --git a/geopandas/tools/_show_versions.py b/geopandas/tools/_show_versions.py\n--- a/geopandas/tools/_show_versions.py\n+++ b/geopandas/tools/_show_versions.py\n@@ -22,6 +22,53 @@\n     return dict(blob)\n \n \n+def _get_C_info():\n+    \"\"\"Information on system PROJ, GDAL, GEOS\n+    Returns\n+    -------\n+    c_info: dict\n+        system PROJ information\n+    \"\"\"\n+    try:\n+        import pyproj\n+        from pyproj.exceptions import DataDirError\n+        proj = pyproj.proj_version_str\n+        try:\n+            proj_dir = pyproj.datadir.get_data_dir()\n+        except DataDirError:\n+            proj_dir = None\n+    except Exception:\n+        proj = None\n+        proj_dir = None\n+\n+    try:\n+        import shapely._buildcfg\n+        geos = '{}.{}.{}'.format(*shapely._buildcfg.geos_version)\n+        geos_dir = shapely._buildcfg.geos_library_path\n+    except Exception:\n+        geos = None\n+        geos_dir = None\n+\n+    try:\n+        import fiona\n+        gdal = fiona.env.get_gdal_release_name()\n+        gdal_dir = fiona.env.GDALDataFinder().search()\n+    except Exception:\n+        gdal = None\n+        gdal_dir = None\n+\n+    blob = [\n+            (\"GEOS\", geos),\n+            (\"GEOS lib\", geos_dir),\n+            (\"GDAL\", gdal),\n+            (\"GDAL dir\", gdal_dir),\n+            (\"PROJ\", proj),\n+            (\"PROJ data dir\", proj_dir)\n+            ]\n+\n+    return dict(blob)\n+\n+\n def _get_deps_info():\n     \"\"\"Overview of the installed version of main dependencies\n \n@@ -34,7 +81,6 @@\n         \"geopandas\",\n         \"pandas\",\n         \"fiona\",\n-        \"osgeo.gdal\",\n         \"numpy\",\n         \"shapely\",\n         \"rtree\",\n@@ -43,8 +89,7 @@\n         \"mapclassify\",\n         \"pysal\",\n         \"geopy\",\n-        \"psycopg2\",\n-        \"descartes\"\n+        \"psycopg2\"\n     ]\n \n     def get_version(module):\n@@ -60,9 +105,7 @@\n                 mod = importlib.import_module(modname)\n             ver = get_version(mod)\n             deps_info[modname] = ver\n-        except ImportError:\n-            deps_info[modname] = None\n-        except AttributeError:\n+        except Exception:\n             deps_info[modname] = None\n \n     return deps_info\n@@ -78,6 +121,7 @@\n     \"\"\"\n     sys_info = _get_sys_info()\n     deps_info = _get_deps_info()\n+    proj_info = _get_C_info()\n \n     maxlen = max(len(x) for x in deps_info)\n     tpl = \"{{k:<{maxlen}}}: {{stat}}\".format(maxlen=maxlen)\n@@ -85,6 +129,10 @@\n     print(\"-----------\")\n     for k, stat in sys_info.items():\n         print(tpl.format(k=k, stat=stat))\n+    print(\"\\nGEOS, GDAL, PROJ INFO\")\n+    print(\"---------------------\")\n+    for k, stat in proj_info.items():\n+        print(tpl.format(k=k, stat=stat))\n     print(\"\\nPYTHON DEPENDENCIES\")\n     print(\"-------------------\")\n     for k, stat in deps_info.items():\n", "issue": "Add a show_versions function\nSimilarly to `pandas.show_versions()` and `sklearn.show_versions()`, it would be nice to have a function like that for GeoPandas. We can probably base the code on those examples. \r\n\r\nIt could list the versions of the direct python dependencies, but also try to show the versions of the underlying GEOS / GDAL libraries.\n", "before_files": [{"content": "import platform\nimport sys\nimport importlib\n\n\ndef _get_sys_info():\n    \"\"\"System information\n\n    Returns\n    -------\n    sys_info : dict\n        system and Python version information\n    \"\"\"\n    python = sys.version.replace('\\n', ' ')\n\n    blob = [\n        (\"python\", python),\n        ('executable', sys.executable),\n        (\"machine\", platform.platform()),\n    ]\n\n    return dict(blob)\n\n\ndef _get_deps_info():\n    \"\"\"Overview of the installed version of main dependencies\n\n    Returns\n    -------\n    deps_info: dict\n        version information on relevant Python libraries\n    \"\"\"\n    deps = [\n        \"geopandas\",\n        \"pandas\",\n        \"fiona\",\n        \"osgeo.gdal\",\n        \"numpy\",\n        \"shapely\",\n        \"rtree\",\n        \"pyproj\",\n        \"matplotlib\",\n        \"mapclassify\",\n        \"pysal\",\n        \"geopy\",\n        \"psycopg2\",\n        \"descartes\"\n    ]\n\n    def get_version(module):\n        return module.__version__\n\n    deps_info = {}\n\n    for modname in deps:\n        try:\n            if modname in sys.modules:\n                mod = sys.modules[modname]\n            else:\n                mod = importlib.import_module(modname)\n            ver = get_version(mod)\n            deps_info[modname] = ver\n        except ImportError:\n            deps_info[modname] = None\n        except AttributeError:\n            deps_info[modname] = None\n\n    return deps_info\n\n\ndef show_versions():\n    \"\"\"\n    Print system information and installed module versions.\n\n    Example\n    -------\n    > python -c \"import geopandas; geopandas.show_versions()\"\n    \"\"\"\n    sys_info = _get_sys_info()\n    deps_info = _get_deps_info()\n\n    maxlen = max(len(x) for x in deps_info)\n    tpl = \"{{k:<{maxlen}}}: {{stat}}\".format(maxlen=maxlen)\n    print(\"\\nSYSTEM INFO\")\n    print(\"-----------\")\n    for k, stat in sys_info.items():\n        print(tpl.format(k=k, stat=stat))\n    print(\"\\nPYTHON DEPENDENCIES\")\n    print(\"-------------------\")\n    for k, stat in deps_info.items():\n        print(tpl.format(k=k, stat=stat))\n", "path": "geopandas/tools/_show_versions.py"}], "after_files": [{"content": "import platform\nimport sys\nimport importlib\n\n\ndef _get_sys_info():\n    \"\"\"System information\n\n    Returns\n    -------\n    sys_info : dict\n        system and Python version information\n    \"\"\"\n    python = sys.version.replace('\\n', ' ')\n\n    blob = [\n        (\"python\", python),\n        ('executable', sys.executable),\n        (\"machine\", platform.platform()),\n    ]\n\n    return dict(blob)\n\n\ndef _get_C_info():\n    \"\"\"Information on system PROJ, GDAL, GEOS\n    Returns\n    -------\n    c_info: dict\n        system PROJ information\n    \"\"\"\n    try:\n        import pyproj\n        from pyproj.exceptions import DataDirError\n        proj = pyproj.proj_version_str\n        try:\n            proj_dir = pyproj.datadir.get_data_dir()\n        except DataDirError:\n            proj_dir = None\n    except Exception:\n        proj = None\n        proj_dir = None\n\n    try:\n        import shapely._buildcfg\n        geos = '{}.{}.{}'.format(*shapely._buildcfg.geos_version)\n        geos_dir = shapely._buildcfg.geos_library_path\n    except Exception:\n        geos = None\n        geos_dir = None\n\n    try:\n        import fiona\n        gdal = fiona.env.get_gdal_release_name()\n        gdal_dir = fiona.env.GDALDataFinder().search()\n    except Exception:\n        gdal = None\n        gdal_dir = None\n\n    blob = [\n            (\"GEOS\", geos),\n            (\"GEOS lib\", geos_dir),\n            (\"GDAL\", gdal),\n            (\"GDAL dir\", gdal_dir),\n            (\"PROJ\", proj),\n            (\"PROJ data dir\", proj_dir)\n            ]\n\n    return dict(blob)\n\n\ndef _get_deps_info():\n    \"\"\"Overview of the installed version of main dependencies\n\n    Returns\n    -------\n    deps_info: dict\n        version information on relevant Python libraries\n    \"\"\"\n    deps = [\n        \"geopandas\",\n        \"pandas\",\n        \"fiona\",\n        \"numpy\",\n        \"shapely\",\n        \"rtree\",\n        \"pyproj\",\n        \"matplotlib\",\n        \"mapclassify\",\n        \"pysal\",\n        \"geopy\",\n        \"psycopg2\"\n    ]\n\n    def get_version(module):\n        return module.__version__\n\n    deps_info = {}\n\n    for modname in deps:\n        try:\n            if modname in sys.modules:\n                mod = sys.modules[modname]\n            else:\n                mod = importlib.import_module(modname)\n            ver = get_version(mod)\n            deps_info[modname] = ver\n        except Exception:\n            deps_info[modname] = None\n\n    return deps_info\n\n\ndef show_versions():\n    \"\"\"\n    Print system information and installed module versions.\n\n    Example\n    -------\n    > python -c \"import geopandas; geopandas.show_versions()\"\n    \"\"\"\n    sys_info = _get_sys_info()\n    deps_info = _get_deps_info()\n    proj_info = _get_C_info()\n\n    maxlen = max(len(x) for x in deps_info)\n    tpl = \"{{k:<{maxlen}}}: {{stat}}\".format(maxlen=maxlen)\n    print(\"\\nSYSTEM INFO\")\n    print(\"-----------\")\n    for k, stat in sys_info.items():\n        print(tpl.format(k=k, stat=stat))\n    print(\"\\nGEOS, GDAL, PROJ INFO\")\n    print(\"---------------------\")\n    for k, stat in proj_info.items():\n        print(tpl.format(k=k, stat=stat))\n    print(\"\\nPYTHON DEPENDENCIES\")\n    print(\"-------------------\")\n    for k, stat in deps_info.items():\n        print(tpl.format(k=k, stat=stat))\n", "path": "geopandas/tools/_show_versions.py"}]}