Commits

Alexander Shorin  committed 95cdf49

Make project installable.

  • Participants
  • Parent commits 9082c6d

Comments (0)

Files changed (1)

 import os
 import imp
 try:
-    from setuptools import setup
-    has_setuptools = True
+    from setuptools import setup, find_packages
 except ImportError:
     from distutils.core import setup
-    has_setuptools = False
+    # http://wiki.python.org/moin/Distutils/Cookbook/AutoPackageDiscovery
+    import os
+
+    def is_package(path):
+        return (
+            os.path.isdir(path) and
+            os.path.isfile(os.path.join(path, '__init__.py'))
+        )
+
+    def find_packages(path='.', base=""):
+        """ Find all packages in path """
+        packages = {}
+        for item in os.listdir(path):
+            dir = os.path.join(path, item)
+            if is_package(dir):
+                if base:
+                    module_name = "%(base)s.%(item)s" % vars()
+                else:
+                    module_name = item
+                packages[module_name] = dir
+                packages.update(find_packages(dir, module_name))
+        return packages
 
 
 mod = imp.load_module('version', *imp.find_module('version', ['./hydra/']))
 info['author'] = 'Alexander Shorin'
 info['author_email'] = 'kxepal@gmail.com'
 info['url'] = 'https://bitbucket.org/kxepal/hydra'
-info['py_modules'] = ('hydra',)
+info['packages'] = find_packages()
 
 setup(**info)