Permalink
Browse files

pack: (experimental) added egg-info to pack (see #101)

  • Loading branch information...
1 parent 15d1ded commit f873afc134b55655d0ce84b15ff1d9c77e6a5f3e @rubik committed Aug 13, 2011
Showing with 68 additions and 18 deletions.
  1. +45 −0 docs/_themes/nature2/layout.html
  2. +22 −17 pyg/pack.py
  3. +1 −1 pyg/utils.py
@@ -0,0 +1,45 @@
+{% extends "!layout.html" %}
+
+{%- block extrahead %}
+{{ super() }}
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'XXX account number XXX']);
+ _gaq.push(['_trackPageview']);
+</script>
+{% endblock %}
+
+{% block footer %}
+{{ super() }}
+<div class="footer">This page uses <a href="http://analytics.google.com/">
+Google Analytics</a> to collect statistics. You can disable it by blocking
+the JavaScript coming from www.google-analytics.com.
+{% extends "!layout.html" %}
+
+{%- block extrahead %}
+{{ super() }}
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'XXX account number XXX']);
+ _gaq.push(['_trackPageview']);
+</script>
+{% endblock %}
+
+{% block footer %}
+{{ super() }}
+<div class="footer">This page uses <a href="http://analytics.google.com/">
+Google Analytics</a> to collect statistics. You can disable it by blocking
+the JavaScript coming from www.google-analytics.com.
+<script type="text/javascript">
+ (function() {
+ var ga = document.createElement('script');
+ ga.src = ('https:' == document.location.protocol ?
+ 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ ga.setAttribute('async', 'true');
+ document.documentElement.firstChild.appendChild(ga);
+ })();
+</script>
+</div>
+{% endblock %}
+</div>
+{% endblock %}
View
@@ -136,12 +136,14 @@ def _safe_readlines(self, dist, filename):
except KeyError:
return {}
- def _mk_egg_info(self):
+ def _mk_egg_info(self, egg_info_dir):
## This function returns the EGG-INFO path
logger.info('Generating EGG-INFO...')
with TempDir(dont_remove=True) as tempdir:
egg_info = os.path.join(tempdir, 'EGG-INFO')
- os.mkdir(egg_info)
+ # copy egg-info from egg_info_dir to spec/
+ shutil.copytree(egg_info_dir, os.path.join(egg_info, 'spec'))
+
self._fill_metadata()
for mfile, data in self.EGG_FILES.iteritems():
deps = dict((name, self._safe_readlines(dist, mfile)) for name, dist in self.bundled.iteritems())
@@ -183,8 +185,10 @@ def _mk_egg_info(self):
if '/' in mfile:
# Make it platform-indipendent
parts = mfile.split('/')
- mfile = os.path.join(*mfile.split('/'))
- os.makedirs(os.path.join(egg_info, *parts[:-1]))
+ mfile = os.path.join(*parts)
+ path = os.path.join(egg_info, *parts[:-1])
+ if not os.path.exists(path):
+ os.makedirs(path)
with open(os.path.join(egg_info, mfile), 'w') as f:
# FIXME: this is a bit ugly
if mfile == 'entry_points.txt':
@@ -200,12 +204,12 @@ def _mk_egg_info(self):
self.entry_points[cmd] = code
f.write(content)
- # this is for Bundler._add_to_archive: it needs the temporary
- # directory length
- tempdir_len = len(tempdir)
+ # this is for Bundler._add_to_archive: it needs the temporary
+ # directory length
+ tempdir_len = len(tempdir)
return egg_info, tempdir_len
- def _gen_eggs(self, source_dir, egg_dir):
+ def _gen_eggs(self, source_dir, egg_dir, egg_info_dir):
## Old method
r = re.compile(r'-py\d\.\d')
def sep_egg_info(arch_path):
@@ -234,11 +238,10 @@ def no_egg_info(arch_path):
no_egg_info(arch)
os.remove(arch)
logger.info('\rGenerating eggs... [{0} - {1:.1%}]', dist, i / dist_no, addn=False)
+ # copy metadata file to egg_info_dir location
+ shutil.move(os.path.join(egg_dir, 'EGG-INFO'), os.path.join(egg_info_dir, dist))
# complete the progress
logger.info('\rGenerating eggs... 100%')
- # Comment out this line if you want to use old method (see above)
- # You should use the new one, though
- shutil.rmtree(os.path.join(egg_dir, 'EGG-INFO'))
def gen_pack(self, exclude=[], use_develop=False):
# This is where to download all packages
@@ -259,12 +262,14 @@ def gen_pack(self, exclude=[], use_develop=False):
with ZipFile(bundle, mode='w') as egg:
# Create a new directory to store unpacked eggs
with TempDir() as egg_dir:
- # generate eggs (through distributions' setups)
- self._gen_eggs(tempdir, egg_dir)
- b._add_to_archive(egg, egg_dir, len(egg_dir))
- # generate egg-info (merging)
- egg_info, tl = self._mk_egg_info()
- b._add_to_archive(egg, egg_info, tl)
+ # where to store egg-info
+ with TempDir() as egg_info_dir:
+ # generate eggs (through distributions' setups)
+ self._gen_eggs(tempdir, egg_dir, egg_info_dir)
+ b._add_to_archive(egg, egg_dir, len(egg_dir))
+ # generate egg-info (merging)
+ egg_info, tl = self._mk_egg_info(egg_info_dir)
+ b._add_to_archive(egg, egg_info, tl)
pack = os.path.join(tempdir, self.pack_name)
eggname = self.req.name + '.egg'
View
@@ -294,7 +294,7 @@ def __exit__(self, *args):
shutil.rmtree(self.tempdir)
## Experimental (remember to remove before releasing)
except Exception as e:
- print 'Ahah: ', e
+ logger.verbose('Error: cannot remove temporary directory {0}: {1}', self.tempdir, e)
@staticmethod
@atexit.register

0 comments on commit f873afc

Please sign in to comment.