[Checkins] SVN: z3c.dependencychecker/trunk/src/z3c/dependencychecker/dependencychecker.py First go at compensating for django-style 'django-something' package names and

Reinout van Rees reinout at vanrees.org
Tue Aug 17 05:21:34 EDT 2010


Log message for revision 115729:
  First go at compensating for django-style 'django-something' package names and
  'django_something' package directories.
  

Changed:
  U   z3c.dependencychecker/trunk/src/z3c/dependencychecker/dependencychecker.py

-=-
Modified: z3c.dependencychecker/trunk/src/z3c/dependencychecker/dependencychecker.py
===================================================================
--- z3c.dependencychecker/trunk/src/z3c/dependencychecker/dependencychecker.py	2010-08-17 08:57:00 UTC (rev 115728)
+++ z3c.dependencychecker/trunk/src/z3c/dependencychecker/dependencychecker.py	2010-08-17 09:21:34 UTC (rev 115729)
@@ -109,11 +109,19 @@
 def existing_requirements():
     """Extract install and test requirements"""
     name = name_from_setup()
+    underscored_name = name.replace('-', '_')
+    egginfo_dir_name = name + '.egg-info'
+    egginfo_underscored_dir_name = underscored_name + '.egg-info'
     # Who on earth made it so earth-shattering impossible to get your hands on
     # the egg info stuff via an api?  We'll do it mostly by hand...
-    egginfo_dir_name = name + '.egg-info'
     if egginfo_dir_name in os.listdir(os.getcwd()):
         egginfo_dir = egginfo_dir_name
+    elif egginfo_underscored_dir_name in os.listdir(os.getcwd()):
+        # Django apps often have a name like 'django-something' and a package
+        # like 'django_something' as django doesn't like namespace packages in
+        # all places.  So we need to check for dashes that became underscores.
+        egginfo_dir = egginfo_underscored_dir_name
+        name = underscored_name
     else:
         egginfo_dir = os.path.join(os.getcwd(), 'src', egginfo_dir_name)
     requires_filename = os.path.join(egginfo_dir, 'requires.txt')



More information about the checkins mailing list