Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb1d250d

Browse 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 parent12ed239 commitb1d250d

File tree

14 files changed

+52
-2224
lines changed

14 files changed

+52
-2224
lines changed

‎.flake8‎

Lines 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‎

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

‎.gitattributes‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
*.ppmbinary
33
*.svgbinary
44
*.svglinguist-language=true
5-
lib/matplotlib/_version.pyexport-subst
5+
.git_archival.txtexport-subst

‎.github/workflows/tests.yml‎

Lines 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-dateutilsetuptools-scm\
144144
-r requirements/testing/travis_all.txt \
145145
${{ matrix.extra-requirements }}
146146

‎.gitignore‎

Lines 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‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎doc/conf.py‎

Lines 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 theversioneer
199+
# Catch the case where git is not installed locally, and use thesetuptools_scm
200200
# version number instead
201201
except (subprocess.CalledProcessError,FileNotFoundError):
202202
SHA=matplotlib.__version__

‎doc/devel/contributing.rst‎

Lines 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‎

Lines 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 usesetuptools_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‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,15 @@
102102
importtempfile
103103
importwarnings
104104

105+
importnumpy
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
frommatplotlib.cbookimportMatplotlibDeprecationWarning,sanitize_sequence
109111
frommatplotlib.cbookimportmplDeprecation# deprecated
110112
frommatplotlib.rcsetupimportvalidate_backend,cycler
111113

112-
importnumpy
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 ._versionimportget_versions
117-
__version__=str(get_versions()['version'])
118-
delget_versions
119114

120115
_log=logging.getLogger(__name__)
121116

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

137132

133+
def__getattr__(name):
134+
ifname=="__version__":
135+
importsetuptools_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+
raiseAttributeError(f"module{__name__!r} has no attribute{name!r}")
150+
151+
138152
def_check_versions():
139153

140154
# Quickfix to ensure Microsoft Visual C++ redistributable
@@ -1435,7 +1449,6 @@ def inner(ax, *args, data=None, **kwargs):
14351449
returninner
14361450

14371451

1438-
_log.debug('matplotlib version %s',__version__)
14391452
_log.debug('interactive is %s',is_interactive())
14401453
_log.debug('platform is %s',sys.platform)
14411454
_log.debug('loaded modules: %s',list(sys.modules))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp