| 12 | | With the notable exception that the os_version is excluded when the |
|---|
| 13 | | os_name is Linux. Mac OS X with Universal MacPython (macpython.org) |
|---|
| 14 | | is always python_version-macosx-10.3-fat-ucs2 . |
|---|
| 15 | | |
|---|
| 16 | | Some examples: |
|---|
| 17 | | |
|---|
| 18 | | py2.4-linux-i686-ucs4 (debian, ubuntu 32 bit) |
|---|
| 19 | | py2.4-linux-x86_64-ucs2 (rhel, fedora, centos 64 bit) |
|---|
| 20 | | py2.4-solaris-2.10-sparc-ucs2 (solaris 10 sparc) |
|---|
| 21 | | |
|---|
| 22 | | check_python_ucs.py in this directory will tell you what UCS is correct |
|---|
| 23 | | for your particular python. |
|---|
| 24 | | """ |
|---|
| 25 | | |
|---|
| 26 | | repo = "http://eggs.g2.bx.psu.edu" |
|---|
| 27 | | |
|---|
| 28 | | import os, sys, glob |
|---|
| 29 | | |
|---|
| 30 | | def get_egg_platform(): |
|---|
| 31 | | |
|---|
| 32 | | # platform can be specified as an arg |
|---|
| 33 | | if len(sys.argv) > 1: |
|---|
| 34 | | py = (sys.argv[1].split('-', 1))[0] |
|---|
| 35 | | ucs = (sys.argv[1].rsplit('-', 1))[1] |
|---|
| 36 | | return ( sys.argv[1], ucs, "%s-noarch" % py ) |
|---|
| 37 | | |
|---|
| 38 | | # else figure it out ourselves |
|---|
| 39 | | py = "py%s" % sys.version[0:3] |
|---|
| 40 | | if sys.maxunicode > 65535: |
|---|
| 41 | | ucs = "ucs4" |
|---|
| | 17 | missing_eggs = get_missing_eggs( config_eggs, galaxy_eggs, galaxy_config ) |
|---|
| | 18 | if len( missing_eggs ) != 0: |
|---|
| | 19 | ret = fetch_eggs( config_eggs.repo, missing_eggs ) |
|---|
| | 20 | if ret == []: |
|---|
| | 21 | print "Eggs fetched successfully" |
|---|
| | 22 | sys.exit( 0 ) |
|---|
| 43 | | ucs = "ucs2" |
|---|
| 44 | | |
|---|
| 45 | | from distutils.util import get_platform |
|---|
| 46 | | platform = get_platform() |
|---|
| 47 | | if platform.startswith('darwin-8'): |
|---|
| 48 | | platform = "macosx-10.3-fat" |
|---|
| 49 | | full_platform = "%s-%s-%s" % (py, platform, ucs) |
|---|
| 50 | | |
|---|
| 51 | | return (full_platform, ucs, "%s-noarch" % py) |
|---|
| 52 | | |
|---|
| 53 | | def get_eggs( tar=False ): |
|---|
| 54 | | |
|---|
| 55 | | (platform, ucs, noarch) = get_egg_platform() |
|---|
| 56 | | |
|---|
| 57 | | here = os.path.abspath(os.path.dirname(sys.argv[0])) |
|---|
| 58 | | if tar: |
|---|
| 59 | | eggs = os.path.abspath( "%s/../eggs_dist/%s/eggs" % ( here, platform ) ) |
|---|
| 60 | | else: |
|---|
| 61 | | eggs = os.path.abspath("%s/../eggs" % here) |
|---|
| 62 | | sys.path.append("%s/../lib" % here) |
|---|
| 63 | | sys.path.append("%s/../eggs" % here) # twill is here regardless of what eggs is, above |
|---|
| 64 | | |
|---|
| 65 | | import pkg_resources |
|---|
| 66 | | pkg_resources.require('twill') |
|---|
| 67 | | import twill.commands as tc |
|---|
| 68 | | import twill.errors as te |
|---|
| 69 | | |
|---|
| 70 | | if tar: |
|---|
| 71 | | import tarfile |
|---|
| 72 | | |
|---|
| 73 | | ucseggs = "%s/%s" % ( eggs, ucs.upper() ) |
|---|
| 74 | | |
|---|
| 75 | | platform_url = "%s/%s" % ( repo, platform ) |
|---|
| 76 | | noarch_url = "%s/%s" % ( repo, noarch ) |
|---|
| 77 | | |
|---|
| 78 | | platforms = { platform : ( ucseggs, platform_url ), noarch : ( eggs, noarch_url ) } |
|---|
| 79 | | failed_platforms = [] |
|---|
| 80 | | |
|---|
| 81 | | for plat in platforms: |
|---|
| 82 | | |
|---|
| 83 | | print "fetching eggs for %s" % plat |
|---|
| 84 | | (eggs, url) = platforms[plat] |
|---|
| 85 | | |
|---|
| 86 | | if not os.path.exists( eggs ): |
|---|
| 87 | | try: |
|---|
| 88 | | os.makedirs( eggs ) |
|---|
| 89 | | except Exception, e: |
|---|
| 90 | | print "Egg directory creation failed! (details follow):" |
|---|
| 91 | | print e |
|---|
| 92 | | failed_platforms.append(plat) |
|---|
| 93 | | continue |
|---|
| 94 | | |
|---|
| 95 | | try: |
|---|
| 96 | | tc.go(url) |
|---|
| 97 | | tc.code(200) |
|---|
| 98 | | except te.TwillAssertionError, e: |
|---|
| 99 | | #print "eggs are not available for this platform (twill error follows):" |
|---|
| 100 | | #print e |
|---|
| 101 | | print "eggs are not available for this platform (continuing to fetch additional platforms)" |
|---|
| 102 | | failed_platforms.append(plat) |
|---|
| 103 | | continue |
|---|
| 104 | | |
|---|
| 105 | | for link in tc.get_browser()._browser.links(): |
|---|
| 106 | | if not link.url.endswith('.egg'): |
|---|
| 107 | | continue |
|---|
| 108 | | if os.path.exists("%s/%s" % ( eggs, link.url )): |
|---|
| 109 | | print "Skipping %s, already exists" % link.url |
|---|
| 110 | | continue |
|---|
| 111 | | (pkg, version, rest) = link.url.split('-', 2) |
|---|
| 112 | | for old in glob.glob( "%s/%s-*-%s" % ( eggs, pkg, rest ) ): |
|---|
| 113 | | print "Removing differing version of %s: %s" % ( pkg, old ) |
|---|
| 114 | | try: |
|---|
| 115 | | os.unlink( old ) |
|---|
| 116 | | except Exception, e: |
|---|
| 117 | | print "Removal failed! (details follow):" |
|---|
| 118 | | print e |
|---|
| 119 | | sys.exit(1) |
|---|
| 120 | | print "Fetching", link.url |
|---|
| 121 | | tc.go( "%s/%s" % ( url, link.url ) ) |
|---|
| 122 | | tc.code( 200 ) |
|---|
| 123 | | tc.save_html( "%s/%s" % ( eggs, link.url ) ) |
|---|
| 124 | | |
|---|
| 125 | | if tar: |
|---|
| 126 | | try: |
|---|
| 127 | | tfname = os.path.abspath( "%s/../eggs_dist/%s.tar" % ( here, platform ) ) |
|---|
| 128 | | t = tarfile.open( tfname, 'w' ) |
|---|
| 129 | | os.chdir( "%s/../eggs_dist/%s" % ( here, platform ) ) |
|---|
| 130 | | t.add( "eggs" ) |
|---|
| 131 | | t.close() |
|---|
| 132 | | print "Created egg tarfile:", tfname |
|---|
| 133 | | except Exception, e: |
|---|
| 134 | | print "Unable to create tarfile (details follow)" |
|---|
| 135 | | print e |
|---|
| 136 | | sys.exit(1) |
|---|
| 137 | | |
|---|
| 138 | | print "" |
|---|
| 139 | | print "WARNING: The script was unable to download eggs for these platforms:" |
|---|
| 140 | | print "" |
|---|
| 141 | | print "\n".join(failed_platforms) |
|---|
| 142 | | print "" |
|---|
| 143 | | print "This will probably make Galaxy unusable. Because of the wide range of" |
|---|
| 144 | | print "operating systems and os versions available on which Galaxy will run," |
|---|
| 145 | | print "the Galaxy developers are not always able to provide pre-built eggs." |
|---|
| 146 | | print "For information on building eggs on your own platform, please see the" |
|---|
| 147 | | print "Scramble page on the Galaxy wiki at:" |
|---|
| 148 | | print "" |
|---|
| 149 | | print "http://g2.trac.bx.psu.edu/wiki/Scramble" |
|---|
| 150 | | print "" |
|---|
| 151 | | print "or email galaxy-bugs@bx.psu.edu" |
|---|
| 152 | | print "" |
|---|
| 153 | | |
|---|
| 154 | | if __name__ == "__main__": |
|---|
| 155 | | get_eggs() |
|---|
| | 24 | print "" |
|---|
| | 25 | print 'fetch_eggs.py was unable to download some eggs. You may have success' |
|---|
| | 26 | print '"scrambling" them yourself:' |
|---|
| | 27 | print "" |
|---|
| | 28 | for name in ret: |
|---|
| | 29 | print " ", sys.executable, os.path.join( os.path.dirname( sys.argv[0] ), "scramble.py" ), name |
|---|
| | 30 | print "" |
|---|
| | 31 | sys.exit( 1 ) |
|---|
| | 32 | else: |
|---|
| | 33 | print "All eggs are up to date for this revision of Galaxy" |
|---|
| | 34 | sys.exit( 0 ) |
|---|