Skip to content

Commit ade496c

Browse files
committed
Auto build pyplot from setup.
1 parent ea3c539 commit ade496c

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

lib/matplotlib/pyplot.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This file is entirely autogenerated by setup.py, and any changes to it will be lost.
2+
# The leading part of this file can be modified in src/pyplot_header.py
3+
# whilst the latter part is generated by boilerplate.py
14
"""
25
Provides a MATLAB-like plotting framework.
36
@@ -2220,6 +2223,10 @@ def spy(Z, precision=0, marker=None, markersize=None, aspect='equal', hold=None,
22202223
sci(ret)
22212224
return ret
22222225

2226+
2227+
################# REMAINING CONTENT GENERATED BY boilerplate.py ##############
2228+
2229+
22232230
# This function was autogenerated by boilerplate.py. Do not edit as
22242231
# changes will be lost
22252232
@autogen_docstring(Axes.acorr)
@@ -2925,7 +2932,7 @@ def step(x, y, *args, **kwargs):
29252932
# This function was autogenerated by boilerplate.py. Do not edit as
29262933
# changes will be lost
29272934
@autogen_docstring(Axes.streamplot)
2928-
def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.10000000000000001, hold=None):
2935+
def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, hold=None):
29292936
ax = gca()
29302937
# allow callers to override the hold state by passing hold=True|False
29312938
washold = ax.ishold()

setup.py

+31
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,37 @@ def add_dateutil():
248248
template = template.replace(" use = 'Agg'", " use = '%s'"%rc['backend'])
249249
open('lib/matplotlib/mpl-data/matplotlib.conf', 'w').write(template)
250250

251+
def build_pyplot():
252+
import StringIO
253+
import os
254+
import sys
255+
256+
pyplot_path = os.path.join('lib', 'matplotlib', 'pyplot.py')
257+
258+
pyplot_orig = file(pyplot_path, 'r').readlines()
259+
260+
# this is the magic line that must exist in pyplot, after which the boilerplate content will be
261+
# appended
262+
bp_marker = '################# REMAINING CONTENT GENERATED BY boilerplate.py ##############\n'
263+
264+
try:
265+
pyplot_orig = pyplot_orig[:pyplot_orig.index(bp_marker)+1]
266+
except IndexError:
267+
raise ValueError('The pyplot.py file *must* have the exact line: %s' % bp_marker)
268+
269+
pyplot = file(pyplot_path, 'w')
270+
pyplot.writelines(pyplot_orig)
271+
pyplot.write('\n\n')
272+
273+
# importing boilerplate prints code. So capture the stdout and put it into the pyplot file.
274+
old_stdout = sys.stdout
275+
sys.stdout = pyplot
276+
import boilerplate
277+
sys.stdout = old_stdout
278+
279+
# Write the matplotlib.pyplot file
280+
build_pyplot()
281+
251282
try: additional_params # has setupegg.py provided
252283
except NameError: additional_params = {}
253284

0 commit comments

Comments
 (0)