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

Skip to content

Commit d572ccd

Browse files
committed
Remove matplotlibrc.template.
1 parent 91cb8a8 commit d572ccd

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ Thumbs.db
5454

5555
# Things specific to this project #
5656
###################################
57-
lib/matplotlib/mpl-data/matplotlib.conf
58-
lib/matplotlib/mpl-data/matplotlibrc
5957
tutorials/intermediate/CL01.png
6058
tutorials/intermediate/CL02.png
6159

matplotlibrc.template renamed to lib/matplotlib/mpl-data/matplotlibrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
## PS PDF SVG Template
7979
## You can also deploy your own backend outside of Matplotlib by referring to
8080
## the module name (which must be in the PYTHONPATH) as 'module://my_backend'.
81-
#backend: Agg
81+
#backend:
8282

8383
## The port to use for the web server in the WebAgg backend.
8484
#webagg.port: 8988

setup.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
]
6767

6868

69+
cmdclass = versioneer.get_cmdclass()
70+
71+
6972
# From https://bugs.python.org/issue26689
7073
def has_flag(self, flagname):
7174
"""Return whether a flag name is supported on the specified compiler."""
@@ -200,9 +203,38 @@ def build_extensions(self):
200203
return super().build_extensions()
201204

202205

203-
cmdclass = versioneer.get_cmdclass()
206+
def update_matplotlibrc(path):
207+
# Update the matplotlibrc file if packagers want to change the default
208+
# backend.
209+
template_lines = path.read_text().splitlines(True)
210+
backend_line_idx, = [ # Also asserts that there is a single such line.
211+
idx for idx, line in enumerate(template_lines)
212+
if line.startswith("#backend:")]
213+
template_lines[backend_line_idx] = (
214+
"#backend: {}".format(setupext.options["backend"])
215+
if setupext.options["backend"]
216+
else "#backend:")
217+
path.write_text("".join(template_lines))
218+
219+
220+
class BuildPy(cmdclass['build_py']):
221+
def run(self):
222+
super().run()
223+
update_matplotlibrc(
224+
Path(self.build_lib, "matplotlib/mpl-data/matplotlibrc"))
225+
226+
227+
class Sdist(cmdclass['sdist']):
228+
def make_release_tree(self, base_dir, files):
229+
super().make_release_tree(base_dir, files)
230+
update_matplotlibrc(
231+
Path(base_dir, "lib/matplotlib/mpl-data/matplotlibrc"))
232+
233+
204234
cmdclass['test'] = NoopTestCommand
205235
cmdclass['build_ext'] = BuildExtraLibraries
236+
cmdclass['build_py'] = BuildPy
237+
cmdclass['sdist'] = Sdist
206238

207239

208240
package_data = {} # Will be filled below by the various components.
@@ -243,18 +275,6 @@ def build_extensions(self):
243275
package_data.setdefault(key, [])
244276
package_data[key] = list(set(val + package_data[key]))
245277

246-
# Write the default matplotlibrc file
247-
with open('matplotlibrc.template') as fd:
248-
template_lines = fd.read().splitlines(True)
249-
backend_line_idx, = [ # Also asserts that there is a single such line.
250-
idx for idx, line in enumerate(template_lines)
251-
if line.startswith('#backend:')]
252-
if setupext.options['backend']:
253-
template_lines[backend_line_idx] = (
254-
'backend: {}'.format(setupext.options['backend']))
255-
with open('lib/matplotlib/mpl-data/matplotlibrc', 'w') as fd:
256-
fd.write(''.join(template_lines))
257-
258278
setup( # Finally, pass this all along to distutils to do the heavy lifting.
259279
name="matplotlib",
260280
version=__version__,

tutorials/introductory/customizing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
# A sample matplotlibrc file
201201
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
202202
#
203-
# .. literalinclude:: ../../../matplotlibrc.template
203+
# .. literalinclude:: ../../../lib/matplotlib/mpl-data/matplotlibrc
204204
#
205205
#
206206
# .. _ggplot: https://ggplot2.tidyverse.org/

0 commit comments

Comments
 (0)