Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 594ad02

Browse filesBrowse files
committed
Switch to setuptools_scm.
A few noteworthy points: - The contents in the sdist now exactly match what `git archive` would include; this avoids having to additionally keep track of things in MANIFEST.in (as noted in contributing.rst). - The `__version__` of an editable install is no longer recomputed at each import (as was done with `versioneer`, but only whenever the project is (re)installed; this can actually save quite a bit of time when working with many editable installs as each version recomputation requires shelling out a subprocess. (If really wanted we could keep the old behavior by optionally adding a runtime dependency on setuptools_scm and calling `setuptools_scm.get_version` in `matplotlib/__init__.py`.)
1 parent 408b1ab commit 594ad02
Copy full SHA for 594ad02

File tree

Expand file treeCollapse file tree

16 files changed

+58
-2231
lines changed
Filter options
Expand file treeCollapse file tree

16 files changed

+58
-2231
lines changed

‎.flake8

Copy file name to clipboardExpand all lines: .flake8
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ exclude =
3535
doc/gallery
3636
doc/tutorials
3737
# External files.
38-
versioneer.py
3938
tools/gh_api.py
4039
tools/github_stats.py
4140
.tox

‎.git_archival.txt

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref-names: $Format:%D$

‎.gitattributes

Copy file name to clipboardExpand all lines: .gitattributes
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
*.ppm binary
33
*.svg binary
44
*.svg linguist-language=true
5-
lib/matplotlib/_version.py export-subst
5+
.git_archival.txt export-subst

‎.github/workflows/tests.yml

Copy file name to clipboardExpand all lines: .github/workflows/tests.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140
141141
# Install dependencies from PyPI.
142142
python -mpip install --upgrade $PRE \
143-
cycler kiwisolver numpy pillow pyparsing python-dateutil \
143+
cycler kiwisolver numpy pillow pyparsing python-dateutil setuptools-scm \
144144
-r requirements/testing/travis_all.txt \
145145
${{ matrix.extra-requirements }}
146146

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ pip-wheel-metadata/*
4242
# tox testing tool
4343
.tox
4444
setup.cfg
45+
# generated by setuptools_scm
46+
lib/matplotlib/_version.py
4547

4648
# OS generated files #
4749
######################

‎MANIFEST.in

Copy file name to clipboardExpand all lines: MANIFEST.in
-24Lines changed: 0 additions & 24 deletions
This file was deleted.

‎doc/conf.py

Copy file name to clipboardExpand all lines: doc/conf.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _check_dependencies():
196196
try:
197197
SHA = subprocess.check_output(
198198
['git', 'describe', '--dirty']).decode('utf-8').strip()
199-
# Catch the case where git is not installed locally, and use the versioneer
199+
# Catch the case where git is not installed locally, and use the setuptools_scm
200200
# version number instead
201201
except (subprocess.CalledProcessError, FileNotFoundError):
202202
SHA = matplotlib.__version__

‎doc/devel/contributing.rst

Copy file name to clipboardExpand all lines: doc/devel/contributing.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ New modules and files: installation
323323

324324
* If you have added new files or directories, or reorganized existing
325325
ones, make sure the new files are included in the match patterns in
326-
:file:`MANIFEST.in`, and/or in *package_data* in :file:`setup.py`.
326+
in *package_data* in :file:`setupext.py`.
327327

328328
C/C++ extensions
329329
----------------

‎doc/devel/release_guide.rst

Copy file name to clipboardExpand all lines: doc/devel/release_guide.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,12 @@ Finally, push the tag to GitHub::
176176

177177
Congratulations, the scariest part is done!
178178

179-
.. [#] The tarball that is provided by GitHub is produced using `git
180-
archive <https://git-scm.com/docs/git-archive>`__. We use
181-
`versioneer <https://github.com/warner/python-versioneer>`__
182-
which uses a format string in
179+
.. [#] The tarball that is provided by GitHub is produced using `git archive`_.
180+
We use setuptools_scm_ which uses a format string in
183181
:file:`lib/matplotlib/_version.py` to have ``git`` insert a
184182
list of references to exported commit (see
185183
:file:`.gitattributes` for the configuration). This string is
186-
then used by ``versioneer`` to produce the correct version,
184+
then used by ``setuptools_scm`` to produce the correct version,
187185
based on the git tag, when users install from the tarball.
188186
However, if there is a branch pointed at the tagged commit,
189187
then the branch name will also be included in the tarball.
@@ -195,6 +193,8 @@ Congratulations, the scariest part is done!
195193
196194
git archive v2.0.0 -o matplotlib-2.0.0.tar.gz --prefix=matplotlib-2.0.0/
197195
196+
.. _git archive: https://git-scm.com/docs/git-archive
197+
.. _setuptools_scm: https://github.com/pypa/setuptools_scm
198198

199199
If this is a final release, also create a 'doc' branch (this is not
200200
done for pre-releases)::

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+22-9Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,15 @@
102102
import tempfile
103103
import warnings
104104

105+
import numpy
106+
105107
# cbook must import matplotlib only within function
106108
# definitions, so it is safe to import from it here.
107-
from . import _api, cbook, docstring, rcsetup
109+
from . import _api, _version, cbook, docstring, rcsetup
108110
from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
109111
from matplotlib.cbook import mplDeprecation # deprecated
110112
from matplotlib.rcsetup import validate_backend, cycler
111113

112-
import numpy
113-
114-
# Get the version from the _version.py versioneer file. For a git checkout,
115-
# this is computed based on the number of commits since the last tag.
116-
from ._version import get_versions
117-
__version__ = str(get_versions()['version'])
118-
del get_versions
119114

120115
_log = logging.getLogger(__name__)
121116

@@ -135,6 +130,25 @@
135130
}"""
136131

137132

133+
def __getattr__(name):
134+
if name == "__version__":
135+
import setuptools_scm
136+
global __version__ # cache it.
137+
# Only shell out to a git subprocess if really needed.
138+
root = Path(__file__).resolve().parents[2]
139+
if (root / ".git").exists():
140+
__version__ = setuptools_scm.get_version(
141+
root=root,
142+
version_scheme="post-release",
143+
local_scheme="node-and-date",
144+
fallback_version=_version.version,
145+
)
146+
else: # Get the version from the _version.py setuptools_scm file.
147+
__version__ = _version.version
148+
return __version__
149+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
150+
151+
138152
def _check_versions():
139153

140154
# Quickfix to ensure Microsoft Visual C++ redistributable
@@ -1378,7 +1392,6 @@ def inner(ax, *args, data=None, **kwargs):
13781392
return inner
13791393

13801394

1381-
_log.debug('matplotlib version %s', __version__)
13821395
_log.debug('interactive is %s', is_interactive())
13831396
_log.debug('platform is %s', sys.platform)
13841397
_log.debug('loaded modules: %s', list(sys.modules))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.