comparison stampit/main.py @ 5:3f9fac577d75

this now actually makes some tarballs for you
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 20 Apr 2010 14:51:47 -0700
parents 95b9f262d795
children 6f8f390ab0b4
comparison
equal deleted inserted replaced
4:95b9f262d795 5:3f9fac577d75
26 def format_description(self, description): 26 def format_description(self, description):
27 return description.strip() or '' 27 return description.strip() or ''
28 28
29 def main(args=sys.argv[1:]): 29 def main(args=sys.argv[1:]):
30 30
31 # XXX this is actually a very long way to work around just getting the
32 # tarballs as pip magically does this for you! ::sigh::
33 # not sure of a better/easier way, though
34
31 if 'PYTHONHOME' in os.environ: 35 if 'PYTHONHOME' in os.environ:
32 del os.environ['PYTHONHOME'] # just make sure this is killed 36 del os.environ['PYTHONHOME'] # just make sure this is killed
33 37
34 # parse options 38 # parse options
35 usage = '%prog [options] <package> <platform>' 39 usage = '%prog [options] <package> <platform>'
49 sys.exit(0) 53 sys.exit(0)
50 if not options.name: 54 if not options.name:
51 options.name = '+'.join(args) 55 options.name = '+'.join(args)
52 56
53 # locate virtualenv 57 # locate virtualenv
54 if not options.virtualenv: 58 if options.virtualenv:
59 if not os.path.exists(options.virtualenv):
60 parser.error("'%s', specified by --virtualenv, does not exist")
61 else:
55 options.virtualenv = which('virtualenv') 62 options.virtualenv = which('virtualenv')
56 if not os.path.exist(options.virtualenv):
57 parser.error("'%s', specified by --virtualenv, does not exist")
58 if options.virtualenv is None: 63 if options.virtualenv is None:
59 # TODO: download virtualenv for them 64 # TODO: download virtualenv for them
60 parser.error("virtualenv cannot be found; please install virtualenv or specify its location with --virtualenv") 65 parser.error("virtualenv cannot be found; please install virtualenv or specify its location with --virtualenv")
61 66
62 # create a virtualenv 67 # create a virtualenv
63 if not options.directory: 68 if not options.directory:
64 options.directory = tempfile.mkdtemp(dir=os.getcwd()) 69 options.directory = tempfile.mkdtemp(dir=os.getcwd())
65 call([options.virtualenv, '--no-site-packages', options.directory]) 70 call([options.virtualenv, '--no-site-packages', options.directory])
66 oldpwd = os.getcwd()
67 os.chdir(options.directory)
68 71
69 # install the packages 72 # install the packages
70 bundlename = options.name + '.pybundle' 73 pip = os.path.join(options.directory, 'bin', 'pip')
71 command = [ 'bin/pip', 'bundle', bundlename ] 74 command = [ pip, 'install', '--no-install' ]
72 command.extend(args) 75 command.extend(args)
73 call(command) 76 call(command)
74 command = ['bin/pip', 'install', bundlename ]
75 77
76 # get the versions 78 # make the tarballs
77 79 distdir = os.path.join(options.directory, 'dist')
80 builddir = os.path.join(options.directory, 'build') # virtualenv creates
81 os.mkdir(distdir)
82 python = os.path.join(options.directory, 'bin', 'python')
83 for package in os.listdir(builddir):
84 os.chdir(os.path.join(builddir, package))
85 call([python, 'setup.py', 'sdist', '--dist-dir', distdir])
86 print 'Tarballs are in %s:' % distdir
87 print '\n'.join(os.listdir(distdir))
78 88
79 if __name__ == '__main__': 89 if __name__ == '__main__':
80 main() 90 main()