[Python-checkins] r46790 - sandbox/trunk/setuptools/setuptools/command/build_py.py

phillip.eby python-checkins at python.org
Fri Jun 9 20:24:28 CEST 2006


Author: phillip.eby
Date: Fri Jun  9 20:24:28 2006
New Revision: 46790

Modified:
   sandbox/trunk/setuptools/setuptools/command/build_py.py
Log:
Allow .py files found by the include_package_data option to be 
automatically included.  Remove duplicate data file matches if both 
include_package_data and package_data are used to refer to the same 
files.


Modified: sandbox/trunk/setuptools/setuptools/command/build_py.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/command/build_py.py	(original)
+++ sandbox/trunk/setuptools/setuptools/command/build_py.py	Fri Jun  9 20:24:28 2006
@@ -92,18 +92,18 @@
         self.run_command('egg_info')
         ei_cmd = self.get_finalized_command('egg_info')
         for path in ei_cmd.filelist.files:
-            if path.endswith('.py'):
-                continue
             d,f = os.path.split(assert_relative(path))
             prev = None
+            oldf = f
             while d and d!=prev and d not in src_dirs:
                 prev = d
                 d, df = os.path.split(d)
                 f = os.path.join(df, f)
             if d in src_dirs:
+                if path.endswith('.py') and f==oldf:
+                    continue    # it's a module, not data
                 mf.setdefault(src_dirs[d],[]).append(path)
 
-
     def get_data_files(self): pass  # kludge 2.4 for lazy computation
 
     if sys.version<"2.4":    # Python 2.4 already has this code
@@ -174,7 +174,11 @@
                 )
             )
         bad = dict.fromkeys(bad)
-        return [f for f in files if f not in bad]
+        seen = {}
+        return [
+            f for f in files if f not in bad
+                and f not in seen and seen.setdefault(f,1)  # ditch dupes
+        ]
 
 
 def assert_relative(path):
@@ -190,3 +194,12 @@
 setup.py directory, *never* absolute paths.
 """ % path
     )
+
+
+
+
+
+
+
+
+


More information about the Python-checkins mailing list