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

Skip to content

Commit 7eb7ec0

Browse files
committed
Merge branch 'master' into unicode_rc
2 parents b300ef3 + 016a4e3 commit 7eb7ec0

7 files changed

Lines changed: 109 additions & 31 deletions

File tree

distribute_setup.py

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
This file can also be run as a script to install or upgrade setuptools.
1515
"""
1616
import os
17+
import shutil
1718
import sys
1819
import time
1920
import fnmatch
2021
import tempfile
2122
import tarfile
23+
import optparse
24+
2225
from distutils import log
2326

2427
try:
@@ -46,7 +49,7 @@ def quote(arg):
4649
args = [quote(arg) for arg in args]
4750
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
4851

49-
DEFAULT_VERSION = "0.6.28"
52+
DEFAULT_VERSION = "0.6.45"
5053
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
5154
SETUPTOOLS_FAKED_VERSION = "0.6c11"
5255

@@ -84,8 +87,11 @@ def _install(tarball, install_args=()):
8487
if not _python_cmd('setup.py', 'install', *install_args):
8588
log.warn('Something went wrong during the installation.')
8689
log.warn('See the error message above.')
90+
# exitcode will be 2
91+
return 2
8792
finally:
8893
os.chdir(old_wd)
94+
shutil.rmtree(tmpdir)
8995

9096

9197
def _build_egg(egg, tarball, to_dir):
@@ -110,6 +116,7 @@ def _build_egg(egg, tarball, to_dir):
110116

111117
finally:
112118
os.chdir(old_wd)
119+
shutil.rmtree(tmpdir)
113120
# returning the result
114121
log.warn(egg)
115122
if not os.path.exists(egg):
@@ -137,6 +144,16 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
137144
try:
138145
try:
139146
import pkg_resources
147+
148+
# Setuptools 0.7b and later is a suitable (and preferable)
149+
# substitute for any Distribute version.
150+
try:
151+
pkg_resources.require("setuptools>=0.7b")
152+
return
153+
except (pkg_resources.DistributionNotFound,
154+
pkg_resources.VersionConflict):
155+
pass
156+
140157
if not hasattr(pkg_resources, '_distribute'):
141158
if not no_fake:
142159
_fake_setuptools()
@@ -232,7 +249,9 @@ def violation(*args):
232249

233250
def _patch_file(path, content):
234251
"""Will backup the file then patch it"""
235-
existing_content = open(path).read()
252+
f = open(path)
253+
existing_content = f.read()
254+
f.close()
236255
if existing_content == content:
237256
# already patched
238257
log.warn('Already patched.')
@@ -250,12 +269,15 @@ def _patch_file(path, content):
250269

251270

252271
def _same_content(path, content):
253-
return open(path).read() == content
272+
f = open(path)
273+
existing_content = f.read()
274+
f.close()
275+
return existing_content == content
254276

255277

256278
def _rename_path(path):
257279
new_name = path + '.OLD.%s' % time.time()
258-
log.warn('Renaming %s into %s', path, new_name)
280+
log.warn('Renaming %s to %s', path, new_name)
259281
os.rename(path, new_name)
260282
return new_name
261283

@@ -273,7 +295,7 @@ def _remove_flat_installation(placeholder):
273295
log.warn('Could not locate setuptools*.egg-info')
274296
return
275297

276-
log.warn('Removing elements out of the way...')
298+
log.warn('Moving elements out of the way...')
277299
pkg_info = os.path.join(placeholder, file)
278300
if os.path.isdir(pkg_info):
279301
patched = _patch_egg_dir(pkg_info)
@@ -314,11 +336,12 @@ def _create_fake_setuptools_pkg_info(placeholder):
314336
log.warn('%s already exists', pkg_info)
315337
return
316338

317-
if not os.access(pkg_info, os.W_OK):
318-
log.warn("Don't have permissions to write %s, skipping", pkg_info)
319-
320339
log.warn('Creating %s', pkg_info)
321-
f = open(pkg_info, 'w')
340+
try:
341+
f = open(pkg_info, 'w')
342+
except EnvironmentError:
343+
log.warn("Don't have permissions to write %s, skipping", pkg_info)
344+
return
322345
try:
323346
f.write(SETUPTOOLS_PKG_INFO)
324347
finally:
@@ -432,16 +455,17 @@ def _fake_setuptools():
432455
res = _patch_egg_dir(setuptools_location)
433456
if not res:
434457
return
435-
log.warn('Patched done.')
458+
log.warn('Patching complete.')
436459
_relaunch()
437460

438461

439462
def _relaunch():
440463
log.warn('Relaunching...')
441464
# we have to relaunch the process
442465
# pip marker to avoid a relaunch bug
443-
_cmd = ['-c', 'install', '--single-version-externally-managed']
444-
if sys.argv[:3] == _cmd:
466+
_cmd1 = ['-c', 'install', '--single-version-externally-managed']
467+
_cmd2 = ['-c', 'install', '--record']
468+
if sys.argv[:3] == _cmd1 or sys.argv[:3] == _cmd2:
445469
sys.argv[0] = 'setup.py'
446470
args = [sys.executable] + sys.argv
447471
sys.exit(subprocess.call(args))
@@ -494,22 +518,39 @@ def sorter(dir1, dir2):
494518
self._dbg(1, "tarfile: %s" % e)
495519

496520

497-
def _build_install_args(argv):
521+
def _build_install_args(options):
522+
"""
523+
Build the arguments to 'python setup.py install' on the distribute package
524+
"""
498525
install_args = []
499-
user_install = '--user' in argv
500-
if user_install and sys.version_info < (2, 6):
501-
log.warn("--user requires Python 2.6 or later")
502-
raise SystemExit(1)
503-
if user_install:
526+
if options.user_install:
527+
if sys.version_info < (2, 6):
528+
log.warn("--user requires Python 2.6 or later")
529+
raise SystemExit(1)
504530
install_args.append('--user')
505531
return install_args
506532

507-
508-
def main(argv, version=DEFAULT_VERSION):
533+
def _parse_args():
534+
"""
535+
Parse the command line for options
536+
"""
537+
parser = optparse.OptionParser()
538+
parser.add_option(
539+
'--user', dest='user_install', action='store_true', default=False,
540+
help='install in user site package (requires Python 2.6 or later)')
541+
parser.add_option(
542+
'--download-base', dest='download_base', metavar="URL",
543+
default=DEFAULT_URL,
544+
help='alternative URL from where to download the distribute package')
545+
options, args = parser.parse_args()
546+
# positional arguments are ignored
547+
return options
548+
549+
def main(version=DEFAULT_VERSION):
509550
"""Install or upgrade setuptools and EasyInstall"""
510-
tarball = download_setuptools()
511-
_install(tarball, _build_install_args(argv))
512-
551+
options = _parse_args()
552+
tarball = download_setuptools(download_base=options.download_base)
553+
return _install(tarball, _build_install_args(options))
513554

514555
if __name__ == '__main__':
515-
main(sys.argv[1:])
556+
sys.exit(main())

doc/_static/mpl.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,3 +566,18 @@ table.docutils td {
566566
width: 30em;
567567
}
568568

569+
figure {
570+
margin: 1em;
571+
display: inline-block;
572+
}
573+
574+
figure img {
575+
margin-left: auto;
576+
margin-right: auto;
577+
}
578+
579+
figcaption {
580+
text-align: center;
581+
}
582+
583+

doc/sphinxext/gen_gallery.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
</h4>"""
4242

