comparison paint/package.py @ 39:cc25499e9485

note TODO....and cry a little
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 30 Mar 2012 15:46:37 -0700
parents c9d8abb2026f
children 06f21791eba1
comparison
equal deleted inserted replaced
38:c9d8abb2026f 39:cc25499e9485
122 setup_py = os.path.join(directory, 'setup.py') 122 setup_py = os.path.join(directory, 'setup.py')
123 if not os.path.exists(setup_py): 123 if not os.path.exists(setup_py):
124 raise AssertionError("%s does not exist" % setup_py) 124 raise AssertionError("%s does not exist" % setup_py)
125 125
126 # setup the egg info 126 # setup the egg info
127 exception = None
127 try: 128 try:
128 call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=subprocess.PIPE) 129 code = call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=subprocess.PIPE)
129 except BaseException, e: 130 except BaseException, exception:
130 print "Failure to generate egg_info" 131 pass
131 print ' - src: %s' % self.src 132 if code or exception:
132 print ' - directory: %s' % directory 133 message = """Failure to generate egg_info
133 raise 134 - src: %s
135 - directory: %s
136 """ % (self.src, directory)
137 if exception:
138 sys.stderr.write(message)
139 raise exception
140 else:
141 raise Exception(message)
134 142
135 # get the .egg-info directory 143 # get the .egg-info directory
136 egg_info = [i for i in os.listdir(directory) 144 egg_info = [i for i in os.listdir(directory)
137 if i.endswith('.egg-info')] 145 if i.endswith('.egg-info')]
138 assert len(egg_info) == 1, 'Expected one .egg-info directory in %s, got: %s' % (directory, egg_info) 146 assert len(egg_info) == 1, 'Expected one .egg-info directory in %s, got: %s' % (directory, egg_info)
145 153
146 def info(self): 154 def info(self):
147 """return info dictionary for package""" 155 """return info dictionary for package"""
148 # could use pkginfo 156 # could use pkginfo
149 157
150 egg_info = self._egg_info() 158 if self._pkg_info_path:
159 pkg_info = self._pkg_info_path
160 else:
161 try:
162 egg_info = self._egg_info()
163 pkg_info = os.path.join(egg_info, 'PKG-INFO')
164 except BaseException, exception:
165 # try to get the package info from a file
166 raise NotImplementedError("TODO: try to get the package info from a file")
151 167
152 # read the package information 168 # read the package information
153 pkg_info = os.path.join(egg_info, 'PKG-INFO')
154 info_dict = {} 169 info_dict = {}
155 for line in file(pkg_info).readlines(): 170 for line in file(pkg_info).readlines():
156 if not line or line[0].isspace(): 171 if not line or line[0].isspace():
157 continue # XXX neglects description 172 continue # XXX neglects description
158 assert ':' in line 173 assert ':' in line