1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
import importlib
import platform
import sys
def _get_sys_info():
"""System information
Returns
-------
sys_info : dict
system and Python version information
"""
python = sys.version.replace("\n", " ")
blob = [
("python", python),
("executable", sys.executable),
("machine", platform.platform()),
]
return dict(blob)
def _get_C_info():
"""Information on system PROJ, GDAL, GEOS
Returns
-------
c_info: dict
system PROJ information
"""
try:
import pyproj
proj_version = pyproj.proj_version_str
except Exception:
proj_version = None
try:
import pyproj
proj_dir = pyproj.datadir.get_data_dir()
except Exception:
proj_dir = None
try:
import shapely._buildcfg
geos_version = "{}.{}.{}".format(*shapely._buildcfg.geos_version)
geos_dir = shapely._buildcfg.geos_library_path
except Exception:
geos_version = None
geos_dir = None
try:
import fiona
gdal_version = fiona.env.get_gdal_release_name()
except Exception:
gdal_version = None
try:
import fiona
gdal_dir = fiona.env.GDALDataFinder().search()
except Exception:
gdal_dir = None
blob = [
("GEOS", geos_version),
("GEOS lib", geos_dir),
("GDAL", gdal_version),
("GDAL data dir", gdal_dir),
("PROJ", proj_version),
("PROJ data dir", proj_dir),
]
return dict(blob)
def _get_deps_info():
"""Overview of the installed version of main dependencies
Returns
-------
deps_info: dict
version information on relevant Python libraries
"""
deps = [
"geopandas",
"pandas",
"fiona",
"numpy",
"shapely",
"rtree",
"pyproj",
"matplotlib",
"mapclassify",
"geopy",
"psycopg2",
"geoalchemy2",
"pyarrow",
]
def get_version(module):
return module.__version__
deps_info = {}
for modname in deps:
try:
if modname in sys.modules:
mod = sys.modules[modname]
else:
mod = importlib.import_module(modname)
ver = get_version(mod)
deps_info[modname] = ver
except Exception:
deps_info[modname] = None
return deps_info
def show_versions():
"""
Print system information and installed module versions.
Examples
--------
::
$ python -c "import geopandas; geopandas.show_versions()"
"""
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)
print("\nSYSTEM INFO")
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():
print(tpl.format(k=k, stat=stat))
|