4343
link_template = """\
44-
<a href="{link}"><img src="{thumb}" border="0" alt="{basename}"/></a>
44+
<figure>
45+
<a href="{link}"><img src="{thumb}" border="0" alt="{basename}"/></a><br>
46+
<figcaption><a href="{link}">{title}</a></figcaption>
47+
</figure>
4548
"""
4649

4750
toc_template = """\
@@ -122,7 +125,8 @@ def gen_gallery(app, doctree):
122125
link = 'examples/%s/%s.html'%(subdir, basename)
123126
rows.append(link_template.format(link=link,
124127
thumb=thumbfile,
125-
basename=basename))
128+
basename=basename
129+
title=basename))
126130

127131
if len(data) == 0:
128132
warnings.warn("No thumbnails were found in %s" % subdir)

doc/sphinxext/gen_rst.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ def generate_example_rst(app):
121121
rstfile = '%s.rst'%basename
122122
outrstfile = os.path.join(rstdir, rstfile)
123123

124+
# XXX: We might consider putting extra metadata in the example
125+
# files to include a title. If so, this line is where we would add
126+
# this information.
124127
fhsubdirIndex.write(' %s <%s>\n'%(os.path.basename(basename),rstfile))
125128

126129
do_plot = (subdir in example_subdirs

lib/matplotlib/rcsetup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def validate_fonttype(s):
134134
return fonttype
135135

136136

137-
#validate_backend = ValidateInStrings('backend', all_backends, ignorecase=True)
138137
_validate_standard_backends = ValidateInStrings('backend',
139138
all_backends,
140139
ignorecase=True)

lib/matplotlib/tests/test_basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def test_override_builtins():
1616
'__name__',
1717
'__doc__',
1818
'__package__',
19+
'__loader__',
1920
'any',
2021
'all',
2122
'sum'

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,23 @@ class Patch3DCollection(PatchCollection):
293293
'''
294294

295295
def __init__(self, *args, **kwargs):
296+
"""
297+
Create a collection of flat 3D patches with its normal vector
298+
pointed in *zdir* direction, and located at *zs* on the *zdir*
299+
axis. 'zs' can be a scalar or an array-like of the same length as
300+
the number of patches in the collection.
301+
302+
Constructor arguments are the same as for
303+
:class:`~matplotlib.collections.PatchCollection`. In addition,
304+
keywords *zs=0* and *zdir='z'* are available.
305+
306+
"""
307+
zs = kwargs.pop('zs', 0)
308+
zdir = kwargs.pop('zdir', 'z')
296309
PatchCollection.__init__(self, *args, **kwargs)
297310
self._old_draw = lambda x: PatchCollection.draw(self, x)
311+
self.set_3d_properties(zs, zdir)
312+
298313

299314
def set_sort_zpos(self,val):
300315
'''Set the position to use for z-sorting.'''
@@ -306,11 +321,11 @@ def set_3d_properties(self, zs, zdir):
306321
self.update_scalarmappable()
307322
offsets = self.get_offsets()
308323
if len(offsets) > 0:
309-
xs, ys = zip(*self.get_offsets())
324+
xs, ys = zip(*offsets)
310325
else:
311-
xs = [0] * len(zs)
312-
ys = [0] * len(zs)
313-
self._offsets3d = juggle_axes(xs, ys, zs, zdir)
326+
xs = []
327+
ys = []
328+
self._offsets3d = juggle_axes(xs, ys, np.atleast_1d(zs), zdir)
314329
self._facecolor3d = self.get_facecolor()
315330
self._edgecolor3d = self.get_edgecolor()
316331

0 commit comments

Comments
 (0)