Jack Jansen | 26e6be3 | 2002-11-15 00:13:33 +0000 | [diff] [blame] | 1 | from distutils.core import Extension, setup |
Jack Jansen | 5efbbcd | 2002-11-18 13:48:18 +0000 | [diff] [blame] | 2 | from distutils import sysconfig |
| 3 | import os |
| 4 | |
| 5 | SRCDIR="../.." |
| 6 | |
| 7 | def find_file(filename, std_dirs, paths): |
| 8 | """Searches for the directory where a given file is located, |
| 9 | and returns a possibly-empty list of additional directories, or None |
| 10 | if the file couldn't be found at all. |
| 11 | |
| 12 | 'filename' is the name of a file, such as readline.h or libcrypto.a. |
| 13 | 'std_dirs' is the list of standard system directories; if the |
| 14 | file is found in one of them, no additional directives are needed. |
| 15 | 'paths' is a list of additional locations to check; if the file is |
| 16 | found in one of them, the resulting list will contain the directory. |
| 17 | """ |
| 18 | |
| 19 | # Check the standard locations |
| 20 | for dir in std_dirs: |
| 21 | f = os.path.join(dir, filename) |
| 22 | if os.path.exists(f): return [] |
| 23 | |
| 24 | # Check the additional directories |
| 25 | for dir in paths: |
| 26 | f = os.path.join(dir, filename) |
| 27 | if os.path.exists(f): |
| 28 | return [dir] |
| 29 | |
| 30 | # Not found anywhere |
| 31 | return None |
| 32 | |
| 33 | def find_library_file(compiler, libname, std_dirs, paths): |
| 34 | filename = compiler.library_filename(libname, lib_type='shared') |
| 35 | result = find_file(filename, std_dirs, paths) |
| 36 | if result is not None: return result |
| 37 | |
| 38 | filename = compiler.library_filename(libname, lib_type='static') |
| 39 | result = find_file(filename, std_dirs, paths) |
| 40 | return result |
| 41 | |
| 42 | def waste_Extension(): |
| 43 | waste_incs = find_file("WASTE.h", [], |
| 44 | ['../'*n + 'waste/C_C++ Headers' for n in (0,1,2,3,4)]) |
| 45 | if waste_incs != None: |
| 46 | waste_libs = [os.path.join(os.path.split(waste_incs[0])[0], "Static Libraries")] |
| 47 | srcdir = SRCDIR |
| 48 | return [ Extension('waste', |
| 49 | [os.path.join(srcdir, d) for d in |
| 50 | 'Mac/Modules/waste/wastemodule.c', |
| 51 | 'Mac/Wastemods/WEObjectHandlers.c', |
| 52 | 'Mac/Wastemods/WETabHooks.c', |
| 53 | 'Mac/Wastemods/WETabs.c' |
| 54 | ], |
| 55 | include_dirs = waste_incs + [ |
| 56 | os.path.join(srcdir, 'Mac/Include'), |
| 57 | os.path.join(srcdir, 'Mac/Wastemods') |
| 58 | ], |
| 59 | library_dirs = waste_libs, |
| 60 | libraries = ['WASTE'], |
| 61 | extra_link_args = ['-framework', 'Carbon'], |
| 62 | ) ] |
| 63 | return [] |
Jack Jansen | 26e6be3 | 2002-11-15 00:13:33 +0000 | [diff] [blame] | 64 | |
| 65 | setup(name="MacPython for Jaguar extensions", version="2.2", |
Jack Jansen | 5efbbcd | 2002-11-18 13:48:18 +0000 | [diff] [blame] | 66 | ext_modules=[ |
Jack Jansen | 202355a | 2002-11-29 23:58:51 +0000 | [diff] [blame] | 67 | Extension("OverrideFrom23._AE", |
| 68 | [SRCDIR + "/Mac/Modules/ae/_AEmodule.c"], |
| 69 | include_dirs=[SRCDIR+"/Mac/Include"], |
| 70 | extra_link_args=['-framework', 'Carbon']), |
Jack Jansen | 5efbbcd | 2002-11-18 13:48:18 +0000 | [diff] [blame] | 71 | Extension("OverrideFrom23._Res", |
| 72 | [SRCDIR + "/Mac/Modules/res/_Resmodule.c"], |
| 73 | include_dirs=[SRCDIR+"/Mac/Include"], |
| 74 | extra_link_args=['-framework', 'Carbon']), |
| 75 | Extension('_Help', |
| 76 | [SRCDIR + '/Mac/Modules/help/_Helpmodule.c'], |
| 77 | include_dirs=[SRCDIR+"/Mac/Include"], |
| 78 | extra_link_args=['-framework', 'Carbon']), |
| 79 | Extension('_Scrap', |
| 80 | [SRCDIR + '/Mac/Modules/scrap/_Scrapmodule.c'], |
| 81 | include_dirs=[SRCDIR+"/Mac/Include"], |
| 82 | extra_link_args=['-framework', 'Carbon']), |
| 83 | ] + |
| 84 | waste_Extension() |
| 85 | ) |