Mercurial > hg > PaInt
annotate paint/info.py @ 71:da69d58f960d
stub method of conversion, PackageSet, and some cleanup
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 27 Jan 2013 17:57:38 -0800 |
parents | fea269259222 |
children | 5b10f2c03cb9 |
rev | line source |
---|---|
54
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 """ |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 interfaces to get information from a package |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 """ |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 |
57 | 5 import imp |
54
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 import os |
58
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
7 import subprocess |
54
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 import sys |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 |
71
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
10 from distutils.dist import DistributionMetadata |
57 | 11 from subprocess import check_call as call |
12 | |
61
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
13 # TODO: |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
14 # Reconcile the difference between the keys (and values) between the different |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
15 # implementations. Pick a canon and stick with it. |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
16 |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
17 # SetupOverridePackageInfo: |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
18 # {'entry_points': '\n', 'description': 'a dummy package', 'license': '', 'author': 'Jeff Hammel', 'install_requires': [], 'include_package_data': True, 'classifiers': [], 'url': 'http://example.com/', 'author_email': 'jhammel@mozilla.com', 'version': '0.1', 'zip_safe': False, 'packages': ['dummy'], 'long_description': 'dummy\n===========\n\na dummy package\n\n----\n\nJeff Hammel\n\nhttp://example.com/\n\n', 'name': 'dummy'} |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
19 |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
20 # EggInfo: |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
21 # {'Name': 'dummy', 'License': 'UNKNOWN', 'Author': 'Jeff Hammel', 'Metadata-Version': '1.0', 'Home-page': 'http://example.com/', 'Summary': 'a dummy package', 'Platform': 'UNKNOWN', 'Version': '0.1', 'Author-email': 'jhammel@mozilla.com', 'Description': 'dummy'} |
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
22 |
67 | 23 # see http://www.python.org/dev/peps/pep-0314/ : |
24 # Metadata for Python Software Packages | |
61
1234bfb1f1f0
we really need to pick a canon
Jeff Hammel <jhammel@mozilla.com>
parents:
60
diff
changeset
|
25 |
69
fea269259222
move comment to more appropriate place
Jeff Hammel <jhammel@mozilla.com>
parents:
68
diff
changeset
|
26 |
fea269259222
move comment to more appropriate place
Jeff Hammel <jhammel@mozilla.com>
parents:
68
diff
changeset
|
27 # TODO: consider using pkginfo |
fea269259222
move comment to more appropriate place
Jeff Hammel <jhammel@mozilla.com>
parents:
68
diff
changeset
|
28 |
71
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
29 def setup2metadata(**kwargs): |
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
30 """ |
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
31 convert setup arguments to standard python metadata: |
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
32 http://www.python.org/dev/peps/pep-0314/ |
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
33 """ |
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
34 metadata = DistributionMetadata() |
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
35 raise NotImplementedError("TODO") |
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
36 |
da69d58f960d
stub method of conversion, PackageSet, and some cleanup
Jeff Hammel <jhammel@mozilla.com>
parents:
69
diff
changeset
|
37 |
54
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
38 class PackageInfo(object): |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
39 """abstract base class of package info""" |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
40 def __init__(self, path): |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
41 """ |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
42 - path : path to setup.py or its directory |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
43 """ |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
44 if os.path.isdir(path): |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
45 path = os.path.join(path, 'setup.py') |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
46 assert os.path.exists(path), "'%s' not found" % path |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
47 self.setup_py = os.path.abspath(path) |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
48 |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
49 def __call__(self): |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
50 """returns dictionary of package info""" |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
51 raise NotImplementedError("abstract base class") |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
52 |
68
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
53 def dependencies(self): |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
54 raise NotImplementedError("abstract base class") |
67 | 55 |
54
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
56 class SetupOverridePackageInfo(PackageInfo): |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
57 """ |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
58 gather setup.py information by overriding the function |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
59 """ |
67 | 60 # TODO: override distutils.core.setup as well |
61 # http://docs.python.org/2/distutils/index.html#distutils-index | |
54
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
62 |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
63 def __call__(self): |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
64 setuptools = sys.modules.get('setuptools') |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
65 sys.modules['setuptools'] = sys.modules[__name__] |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
66 globals()['setup'] = self._setup |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
67 try: |
57 | 68 module = imp.load_source('setup', self.setup_py) |
56 | 69 finally: |
70 sys.modules.pop('setuptools') | |
71 if setuptools: | |
72 sys.modules['setuptools'] = setuptools | |
73 globals().pop('setup') | |
54
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
74 return self.__dict__.pop('_info') |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
75 |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
76 def _setup(self, **kwargs): |
a8236b97abd3
separate methods for gathering package information
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
77 self._info = kwargs |
57 | 78 |
67 | 79 |
57 | 80 class EggInfo(PackageInfo): |
81 """ | |
82 use `python setup.py egg_info` to gather package information | |
83 """ | |
84 | |
85 def __call__(self): | |
58
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
86 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
87 info = self.read_pkg_info(self._pkg_info()) |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
88 # TODO: install_requires |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
89 return info |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
90 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
91 @classmethod |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
92 def read_pkg_info(cls, path): |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
93 """reads PKG-INFO and returns a dict""" |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
94 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
95 # read the package information |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
96 info_dict = {} |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
97 for line in file(path).readlines(): |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
98 if not line or line[0].isspace(): |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
99 continue # XXX neglects description |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
100 assert ':' in line |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
101 key, value = [i.strip() for i in line.split(':', 1)] |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
102 info_dict[key] = value |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
103 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
104 # return the information |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
105 return info_dict |
57 | 106 |
68
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
107 def dependencies(self): |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
108 """return the dependencies of the package""" |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
109 |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
110 # TODO: should probably have a more detailed dict: |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
111 # {'mozinfo': {'version': '>= 0.2', |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
112 # 'url': 'http://something.com/'}} |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
113 |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
114 # get the egg_info directory |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
115 egg_info = self._egg_info() |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
116 |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
117 # read the dependencies |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
118 requires = os.path.join(egg_info, 'requires.txt') |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
119 if os.path.exists(requires): |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
120 dependencies = [i.strip() for i in file(requires).readlines() if i.strip()] |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
121 else: |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
122 dependencies = [] |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
123 dependencies = dict([(i, None) for i in dependencies]) |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
124 |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
125 # read the dependency links |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
126 dependency_links = os.path.join(egg_info, 'dependency_links.txt') |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
127 if os.path.exists(dependency_links): |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
128 links = [i.strip() for i in file(dependency_links).readlines() if i.strip()] |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
129 for link in links: |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
130 # XXX pretty ghetto |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
131 assert '#egg=' in link |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
132 url, dep = link.split('#egg=', 1) |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
133 if dep in dependencies: |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
134 dependencies[dep] = link |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
135 |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
136 return dependencies |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
137 |
d001017d5870
migrate this code to the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
67
diff
changeset
|
138 |
57 | 139 def _egg_info(self): |
140 """build the egg_info directory""" | |
141 | |
60 | 142 # cached result |
143 if getattr(self, '_egg_info_path', None): | |
57 | 144 return self._egg_info_path |
145 | |
58
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
146 directory = os.path.dirname(self.setup_py) |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
147 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
148 # setup the egg info |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
149 try: |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
150 call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=subprocess.PIPE) |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
151 except Exception: |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
152 print "Failure to generate egg_info: %s" % self.setup_py |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
153 raise |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
154 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
155 # get the .egg-info directory |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
156 egg_info = [i for i in os.listdir(directory) |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
157 if i.endswith('.egg-info')] |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
158 assert len(egg_info) == 1, 'Expected one .egg-info directory in %s, got: %s' % (directory, egg_info) |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
159 egg_info = os.path.join(directory, egg_info[0]) |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
160 assert os.path.isdir(egg_info), "%s is not a directory" % egg_info |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
161 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
162 # cache it |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
163 self._egg_info_path = egg_info |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
164 return self._egg_info_path |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
165 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
166 def _pkg_info(self): |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
167 """returns path to PKG-INFO file""" |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
168 |
59
acee5e882768
the egg-info tests fail. yay!
Jeff Hammel <jhammel@mozilla.com>
parents:
58
diff
changeset
|
169 if getattr(self, '_pkg_info_path', None): |
58
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
170 # return cached value |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
171 return self._pkg_info_path |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
172 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
173 try: |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
174 egg_info = self._egg_info() |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
175 except Exception, exception: |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
176 # try to get the package info from a file |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
177 path = os.path.dirname(self.setup_py) |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
178 pkg_info = os.path.join(path, 'PKG-INFO') |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
179 if os.path.exists(pkg_info): |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
180 self._pkg_info_path = pkg_info |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
181 return self._pkg_info_path |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
182 raise Exception("Cannot find or generate PKG-INFO") |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
183 |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
184 pkg_info = os.path.join(egg_info, 'PKG-INFO') |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
185 assert os.path.exists(pkg_info) |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
186 self._pkg_info_path = pkg_info |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
187 return self._pkg_info_path |
13767ee2ddf4
start adding an egg_info based information thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
57
diff
changeset
|
188 |