| 1 | #!/usr/bin/python | 
|---|
| 2 |  | 
|---|
| 3 | from distutils.core import setup | 
|---|
| 4 | from distutils.extension import Extension | 
|---|
| 5 | from Cython.Distutils import build_ext | 
|---|
| 6 | import sys | 
|---|
| 7 | import os | 
|---|
| 8 |  | 
|---|
| 9 | for root in ['/Library/OpenAFS/Tools', | 
|---|
| 10 | '/usr/local', | 
|---|
| 11 | '/usr/afsws', | 
|---|
| 12 | '/usr']: | 
|---|
| 13 | if os.path.exists('%s/include/afs/afs.h' % root): | 
|---|
| 14 | break | 
|---|
| 15 |  | 
|---|
| 16 | include_dirs = [os.path.join(os.path.dirname(__file__), 'afs'), | 
|---|
| 17 | '%s/include' % root] | 
|---|
| 18 | library_dirs = ['%s/lib' % root, | 
|---|
| 19 | '%s/lib/afs' % root] | 
|---|
| 20 | if os.path.exists('%s/lib/libafsauthent_pic.a' % root): | 
|---|
| 21 | suffix = '_pic' | 
|---|
| 22 | else: | 
|---|
| 23 | suffix = '' | 
|---|
| 24 | libraries = ['afsauthent%s' % suffix, 'afsrpc%s' % suffix, 'resolv'] | 
|---|
| 25 | define_macros = [('AFS_PTHREAD_ENV', None)] | 
|---|
| 26 |  | 
|---|
| 27 | def PyAFSExtension(module, *args, **kwargs): | 
|---|
| 28 | kwargs.setdefault('libraries', []).extend(libraries) | 
|---|
| 29 | kwargs.setdefault('include_dirs', []).extend(include_dirs) | 
|---|
| 30 | kwargs.setdefault('library_dirs', []).extend(library_dirs) | 
|---|
| 31 | kwargs.setdefault('define_macros', []).extend(define_macros) | 
|---|
| 32 | return Extension(module, | 
|---|
| 33 | ["%s.pyx" % module.replace('.', '/')], | 
|---|
| 34 | *args, | 
|---|
| 35 | **kwargs) | 
|---|
| 36 |  | 
|---|
| 37 | setup( | 
|---|
| 38 | name="PyAFS", | 
|---|
| 39 | version="0.1.1", | 
|---|
| 40 | description="PyAFS - Python bindings for AFS", | 
|---|
| 41 | author="Evan Broder", | 
|---|
| 42 | author_email="broder@mit.edu", | 
|---|
| 43 | url="http://github.com/ebroder/pyafs/", | 
|---|
| 44 | license="GPL", | 
|---|
| 45 | requires=['Cython'], | 
|---|
| 46 | packages=['afs', 'afs.tests'], | 
|---|
| 47 | ext_modules=[ | 
|---|
| 48 | PyAFSExtension("afs._util"), | 
|---|
| 49 | PyAFSExtension("afs._acl"), | 
|---|
| 50 | PyAFSExtension("afs._fs"), | 
|---|
| 51 | PyAFSExtension("afs._pts", libraries=['krb5']), | 
|---|
| 52 | ], | 
|---|
| 53 | cmdclass= {"build_ext": build_ext} | 
|---|
| 54 | ) | 
|---|