diff --git a/.matplotlib-repo b/.matplotlib-repo new file mode 100644 index 000000000000..0b1d699bcdb1 --- /dev/null +++ b/.matplotlib-repo @@ -0,0 +1,3 @@ +The existence of this file signals that the code is a matplotlib source repo +and not an installed version. We use this in __init__.py for gating version +detection. diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 7df511af1e16..1dcfb827833e 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -164,11 +164,13 @@ def _parse_to_version_info(version_str): def _get_version(): """Return the version string used for __version__.""" - # Only shell out to a git subprocess if really needed, and not on a - # shallow clone, such as those used by CI, as the latter would trigger - # a warning from setuptools_scm. + # Only shell out to a git subprocess if really needed, i.e. when we are in + # a matplotlib git repo but not in a shallow clone, such as those used by + # CI, as the latter would trigger a warning from setuptools_scm. root = Path(__file__).resolve().parents[2] - if (root / ".git").exists() and not (root / ".git/shallow").exists(): + if ((root / ".matplotlib-repo").exists() + and (root / ".git").exists() + and not (root / ".git/shallow").exists()): import setuptools_scm return setuptools_scm.get_version( root=root,
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: