Return the version string used for __version__.
()
| 211 | |
| 212 | |
| 213 | def _get_version(): |
| 214 | """Return the version string used for __version__.""" |
| 215 | # Only shell out to a git subprocess if really needed, i.e. when we are in |
| 216 | # a matplotlib git repo but not in a shallow clone, such as those used by |
| 217 | # CI, as the latter would trigger a warning from setuptools_scm. |
| 218 | root = Path(__file__).resolve().parents[2] |
| 219 | if ((root / ".matplotlib-repo").exists() |
| 220 | and (root / ".git").exists() |
| 221 | and not (root / ".git/shallow").exists()): |
| 222 | try: |
| 223 | import setuptools_scm |
| 224 | except ImportError: |
| 225 | pass |
| 226 | else: |
| 227 | return setuptools_scm.get_version( |
| 228 | root=root, |
| 229 | dist_name="matplotlib", |
| 230 | version_scheme="release-branch-semver", |
| 231 | local_scheme="node-and-date", |
| 232 | fallback_version=_version.version, |
| 233 | ) |
| 234 | # Get the version from the _version.py file if not in repo or setuptools_scm is |
| 235 | # unavailable. |
| 236 | return _version.version |
| 237 | |
| 238 | |
| 239 | @_api.caching_module_getattr |
no test coverage detected
searching dependent graphs…