details: http://www.bx.psu.edu/hg/galaxy/rev/d8ce43b63ebb changeset: 2922:d8ce43b63ebb user: Nate Coraor <nate@bx.psu.edu> date: Tue Oct 27 11:36:57 2009 -0400 description: A get_platform() monkeypatch for fat versions of python on Mac. Also do more explicit version checking ( >= 2.4, <= 2.5 ) and provide helpful messages if the version is not supported. 6 file(s) affected in this change: lib/galaxy/__init__.py lib/galaxy/eggs/__init__.py scripts/check_python.py scripts/get_python.sh scripts/paster.py setup.sh diffs (189 lines): diff -r 9d0d6a33a435 -r d8ce43b63ebb lib/galaxy/__init__.py --- a/lib/galaxy/__init__.py Mon Oct 26 19:47:27 2009 -0400 +++ b/lib/galaxy/__init__.py Tue Oct 27 11:36:57 2009 -0400 @@ -2,4 +2,29 @@ Galaxy root package -- this is a namespace package. """ -__import__( "pkg_resources" ).declare_namespace( __name__ ) \ No newline at end of file +# Starting somewhere in 2.5.x, Python on Mac became broken - despite being fat, +# the machine portion of the platform is not set to 'fat'. +# +# For more, see: +# +# http://bugs.python.org/setuptools/issue19 +# +import os, sys +from distutils.sysconfig import get_config_vars + +if ( os.uname()[-1] in ( 'i386', 'ppc' ) and sys.platform == 'darwin' and sys.prefix.startswith( '/System' ) ) or \ + ( sys.platform == 'darwin' and get_config_vars().get('UNIVERSALSDK', '').strip() ): + # Has to be before anything imports pkg_resources + def _get_platform_monkeypatch(): + plat = distutils.util._get_platform() + if plat.startswith( 'macosx-' ): + plat = 'macosx-10.3-fat' + return plat + import distutils.util + try: + assert distutils.util._get_platform + except: + distutils.util._get_platform = distutils.util.get_platform + distutils.util.get_platform = _get_platform_monkeypatch + +__import__( "pkg_resources" ).declare_namespace( __name__ ) diff -r 9d0d6a33a435 -r d8ce43b63ebb lib/galaxy/eggs/__init__.py --- a/lib/galaxy/eggs/__init__.py Mon Oct 26 19:47:27 2009 -0400 +++ b/lib/galaxy/eggs/__init__.py Tue Oct 27 11:36:57 2009 -0400 @@ -533,9 +533,9 @@ egg = c.get_for_require( name ) try: if egg is None: - pkg_resources.working_set.require( pkg ) + return pkg_resources.working_set.require( pkg ) else: - pkg_resources.working_set.require( "%s==%s" % ( name, egg.get_vertag() ) ) + return pkg_resources.working_set.require( "%s==%s" % ( name, egg.get_vertag() ) ) except pkg_resources.VersionConflict, e: # there's a conflicting egg on the pythonpath, remove it dist = e.args[0] @@ -551,9 +551,10 @@ del working_set.by_key[dist.key] working_set.entry_keys[entry] = [] sys.path.remove(entry) - require( pkg ) + r = require( pkg ) if location is not None and not location.endswith( '.egg' ): working_set.entries.append( location ) # re-add to the set if it's a dir. + return r except pkg_resources.DistributionNotFound, e: # the initial require itself is the first dep, but it can have # multiple deps, which will be fetched by the require below. @@ -566,7 +567,7 @@ if not egg.have: if not egg.fetch(): raise EggNotFetchable( egg.name ) - require( pkg ) + return require( pkg ) # convenience stuff def get_ucs(): diff -r 9d0d6a33a435 -r d8ce43b63ebb scripts/check_python.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/check_python.py Tue Oct 27 11:36:57 2009 -0400 @@ -0,0 +1,22 @@ +import os, sys + +def check_python(): + try: + assert sys.version_info[:2] >= ( 2, 4 ) and sys.version_info[:2] <= ( 2, 5 ) + except AssertionError: + print >>sys.stderr, "ERROR: Your Python version is:", sys.version.split( ' ', 1 )[0] + print >>sys.stderr, "Galaxy is currently only supported on Python 2.4 and Python 2.5." + if sys.version_info[:2] < ( 2, 4 ): + print >>sys.stderr, "To run Galaxy, please download and install Python 2.5 from http://python.org" + else: + print >>sys.stderr, "To track the progress of Python 2.6 support, please see:" + print >>sys.stderr, " http://bitbucket.org/galaxy/galaxy-central/issue/76/support-python-26" + print >>sys.stderr, "For hints on how to direct Galaxy to use a different python installation, see:" + print >>sys.stderr, " http://bitbucket.org/galaxy/galaxy-central/wiki/GetGalaxy" + raise + +if __name__ == '__main__': + try: + check_python() + except: + sys.exit( 1 ) diff -r 9d0d6a33a435 -r d8ce43b63ebb scripts/get_python.sh --- a/scripts/get_python.sh Mon Oct 26 19:47:27 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -#!/bin/sh -# -# Try to find a usable python -# - -if [ "$GALAXY_PYTHON" != "" ]; then - PYTHONS="$GALAXY_PYTHON" -else - PYTHONS="python python2.4 python2.5" -fi - -found="" -for python in $PYTHONS; do - version=`$python -c 'import sys; print sys.version[:3]' 2>/dev/null` - if [ $? -eq 0 ]; then - case $version in - 2.4|2.5) - found="$python" - break - ;; - esac - fi -done - -if [ "$found" != "" ]; then - GALAXY_PYTHON="$found" -else - - # user manually defined $GALAXY_PYTHON - if [ "$GALAXY_PYTHON" != "" ]; then - - /bin/cat <<EOF -ERROR: \$GALAXY_PYTHON is set, but what it points to is not a suitable -Python interpreter. This version of Galaxy requires either Python 2.4 -or 2.5. Possible solutions: - * Unset \$GALAXY_PYTHON to let Galaxy attempt to find a suitable - Python itself - * Set \$GALAXY_PYTHON to a suitable Python interpreter. -\$GALAXY_PYTHON is currently set to: $GALAXY_PYTHON -EOF - - # couldn't find one in $PATH - else - - /bin/cat <<EOF -ERROR: Unable to find a suitable Python interpreter. This version of -Galaxy requires either Python 2.4 or 2.5. Possible solutions: - * If you have a suitable Python installed outside your \$PATH, modify - your \$PATH to include it. - * If you have a suitable Python installed outside your \$PATH and - don't want to change your \$PATH, set the \$GALAXY_PYTHON environment - variable to the path of your python executable. - * If you don't have a suitable Python installed anywhere, install one. -EOF - - fi - - exit 1 - -fi diff -r 9d0d6a33a435 -r d8ce43b63ebb scripts/paster.py --- a/scripts/paster.py Mon Oct 26 19:47:27 2009 -0400 +++ b/scripts/paster.py Tue Oct 27 11:36:57 2009 -0400 @@ -7,7 +7,12 @@ import os, sys -assert sys.version_info[:2] >= ( 2, 4 ) +# ensure supported version +from check_python import check_python +try: + check_python() +except: + sys.exit( 1 ) new_path = [ os.path.join( os.getcwd(), "lib" ) ] new_path.extend( sys.path[1:] ) # remove scripts/ from the path diff -r 9d0d6a33a435 -r d8ce43b63ebb setup.sh --- a/setup.sh Mon Oct 26 19:47:27 2009 -0400 +++ b/setup.sh Tue Oct 27 11:36:57 2009 -0400 @@ -1,4 +1,7 @@ #!/bin/sh + +python ./scripts/check_python.py +[ $? -ne 0 ] && exit 1 SAMPLES=" datatypes_conf.xml.sample