Skip to content

Commit 250ed9e

Browse files
committed
update version number code for pyproj
Update code to reflect changes to pyproj API that simplify reporting version numbers. Specifically, pyproj pull request 60, pyproj4/pyproj#60
1 parent 116aefb commit 250ed9e

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

lib/mpl_toolkits/basemap/diagnostic.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ def proj4_version():
99
returns string, so proj.4 version 4.9.3 will return "4.9.3"
1010
"""
1111
import pyproj
12-
13-
# Get PROJ4 version in a floating point number
14-
proj4_ver_num = pyproj.Proj(proj='latlong').proj_version
15-
16-
# reformats floating point number into string (4.90 becomes '4.9.0')
17-
# Exploits single number version numbers for proj4,
18-
# This will need likely need to be change at some point as proj.4 version 4.10.0???
19-
return '.'.join( str(int(proj4_ver_num*100)) )
12+
try:
13+
return pyproj.proj_version_str
14+
except AttributeError:
15+
# for pyproj versions 1.9.5.1 and before, this will run
16+
# Get PROJ4 version in a floating point number
17+
proj4_ver_num = pyproj.Proj(proj='latlong').proj_version
18+
19+
# reformats floating point number into string (4.90 becomes '4.9.0')
20+
# Exploits single number version numbers for proj4,
21+
return '.'.join( str(int(proj4_ver_num*100)) )
2022

2123

2224
def package_versions():
@@ -36,6 +38,13 @@ def package_versions():
3638
import _geoslib
3739
from mpl_toolkits.basemap import __version__ as basemap_version
3840

41+
try:
42+
# geodesic is a part of proj.4 library
43+
# new variable in pyproj versions greater than 1.9.5.1
44+
from pyproj import geodesic_version_str as geodesic_version
45+
except ImportError:
46+
geodesic_version = 'Unknown'
47+
3948
# import optional dependencies
4049
try:
4150
from OWSLib import __version__ as OWSLib_version
@@ -56,8 +65,8 @@ def package_versions():
5665
BasemapPackageVersions = namedtuple(
5766
'BasemapPackageVersions',
5867
"""Python, basemap, matplotlib,
59-
numpy, pyproj, pyshp, PROJ4, GEOS,
60-
OWSLib, PIL, Pillow""")
68+
numpy, pyproj, pyshp, PROJ4, geodesic,
69+
GEOS, OWSLib, PIL, Pillow""")
6170

6271
return BasemapPackageVersions(
6372
Python = sys_version,
@@ -67,6 +76,7 @@ def package_versions():
6776
pyproj = pyproj_version,
6877
pyshp = pyshp_version,
6978
PROJ4 = proj4_version(),
79+
geodesic = geodesic_version,
7080
GEOS = _geoslib.__geos_version__,
7181
# optional dependencies below
7282
OWSLib = OWSLib_version,

0 commit comments

Comments
 (0)