[Python-checkins] distutils2: fixed the writer to handle .pyc files in RECORD

tarek.ziade python-checkins at python.org
Sun Aug 8 11:50:45 CEST 2010


tarek.ziade pushed 753e2c57a71d to distutils2:

http://hg.python.org/distutils2/rev/753e2c57a71d
changeset:   426:753e2c57a71d
user:        Josip Djolonga
date:        Sat Jul 17 14:31:47 2010 +0200
summary:     fixed the writer to handle .pyc files in RECORD
files:       src/distutils2/command/install_dist_info.py

diff --git a/src/distutils2/command/install_dist_info.py b/src/distutils2/command/install_dist_info.py
--- a/src/distutils2/command/install_dist_info.py
+++ b/src/distutils2/command/install_dist_info.py
@@ -97,19 +97,21 @@
                 install = self.get_finalized_command('install')
                 
                 for fpath in install.get_outputs():
-                    if fpath.endswith('.pyc'):
-                        continue
-                        # FIXME, in get_outputs() missing .pyc files exist
-                    size = os.path.getsize(fpath)
-                    fd = open(fpath, 'r')
-                    hash = hashlib.md5()
-                    hash.update(fd.read())
-                    md5sum = hash.hexdigest()
-                    writer.writerow((fpath, md5sum, size))
-                    
+                    if fpath.endswith('.pyc') or fpath.endswith('.pyo'):
+                        # do not put size and md5 hash, as in PEP-376
+                        writer.writerow((fpath, '', ''))
+                    else:
+                        size = os.path.getsize(fpath)
+                        fd = open(fpath, 'r')
+                        hash = hashlib.md5()
+                        hash.update(fd.read())
+                        md5sum = hash.hexdigest()
+                        writer.writerow((fpath, md5sum, size))
+                
+                # add the RECORD file itself
                 writer.writerow((record_path, '', ''))
                 self.outputs.append(record_path)
-                
+
                 f.close()
                 
     def get_outputs(self):

--
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list