commit/galaxy-central: james_taylor: Require Python 2.6+ and remove various compatibility patches for 2.4 and 2.5
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/95bf71620d50/ Changeset: 95bf71620d50 User: james_taylor Date: 2013-04-09 17:57:38 Summary: Require Python 2.6+ and remove various compatibility patches for 2.4 and 2.5 Affected #: 20 files diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 eggs.ini --- a/eggs.ini +++ b/eggs.ini @@ -14,7 +14,6 @@ [eggs:platform] bx_python = 0.7.1 Cheetah = 2.2.2 -ctypes = 1.0.2 DRMAA_python = 0.2 MarkupSafe = 0.12 mercurial = 2.2.3 diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/fpconst.py --- a/lib/fpconst.py +++ /dev/null @@ -1,163 +0,0 @@ -"""Utilities for handling IEEE 754 floating point special values - -This python module implements constants and functions for working with -IEEE754 double-precision special values. It provides constants for -Not-a-Number (NaN), Positive Infinity (PosInf), and Negative Infinity -(NegInf), as well as functions to test for these values. - -The code is implemented in pure python by taking advantage of the -'struct' standard module. Care has been taken to generate proper -results on both big-endian and little-endian machines. Some efficiency -could be gained by translating the core routines into C. - -See <http://babbage.cs.qc.edu/courses/cs341/IEEE-754references.html> -for reference material on the IEEE 754 floating point standard. - -Further information on this package is available at -<http://www.analytics.washington.edu/statcomp/projects/rzope/fpconst/>. - -Author: Gregory R. Warnes <gregory_r_warnes@groton.pfizer.com> -Date:: 2003-04-08 -Copyright: (c) 2003, Pfizer, Inc. -""" - -__version__ = "0.7.0" -ident = "$Id: fpconst.py,v 1.12 2004/05/22 04:38:17 warnes Exp $" - -import struct, operator - -# check endianess -_big_endian = struct.pack('i',1)[0] != '\x01' - -# and define appropriate constants -if(_big_endian): - NaN = struct.unpack('d', '\x7F\xF8\x00\x00\x00\x00\x00\x00')[0] - PosInf = struct.unpack('d', '\x7F\xF0\x00\x00\x00\x00\x00\x00')[0] - NegInf = -PosInf -else: - NaN = struct.unpack('d', '\x00\x00\x00\x00\x00\x00\xf8\xff')[0] - PosInf = struct.unpack('d', '\x00\x00\x00\x00\x00\x00\xf0\x7f')[0] - NegInf = -PosInf - -def _double_as_bytes(dval): - "Use struct.unpack to decode a double precision float into eight bytes" - tmp = list(struct.unpack('8B',struct.pack('d', dval))) - if not _big_endian: - tmp.reverse() - return tmp - -## -## Functions to extract components of the IEEE 754 floating point format -## - -def _sign(dval): - "Extract the sign bit from a double-precision floating point value" - bb = _double_as_bytes(dval) - return bb[0] >> 7 & 0x01 - -def _exponent(dval): - """Extract the exponentent bits from a double-precision floating - point value. - - Note that for normalized values, the exponent bits have an offset - of 1023. As a consequence, the actual exponentent is obtained - by subtracting 1023 from the value returned by this function - """ - bb = _double_as_bytes(dval) - return (bb[0] << 4 | bb[1] >> 4) & 0x7ff - -def _mantissa(dval): - """Extract the _mantissa bits from a double-precision floating - point value.""" - - bb = _double_as_bytes(dval) - mantissa = bb[1] & 0x0f << 48 - mantissa += bb[2] << 40 - mantissa += bb[3] << 32 - mantissa += bb[4] - return mantissa - -def _zero_mantissa(dval): - """Determine whether the mantissa bits of the given double are all - zero.""" - bb = _double_as_bytes(dval) - return ((bb[1] & 0x0f) | reduce(operator.or_, bb[2:])) == 0 - -## -## Functions to test for IEEE 754 special values -## - -def isNaN(value): - "Determine if the argument is a IEEE 754 NaN (Not a Number) value." - return (_exponent(value)==0x7ff and not _zero_mantissa(value)) - -def isInf(value): - """Determine if the argument is an infinite IEEE 754 value (positive - or negative inifinity)""" - return (_exponent(value)==0x7ff and _zero_mantissa(value)) - -def isFinite(value): - """Determine if the argument is an finite IEEE 754 value (i.e., is - not NaN, positive or negative inifinity)""" - return (_exponent(value)!=0x7ff) - -def isPosInf(value): - "Determine if the argument is a IEEE 754 positive infinity value" - return (_sign(value)==0 and _exponent(value)==0x7ff and \ - _zero_mantissa(value)) - -def isNegInf(value): - "Determine if the argument is a IEEE 754 negative infinity value" - return (_sign(value)==1 and _exponent(value)==0x7ff and \ - _zero_mantissa(value)) - -## -## Functions to test public functions. -## - -def test_isNaN(): - assert( not isNaN(PosInf) ) - assert( not isNaN(NegInf) ) - assert( isNaN(NaN ) ) - assert( not isNaN( 1.0) ) - assert( not isNaN( -1.0) ) - -def test_isInf(): - assert( isInf(PosInf) ) - assert( isInf(NegInf) ) - assert( not isInf(NaN ) ) - assert( not isInf( 1.0) ) - assert( not isInf( -1.0) ) - -def test_isFinite(): - assert( not isFinite(PosInf) ) - assert( not isFinite(NegInf) ) - assert( not isFinite(NaN ) ) - assert( isFinite( 1.0) ) - assert( isFinite( -1.0) ) - -def test_isPosInf(): - assert( isPosInf(PosInf) ) - assert( not isPosInf(NegInf) ) - assert( not isPosInf(NaN ) ) - assert( not isPosInf( 1.0) ) - assert( not isPosInf( -1.0) ) - -def test_isNegInf(): - assert( not isNegInf(PosInf) ) - assert( isNegInf(NegInf) ) - assert( not isNegInf(NaN ) ) - assert( not isNegInf( 1.0) ) - assert( not isNegInf( -1.0) ) - -# overall test -def test(): - test_isNaN() - test_isInf() - test_isFinite() - test_isPosInf() - test_isNegInf() - -if __name__ == "__main__": - test() - diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/__init__.py --- a/lib/galaxy/__init__.py +++ b/lib/galaxy/__init__.py @@ -95,10 +95,15 @@ pkg_resources.Distribution._insert_on = pkg_resources.Distribution.insert_on pkg_resources.Distribution.insert_on = _insert_on -# patch to add the NullHandler class to logging -if sys.version_info[:2] < ( 2, 7 ): - import logging +# compat: BadZipFile introduced in Python 2.7 +import zipfile +if not hasattr( zipfile, 'BadZipFile' ): + zipfile.BadZipFile = zipfile.error + +# compat: patch to add the NullHandler class to logging +import logging +if not hasattr( logging, 'NullHandler' ): class NullHandler( logging.Handler ): def emit( self, record ): pass - logging.NullHandler = NullHandler + logging.NullHandler = NullHandler \ No newline at end of file diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/datatypes/data.py --- a/lib/galaxy/datatypes/data.py +++ b/lib/galaxy/datatypes/data.py @@ -17,12 +17,6 @@ eggs.require( "Paste" ) import paste - -if sys.version_info[:2] < ( 2, 6 ): - zipfile.BadZipFile = zipfile.error -if sys.version_info[:2] < ( 2, 5 ): - zipfile.LargeZipFile = zipfile.error - log = logging.getLogger(__name__) tmpd = tempfile.mkdtemp() diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/eggs/__init__.py --- a/lib/galaxy/eggs/__init__.py +++ b/lib/galaxy/eggs/__init__.py @@ -387,7 +387,6 @@ "guppy": lambda: self.config.get( "app:main", "use_memdump" ), "python_openid": lambda: self.config.get( "app:main", "enable_openid" ), "python_daemon": lambda: sys.version_info[:2] >= ( 2, 5 ), - "ctypes": lambda: ( "drmaa" in self.config.get( "app:main", "start_job_runners" ).split(",") ) and sys.version_info[:2] == ( 2, 4 ), "pysam": lambda: check_pysam() }.get( egg_name, lambda: True )() except: diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/jobs/deferred/genome_transfer.py --- a/lib/galaxy/jobs/deferred/genome_transfer.py +++ b/lib/galaxy/jobs/deferred/genome_transfer.py @@ -165,28 +165,18 @@ for name in z.namelist(): if name.endswith('/'): continue - if sys.version_info[:2] >= ( 2, 6 ): - zipped_file = z.open( name ) - while 1: - try: - chunk = zipped_file.read( CHUNK_SIZE ) - except IOError: - os.close( fd ) - log.error( 'Problem decompressing zipped data' ) - return self.app.model.DeferredJob.states.INVALID - if not chunk: - break - os.write( fd, chunk ) - zipped_file.close() - else: + zipped_file = z.open( name ) + while 1: try: - outfile = open( fd, 'wb' ) - outfile.write( z.read( name ) ) - outfile.close() + chunk = zipped_file.read( CHUNK_SIZE ) except IOError: os.close( fd ) log.error( 'Problem decompressing zipped data' ) - return + return self.app.model.DeferredJob.states.INVALID + if not chunk: + break + os.write( fd, chunk ) + zipped_file.close() os.close( fd ) z.close() elif data_type == 'fasta': diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/jobs/runners/drmaa.py --- a/lib/galaxy/jobs/runners/drmaa.py +++ b/lib/galaxy/jobs/runners/drmaa.py @@ -15,8 +15,6 @@ from galaxy.jobs import JobDestination from galaxy.jobs.runners import AsynchronousJobState, AsynchronousJobRunner -if sys.version_info[:2] == ( 2, 4 ): - eggs.require( "ctypes" ) eggs.require( "drmaa" ) # We foolishly named this file the same as the name exported by the drmaa # library... 'import drmaa' imports itself. diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/objectstore/__init__.py --- a/lib/galaxy/objectstore/__init__.py +++ b/lib/galaxy/objectstore/__init__.py @@ -21,13 +21,12 @@ from sqlalchemy.orm import object_session -if sys.version_info >= (2, 6): - import multiprocessing - from galaxy.objectstore.s3_multipart_upload import multipart_upload - import boto - from boto.s3.key import Key - from boto.s3.connection import S3Connection - from boto.exception import S3ResponseError +import multiprocessing +from galaxy.objectstore.s3_multipart_upload import multipart_upload +import boto +from boto.s3.key import Key +from boto.s3.connection import S3Connection +from boto.exception import S3ResponseError log = logging.getLogger( __name__ ) logging.getLogger('boto').setLevel(logging.INFO) # Otherwise boto is quite noisy @@ -381,7 +380,6 @@ Galaxy and S3. """ def __init__(self, config): - assert sys.version_info >= (2, 6), 'S3 Object Store support requires Python >= 2.6' super(S3ObjectStore, self).__init__() self.config = config self.staging_path = self.config.file_path diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/objectstore/s3_multipart_upload.py --- a/lib/galaxy/objectstore/s3_multipart_upload.py +++ b/lib/galaxy/objectstore/s3_multipart_upload.py @@ -13,10 +13,8 @@ import contextlib import functools -if sys.version_info >= (2, 6): - # this is just to prevent unit tests from failing - import multiprocessing - from multiprocessing.pool import IMapIterator +import multiprocessing +from multiprocessing.pool import IMapIterator from galaxy import eggs eggs.require('boto') diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -15,6 +15,8 @@ import types import urllib +from math import isinf + from galaxy import eggs eggs.require( "simplejson" ) eggs.require( "MarkupSafe" ) #MarkupSafe must load before mako @@ -46,7 +48,7 @@ from galaxy.tools.parameters.output import ToolOutputActionGroup from galaxy.tools.parameters.validation import LateValidationError from galaxy.tools.test import ToolTestBuilder -from galaxy.util import isinf, listify, parse_xml, rst_to_html, string_as_bool, string_to_object, xml_text, xml_to_string +from galaxy.util import listify, parse_xml, rst_to_html, string_as_bool, string_to_object, xml_text, xml_to_string from galaxy.util.bunch import Bunch from galaxy.util.expressions import ExpressionContext from galaxy.util.hash_util import hmac_new diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/util/__init__.py --- a/lib/galaxy/util/__init__.py +++ b/lib/galaxy/util/__init__.py @@ -5,24 +5,8 @@ import logging, threading, random, string, re, binascii, pickle, time, datetime, math, re, os, sys, tempfile, stat, grp, smtplib, errno, shutil from email.MIMEText import MIMEText -# Older py compatibility -try: - set() -except: - from sets import Set as set - -try: - from hashlib import md5 -except ImportError: - from md5 import new as md5 - -try: - from math import isinf -except ImportError: - INF = float( 'inf' ) - NEG_INF = -INF - ISINF_LIST = [ INF, NEG_INF ] - isinf = lambda x: x in ISINF_LIST +from os.path import relpath +from hashlib import md5 from galaxy import eggs import pkg_resources @@ -543,41 +527,6 @@ print "ERROR: Unable to read builds for site file %s" %filename return build_sites -def relpath( path, start = None ): - """Return a relative version of a path""" - #modified from python 2.6.1 source code - - #version 2.6+ has it built in, we'll use the 'official' copy - if sys.version_info[:2] >= ( 2, 6 ): - if start is not None: - return os.path.relpath( path, start ) - return os.path.relpath( path ) - - #we need to initialize some local parameters - curdir = os.curdir - pardir = os.pardir - sep = os.sep - commonprefix = os.path.commonprefix - join = os.path.join - if start is None: - start = curdir - - #below is the unedited (but formated) relpath() from posixpath.py of 2.6.1 - #this will likely not function properly on non-posix systems, i.e. windows - if not path: - raise ValueError( "no path specified" ) - - start_list = os.path.abspath( start ).split( sep ) - path_list = os.path.abspath( path ).split( sep ) - - # Work out how much of the filepath is shared by start and path. - i = len( commonprefix( [ start_list, path_list ] ) ) - - rel_list = [ pardir ] * ( len( start_list )- i ) + path_list[ i: ] - if not rel_list: - return curdir - return join( *rel_list ) - def relativize_symlinks( path, start=None, followlinks=False): for root, dirs, files in os.walk( path, followlinks=followlinks ): rel_start = None diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/util/pastescript/serve.py --- a/lib/galaxy/util/pastescript/serve.py +++ b/lib/galaxy/util/pastescript/serve.py @@ -101,13 +101,6 @@ # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php -# if sys.version_info >= (2, 6): -# from logging.config import fileConfig -# else: -# # Use our custom fileConfig -- 2.5.1's with a custom Formatter class -# # and less strict whitespace (which were incorporated into 2.6's) -# from paste.script.util.logging_config import fileConfig - class BadCommand(Exception): def __init__(self, message, exit_code=2): diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/visualization/data_providers/genome.py --- a/lib/galaxy/visualization/data_providers/genome.py +++ b/lib/galaxy/visualization/data_providers/genome.py @@ -6,8 +6,6 @@ from math import ceil, log import pkg_resources pkg_resources.require( "bx-python" ) -if sys.version_info[:2] == (2, 4): - pkg_resources.require( "ctypes" ) pkg_resources.require( "pysam" ) pkg_resources.require( "numpy" ) import numpy diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -285,12 +285,7 @@ log.debug( "Enabling 'eval exceptions' middleware" ) else: # Not in interactive debug mode, just use the regular error middleware - if sys.version_info[:2] >= ( 2, 6 ): - warnings.filterwarnings( 'ignore', '.*', DeprecationWarning, '.*serial_number_generator', 11, True ) - import galaxy.web.framework.middleware.error - warnings.filters.pop() - else: - import galaxy.web.framework.middleware.error + import galaxy.web.framework.middleware.error app = galaxy.web.framework.middleware.error.ErrorMiddleware( app, conf ) log.debug( "Enabling 'error' middleware" ) # Transaction logging (apache access.log style) diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/webapps/galaxy/controllers/dataset.py --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -20,11 +20,6 @@ pkg_resources.require( "Paste" ) import paste.httpexceptions -if sys.version_info[:2] < ( 2, 6 ): - zipfile.BadZipFile = zipfile.error -if sys.version_info[:2] < ( 2, 5 ): - zipfile.LargeZipFile = zipfile.error - tmpd = tempfile.mkdtemp() comptypes=[] ziptype = '32' diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/galaxy/webapps/galaxy/controllers/library_common.py --- a/lib/galaxy/webapps/galaxy/controllers/library_common.py +++ b/lib/galaxy/webapps/galaxy/controllers/library_common.py @@ -27,11 +27,6 @@ whoosh_search_enabled = False schema = None -if sys.version_info[:2] < ( 2, 6 ): - zipfile.BadZipFile = zipfile.error -if sys.version_info[:2] < ( 2, 5 ): - zipfile.LargeZipFile = zipfile.error - log = logging.getLogger( __name__ ) # Test for available compression types diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 lib/tool_shed/tool_shed_registry.py --- a/lib/tool_shed/tool_shed_registry.py +++ b/lib/tool_shed/tool_shed_registry.py @@ -4,12 +4,7 @@ log = logging.getLogger( __name__ ) -if sys.version_info[:2] == ( 2, 4 ): - from galaxy import eggs - eggs.require( 'ElementTree' ) - from elementtree import ElementTree -else: - from xml.etree import ElementTree +from xml.etree import ElementTree class Registry( object ): def __init__( self, root_dir=None, config=None ): diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 scripts/check_python.py --- a/scripts/check_python.py +++ b/scripts/check_python.py @@ -1,19 +1,19 @@ """ -If the current installed python version is not 2.5 to 2.7, prints an error +If the current installed python version is not 2.6 to 2.7, prints an error message to stderr and returns 1 """ import os, sys msg = """ERROR: Your Python version is: %s -Galaxy is currently supported on Python 2.5, 2.6 and 2.7. To run Galaxy, +Galaxy is currently supported on Python 2.6 and 2.7. To run Galaxy, please download and install a supported version from python.org. If a supported version is installed but is not your default, getgalaxy.org contains instructions on how to force Galaxy to use a different version.""" % sys.version[:3] def check_python(): try: - assert sys.version_info[:2] >= ( 2, 5 ) and sys.version_info[:2] <= ( 2, 7 ) + assert sys.version_info[:2] >= ( 2, 6 ) and sys.version_info[:2] <= ( 2, 7 ) except AssertionError: print >>sys.stderr, msg raise diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 tools/regVariation/quality_filter.py --- a/tools/regVariation/quality_filter.py +++ b/tools/regVariation/quality_filter.py @@ -24,7 +24,7 @@ from bx.binned_array import BinnedArray, FileBinnedArray from bx.bitset import * from bx.bitset_builders import * -from fpconst import isNaN +from math import isnan from bx.cookbook import doc_optparse from galaxy.tools.exception_handling import * import bx.align.maf diff -r 24c143157b7acad82501bf8655b587034963e4b2 -r 95bf71620d50c6d81248eef2001a7dc156ae1088 tools/stats/aggregate_scores_in_intervals.py --- a/tools/stats/aggregate_scores_in_intervals.py +++ b/tools/stats/aggregate_scores_in_intervals.py @@ -25,7 +25,7 @@ from bx.binned_array import BinnedArray, FileBinnedArray from bx.bitset import * from bx.bitset_builders import * -from fpconst import isNaN +from math import isnan from bx.cookbook import doc_optparse from galaxy.tools.exception_handling import * Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org