Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Only import setuptools_scm when we are in a matplotlib git repo #23144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .matplotlib-repo
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 6 additions & 4 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down