Rename afs.afs to afs._util so that absolute imports from afs work.
[invirt/packages/python-afs.git] / setup.py
index b685eac..47cf789 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -1,8 +1,8 @@
 #!/usr/bin/python
 
 #!/usr/bin/python
 
-from setuptools import setup, find_packages
+from distutils.core import setup
 from distutils.extension import Extension
 from distutils.extension import Extension
-from Pyrex.Distutils import build_ext
+from Cython.Distutils import build_ext
 import sys
 import os
 
 import sys
 import os
 
@@ -17,8 +17,22 @@ include_dirs = [os.path.join(os.path.dirname(__file__), 'afs'),
                 '%s/include' % root]
 library_dirs = ['%s/lib' % root,
                 '%s/lib/afs' % root]
                 '%s/include' % root]
 library_dirs = ['%s/lib' % root,
                 '%s/lib/afs' % root]
-libraries = ['bos', 'volser', 'vldb', 'afsrpc', 'afsauthent', 'cmd',
-             'usd', 'audit', 'resolv', 'com_err']
+if os.path.exists('%s/lib/libafsauthent_pic.a' % root):
+    suffix = '_pic'
+else:
+    suffix = ''
+libraries = ['afsauthent%s' % suffix, 'afsrpc%s' % suffix, 'resolv']
+define_macros = [('AFS_PTHREAD_ENV', None)]
+
+def PyAFSExtension(module, *args, **kwargs):
+    kwargs.setdefault('libraries', []).extend(libraries)
+    kwargs.setdefault('include_dirs', []).extend(include_dirs)
+    kwargs.setdefault('library_dirs', []).extend(library_dirs)
+    kwargs.setdefault('define_macros', []).extend(define_macros)
+    return Extension(module,
+                     ["%s.pyx" % module.replace('.', '/')],
+                     *args,
+                     **kwargs)
 
 setup(
     name="PyAFS",
 
 setup(
     name="PyAFS",
@@ -27,14 +41,13 @@ setup(
     author="Evan Broder",
     author_email="broder@mit.edu",
     license="GPL",
     author="Evan Broder",
     author_email="broder@mit.edu",
     license="GPL",
-    requires=['Pyrex'],
-    packages=find_packages(),
+    requires=['Cython'],
+    packages=['afs', 'afs.tests'],
     ext_modules=[
     ext_modules=[
-        Extension("afs._pts",
-                  ["afs/_pts.pyx"],
-                  libraries=libraries,
-                  include_dirs=include_dirs,
-                  library_dirs=library_dirs)
+        PyAFSExtension("afs._util"),
+        PyAFSExtension("afs._acl"),
+        PyAFSExtension("afs._fs"),
+        PyAFSExtension("afs._pts", libraries=['krb5']),
         ],
     cmdclass= {"build_ext": build_ext}
 )
         ],
     cmdclass= {"build_ext": build_ext}
 )