[yt-svn] commit/yt: 5 new changesets
Bitbucket
commits-noreply at bitbucket.org
Mon Dec 17 20:14:13 PST 2012
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/49af63635f3f/
changeset: 49af63635f3f
branch: yt
user: ngoldbaum
date: 2012-12-17 19:12:35
summary: Adding tests for direct png, ps, eps, and pdf plot window plots.
affected #: 1 file
diff -r 0a3348004c948192e81cd6d8972c9172bcc14b9c -r 49af63635f3ff304a7f9b256f3d5d69733a8a66e yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -8,21 +8,36 @@
ytcfg["yt","__withintesting"] = "True"
def teardown_func(fns):
- for fn in fns:
+ for fn in np.unique(fns):
os.remove(fn)
+def assert_fn(fn, fns):
+ if fn is not None:
+ print fn, fns[-1]
+ assert fn == fns[-1]
+
def test_plotwindow():
pf = fake_random_pf(64)
fns = []
- for dim in [0,1,2]:
- slc = SlicePlot(pf, dim, 'Density')
- fns.append(slc.save()[0])
- prj = ProjectionPlot(pf, dim, 'Density')
- fns.append(prj.save()[0])
- normal = [1,1,1]
- oaslc = OffAxisSlicePlot(pf, normal, 'Density')
- fns.append(oaslc.save()[0])
- oaprj = OffAxisProjectionPlot(pf, normal, 'Density')
- fns.append(oaprj.save()[0])
+ test_flnms = [None, 'test.png', 'test.eps',
+ 'test.ps', 'test.pdf']
+ for fn in test_flnms:
+ for dim in [0,1,2]:
+ slc = SlicePlot(pf, dim, 'Density')
+ fns.append(slc.save(fn)[0])
+ assert_fn(fn, fns)
+
+ prj = ProjectionPlot(pf, dim, 'Density')
+ fns.append(prj.save(fn)[0])
+ assert_fn(fn, fns)
+ normal = [1,1,1]
+ oaslc = OffAxisSlicePlot(pf, normal, 'Density')
+ fns.append(oaslc.save(fn)[0])
+ assert_fn(fn,fns)
+
+ oaprj = OffAxisProjectionPlot(pf, normal, 'Density')
+ fns.append(oaprj.save(fn)[0])
+ assert_fn(fn, fns)
+
teardown_func(fns)
https://bitbucket.org/yt_analysis/yt/changeset/493b1519bdf5/
changeset: 493b1519bdf5
branch: yt
user: ngoldbaum
date: 2012-12-17 19:21:37
summary: Accidentally left a debug print statement in.
affected #: 1 file
diff -r 49af63635f3ff304a7f9b256f3d5d69733a8a66e -r 493b1519bdf542e93778a19831bfe131f361ca63 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -13,7 +13,6 @@
def assert_fn(fn, fns):
if fn is not None:
- print fn, fns[-1]
assert fn == fns[-1]
def test_plotwindow():
https://bitbucket.org/yt_analysis/yt/changeset/eddc0df3623c/
changeset: eddc0df3623c
branch: yt
user: ngoldbaum
date: 2012-12-17 23:07:25
summary: Directly checking the MIME type for files saved to disk.
affected #: 2 files
diff -r 493b1519bdf542e93778a19831bfe131f361ca63 -r eddc0df3623c99d6a12405cf9e982dda03834087 doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -757,6 +757,12 @@
${DEST_DIR}/bin/pip install readline 1>> ${LOG_FILE}
fi
+if !(${DEST_DIR}/bin/python2.7 -c "import magic" >> ${LOG_FILE})
+then
+ echo "Installing python-magic"
+ ${DEST_DIR}/bin/pip install python-magic 1>> ${LOG_FILE}
+fi
+
if [ $INST_ENZO -eq 1 ]
then
echo "Cloning a copy of Enzo."
diff -r 493b1519bdf542e93778a19831bfe131f361ca63 -r eddc0df3623c99d6a12405cf9e982dda03834087 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -11,9 +11,23 @@
for fn in np.unique(fns):
os.remove(fn)
-def assert_fn(fn, fns):
- if fn is not None:
- assert fn == fns[-1]
+ext_to_mime = {'.ps' : 'application/postscript',
+ '.eps' : 'application/postscript',
+ '.pdf' : 'application/pdf',
+ '.png' : 'image/png' }
+
+def assert_fn(fn):
+ if fn is None:
+ return
+ try:
+ import magic
+ ext = os.path.splitext(fn)[1]
+ magic_text = magic.from_file(fn,mime=True)
+ print fn, magic_text, ext_to_mime[ext]
+ assert magic_text == ext_to_mime[ext]
+ except ImportError:
+ # OS X doesn't come with libmagic
+ pass
def test_plotwindow():
pf = fake_random_pf(64)
@@ -24,19 +38,21 @@
for dim in [0,1,2]:
slc = SlicePlot(pf, dim, 'Density')
fns.append(slc.save(fn)[0])
- assert_fn(fn, fns)
+ assert_fn(fn)
prj = ProjectionPlot(pf, dim, 'Density')
fns.append(prj.save(fn)[0])
- assert_fn(fn, fns)
+ assert_fn(fn)
+
normal = [1,1,1]
+
oaslc = OffAxisSlicePlot(pf, normal, 'Density')
fns.append(oaslc.save(fn)[0])
- assert_fn(fn,fns)
+ assert_fn(fn)
oaprj = OffAxisProjectionPlot(pf, normal, 'Density')
fns.append(oaprj.save(fn)[0])
- assert_fn(fn, fns)
+ assert_fn(fn)
teardown_func(fns)
https://bitbucket.org/yt_analysis/yt/changeset/fe27fd50bb50/
changeset: fe27fd50bb50
branch: yt
user: ngoldbaum
date: 2012-12-17 23:08:03
summary: Upgrading to the latest version of the distribute setup script.
affected #: 1 file
diff -r eddc0df3623c99d6a12405cf9e982dda03834087 -r fe27fd50bb500a6eb8f08f39ce108ee5a2f9198c distribute_setup.py
--- a/distribute_setup.py
+++ b/distribute_setup.py
@@ -14,11 +14,14 @@
This file can also be run as a script to install or upgrade setuptools.
"""
import os
+import shutil
import sys
import time
import fnmatch
import tempfile
import tarfile
+import optparse
+
from distutils import log
try:
@@ -46,7 +49,7 @@
args = [quote(arg) for arg in args]
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
-DEFAULT_VERSION = "0.6.21"
+DEFAULT_VERSION = "0.6.32"
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
SETUPTOOLS_FAKED_VERSION = "0.6c11"
@@ -63,7 +66,7 @@
""" % SETUPTOOLS_FAKED_VERSION
-def _install(tarball):
+def _install(tarball, install_args=()):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
log.warn('Extracting in %s', tmpdir)
@@ -81,11 +84,14 @@
# installing
log.warn('Installing Distribute')
- if not _python_cmd('setup.py', 'install'):
+ if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.')
log.warn('See the error message above.')
+ # exitcode will be 2
+ return 2
finally:
os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
def _build_egg(egg, tarball, to_dir):
@@ -110,6 +116,7 @@
finally:
os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
# returning the result
log.warn(egg)
if not os.path.exists(egg):
@@ -144,7 +151,7 @@
except ImportError:
return _do_download(version, download_base, to_dir, download_delay)
try:
- pkg_resources.require("distribute>="+version)
+ pkg_resources.require("distribute>=" + version)
return
except pkg_resources.VersionConflict:
e = sys.exc_info()[1]
@@ -167,6 +174,7 @@
if not no_fake:
_create_fake_setuptools_pkg_info(to_dir)
+
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15):
"""Download distribute from a specified location and return its filename
@@ -203,6 +211,7 @@
dst.close()
return os.path.realpath(saveto)
+
def _no_sandbox(function):
def __no_sandbox(*args, **kw):
try:
@@ -227,6 +236,7 @@
return __no_sandbox
+
def _patch_file(path, content):
"""Will backup the file then patch it"""
existing_content = open(path).read()
@@ -245,15 +255,18 @@
_patch_file = _no_sandbox(_patch_file)
+
def _same_content(path, content):
return open(path).read() == content
+
def _rename_path(path):
new_name = path + '.OLD.%s' % time.time()
- log.warn('Renaming %s into %s', path, new_name)
+ log.warn('Renaming %s to %s', path, new_name)
os.rename(path, new_name)
return new_name
+
def _remove_flat_installation(placeholder):
if not os.path.isdir(placeholder):
log.warn('Unkown installation at %s', placeholder)
@@ -267,7 +280,7 @@
log.warn('Could not locate setuptools*.egg-info')
return
- log.warn('Removing elements out of the way...')
+ log.warn('Moving elements out of the way...')
pkg_info = os.path.join(placeholder, file)
if os.path.isdir(pkg_info):
patched = _patch_egg_dir(pkg_info)
@@ -289,11 +302,13 @@
_remove_flat_installation = _no_sandbox(_remove_flat_installation)
+
def _after_install(dist):
log.warn('After install bootstrap.')
placeholder = dist.get_command_obj('install').install_purelib
_create_fake_setuptools_pkg_info(placeholder)
+
def _create_fake_setuptools_pkg_info(placeholder):
if not placeholder or not os.path.exists(placeholder):
log.warn('Could not find the install location')
@@ -307,7 +322,11 @@
return
log.warn('Creating %s', pkg_info)
- f = open(pkg_info, 'w')
+ try:
+ f = open(pkg_info, 'w')
+ except EnvironmentError:
+ log.warn("Don't have permissions to write %s, skipping", pkg_info)
+ return
try:
f.write(SETUPTOOLS_PKG_INFO)
finally:
@@ -321,7 +340,10 @@
finally:
f.close()
-_create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info)
+_create_fake_setuptools_pkg_info = _no_sandbox(
+ _create_fake_setuptools_pkg_info
+)
+
def _patch_egg_dir(path):
# let's check if it's already patched
@@ -343,6 +365,7 @@
_patch_egg_dir = _no_sandbox(_patch_egg_dir)
+
def _before_install():
log.warn('Before install bootstrap.')
_fake_setuptools()
@@ -351,7 +374,7 @@
def _under_prefix(location):
if 'install' not in sys.argv:
return True
- args = sys.argv[sys.argv.index('install')+1:]
+ args = sys.argv[sys.argv.index('install') + 1:]
for index, arg in enumerate(args):
for option in ('--root', '--prefix'):
if arg.startswith('%s=' % option):
@@ -359,7 +382,7 @@
return location.startswith(top_dir)
elif arg == option:
if len(args) > index:
- top_dir = args[index+1]
+ top_dir = args[index + 1]
return location.startswith(top_dir)
if arg == '--user' and USER_SITE is not None:
return location.startswith(USER_SITE)
@@ -376,11 +399,14 @@
return
ws = pkg_resources.working_set
try:
- setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools',
- replacement=False))
+ setuptools_dist = ws.find(
+ pkg_resources.Requirement.parse('setuptools', replacement=False)
+ )
except TypeError:
# old distribute API
- setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools'))
+ setuptools_dist = ws.find(
+ pkg_resources.Requirement.parse('setuptools')
+ )
if setuptools_dist is None:
log.warn('No setuptools distribution found')
@@ -414,7 +440,7 @@
res = _patch_egg_dir(setuptools_location)
if not res:
return
- log.warn('Patched done.')
+ log.warn('Patching complete.')
_relaunch()
@@ -422,7 +448,9 @@
log.warn('Relaunching...')
# we have to relaunch the process
# pip marker to avoid a relaunch bug
- if sys.argv[:3] == ['-c', 'install', '--single-version-externally-managed']:
+ _cmd1 = ['-c', 'install', '--single-version-externally-managed']
+ _cmd2 = ['-c', 'install', '--record']
+ if sys.argv[:3] == _cmd1 or sys.argv[:3] == _cmd2:
sys.argv[0] = 'setup.py'
args = [sys.executable] + sys.argv
sys.exit(subprocess.call(args))
@@ -448,7 +476,7 @@
# Extract directories with a safe mode.
directories.append(tarinfo)
tarinfo = copy.copy(tarinfo)
- tarinfo.mode = 448 # decimal for oct 0700
+ tarinfo.mode = 448 # decimal for oct 0700
self.extract(tarinfo, path)
# Reverse sort directories.
@@ -475,11 +503,39 @@
self._dbg(1, "tarfile: %s" % e)
-def main(argv, version=DEFAULT_VERSION):
+def _build_install_args(options):
+ """
+ Build the arguments to 'python setup.py install' on the distribute package
+ """
+ install_args = []
+ if options.user_install:
+ if sys.version_info < (2, 6):
+ log.warn("--user requires Python 2.6 or later")
+ raise SystemExit(1)
+ install_args.append('--user')
+ return install_args
+
+def _parse_args():
+ """
+ Parse the command line for options
+ """
+ parser = optparse.OptionParser()
+ parser.add_option(
+ '--user', dest='user_install', action='store_true', default=False,
+ help='install in user site package (requires Python 2.6 or later)')
+ parser.add_option(
+ '--download-base', dest='download_base', metavar="URL",
+ default=DEFAULT_URL,
+ help='alternative URL from where to download the distribute package')
+ options, args = parser.parse_args()
+ # positional arguments are ignored
+ return options
+
+def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
- tarball = download_setuptools()
- _install(tarball)
-
+ options = _parse_args()
+ tarball = download_setuptools(download_base=options.download_base)
+ return _install(tarball, _build_install_args(options))
if __name__ == '__main__':
- main(sys.argv[1:])
+ sys.exit(main())
https://bitbucket.org/yt_analysis/yt/changeset/ccd2b8a816a1/
changeset: ccd2b8a816a1
branch: yt
user: ngoldbaum
date: 2012-12-17 23:37:32
summary: Removing python-magic from the install script.
affected #: 1 file
diff -r fe27fd50bb500a6eb8f08f39ce108ee5a2f9198c -r ccd2b8a816a109272d884e8cfbee0a5dfd1761ab doc/install_script.sh
--- a/doc/install_script.sh
+++ b/doc/install_script.sh
@@ -757,12 +757,6 @@
${DEST_DIR}/bin/pip install readline 1>> ${LOG_FILE}
fi
-if !(${DEST_DIR}/bin/python2.7 -c "import magic" >> ${LOG_FILE})
-then
- echo "Installing python-magic"
- ${DEST_DIR}/bin/pip install python-magic 1>> ${LOG_FILE}
-fi
-
if [ $INST_ENZO -eq 1 ]
then
echo "Cloning a copy of Enzo."
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list