1 | #!/usr/bin/env python |
---|
2 | """ |
---|
3 | A crude script for minimal "testing" of dist eggs (require and import). It may |
---|
4 | not work on all zipped eggs. It may be easiest to just customize this script |
---|
5 | for whatever egg you want to test. |
---|
6 | |
---|
7 | usage: test_dist_egg.py <egg_name> |
---|
8 | """ |
---|
9 | import os, sys, logging, subprocess |
---|
10 | |
---|
11 | try: |
---|
12 | assert sys.argv[1] |
---|
13 | except: |
---|
14 | print __doc__ |
---|
15 | sys.exit( 1 ) |
---|
16 | |
---|
17 | lib = os.path.abspath( os.path.join( os.path.dirname( __file__ ), '..', 'lib' ) ) |
---|
18 | sys.path.insert( 0, lib ) |
---|
19 | |
---|
20 | if sys.argv[1].endswith( '.egg' ): |
---|
21 | |
---|
22 | egg = sys.argv[1] |
---|
23 | egg_name = os.path.basename( egg ).split( '-' )[0] |
---|
24 | sys.path.insert( 0, egg ) |
---|
25 | |
---|
26 | import pkg_resources |
---|
27 | pkg_resources.require( egg_name ) |
---|
28 | provider = pkg_resources.get_provider( egg_name ) |
---|
29 | importables = provider.get_metadata('top_level.txt').splitlines() |
---|
30 | |
---|
31 | for importable in importables: |
---|
32 | mod = __import__( importable ) |
---|
33 | assert os.path.dirname( mod.__path__[0] ) == os.path.dirname( provider.module_path ) |
---|
34 | print "OK" |
---|
35 | |
---|
36 | sys.exit( 0 ) |
---|
37 | |
---|
38 | else: |
---|
39 | |
---|
40 | build_dir = os.path.join( os.path.dirname( os.path.abspath( __file__ ) ), 'scramble', 'build' ) |
---|
41 | if os.path.exists( build_dir ): |
---|
42 | raise Exception( 'Build dir must be removed before testing: %s' % build_dir ) |
---|
43 | |
---|
44 | name = sys.argv[1] |
---|
45 | |
---|
46 | from galaxy.eggs.dist import DistScrambleCrate |
---|
47 | |
---|
48 | c = DistScrambleCrate() |
---|
49 | |
---|
50 | for egg in c[name]: |
---|
51 | print 'Checking %s %s for %s on %s' % ( name, egg.version, egg.platform, egg.build_host ) |
---|
52 | p = subprocess.Popen( 'ssh %s %s %s %s %s' % ( egg.build_host, egg.python, os.path.abspath( __file__ ), egg.distribution.location, egg.platform ), shell=True ) |
---|
53 | p.wait() |
---|