Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 144ebcc

Browse files
committed
Replace moddir and incdir by
moddirlist and incdirlist, lists of source and include directories that are searched for modules. This is needed because the Mac modules and include files live in the Mac subtree. In addition (and that's actually what the mod is all about) on OSX we build all the Mac extension modules.
1 parent 64fbb33 commit 144ebcc

1 file changed

Lines changed: 62 additions & 5 deletions

File tree

setup.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ def module_enabled(extlist, modname):
5555
extlist = [ext for ext in extlist if ext.name == modname]
5656
return len(extlist)
5757

58+
def find_module_file(module, dirlist):
59+
"""Find a module in a set of possible folders. If it is not found
60+
return the unadorned filename"""
61+
list = find_file(module, [], dirlist)
62+
if not list:
63+
return module
64+
if len(list) > 1:
65+
self.announce("WARNING: multiple copies of %s found"%module)
66+
return os.path.join(list[0], module)
67+
5868
class PyBuildExt(build_ext):
5969

6070
def build_extensions(self):
@@ -76,16 +86,28 @@ def build_extensions(self):
7686
srcdir, tail = os.path.split(moddir)
7787
srcdir = os.path.normpath(srcdir)
7888
moddir = os.path.normpath(moddir)
89+
90+
moddirlist = [moddir]
91+
incdirlist = ['./Include']
92+
93+
# Platform-dependent module source and include directories
94+
platform = self.get_platform()
95+
if platform == 'darwin1':
96+
# Mac OS X also includes some mac-specific modules
97+
macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules')
98+
moddirlist.append(macmoddir)
99+
incdirlist.append('./Mac/Include')
79100

80101
# Fix up the paths for scripts, too
81102
self.distribution.scripts = [os.path.join(srcdir, filename)
82103
for filename in self.distribution.scripts]
83104

84105
for ext in self.extensions[:]:
85-
ext.sources = [ os.path.join(moddir, filename)
106+
ext.sources = [ find_module_file(filename, moddirlist)
86107
for filename in ext.sources ]
87-
ext.include_dirs.append( '.' ) # to get pyconfig.h
88-
ext.include_dirs.append( os.path.join(srcdir, './Include') )
108+
ext.include_dirs.append( '.' ) # to get config.h
109+
for incdir in incdirlist:
110+
ext.include_dirs.append( os.path.join(srcdir, incdir) )
89111

90112
# If a module has already been built statically,
91113
# don't build it here
@@ -173,7 +195,7 @@ def detect_modules(self):
173195
math_libs = ['m']
174196
if platform in ['Darwin1.2', 'beos']:
175197
math_libs = []
176-
198+
177199
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
178200

179201
#
@@ -516,7 +538,42 @@ def detect_modules(self):
516538
if platform == 'sunos5':
517539
# SunOS specific modules
518540
exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
519-
541+
542+
if platform == 'darwin1':
543+
# Mac OS X specific modules. These are ported over from MacPython
544+
# and still experimental. Some (such as gestalt or icglue) are
545+
# already generally useful, some (the GUI ones) really need to
546+
# be used from a framework.
547+
exts.append( Extension('gestalt', ['gestaltmodule.c']) )
548+
exts.append( Extension('MacOS', ['macosmodule.c']) )
549+
exts.append( Extension('icglue', ['icgluemodule.c']) )
550+
exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c']) )
551+
exts.append( Extension('Nav', ['Nav.c']) )
552+
exts.append( Extension('AE', ['ae/AEmodule.c']) )
553+
exts.append( Extension('App', ['app/Appmodule.c']) )
554+
exts.append( Extension('CF', ['cf/CFmodule.c'],
555+
extra_link_args=['-framework', 'CoreFoundation']) )
556+
exts.append( Extension('Cm', ['cm/Cmmodule.c']) )
557+
exts.append( Extension('Ctl', ['ctl/Ctlmodule.c']) )
558+
exts.append( Extension('Dlg', ['dlg/Dlgmodule.c']) )
559+
exts.append( Extension('Drag', ['drag/Dragmodule.c']) )
560+
exts.append( Extension('Evt', ['evt/Evtmodule.c']) )
561+
exts.append( Extension('Fm', ['fm/Fmmodule.c']) )
562+
exts.append( Extension('Icn', ['icn/Icnmodule.c']) )
563+
exts.append( Extension('List', ['list/Listmodule.c']) )
564+
exts.append( Extension('Menu', ['menu/Menumodule.c']) )
565+
exts.append( Extension('Mlte', ['mlte/Mltemodule.c']) )
566+
exts.append( Extension('Qd', ['qd/Qdmodule.c']) )
567+
exts.append( Extension('Qdoffs', ['qdoffs/Qdoffsmodule.c']) )
568+
exts.append( Extension('Qt', ['qt/Qtmodule.c'],
569+
extra_link_args=['-framework', 'QuickTime']) )
570+
exts.append( Extension('Res', ['res/Resmodule.c'] ) )
571+
## exts.append( Extension('Scrap', ['scrap/Scrapmodule.c']) )
572+
exts.append( Extension('Snd', ['snd/Sndmodule.c']) )
573+
exts.append( Extension('TE', ['te/TEmodule.c']) )
574+
## exts.append( Extension('waste', ['waste/wastemodule.c']) )
575+
exts.append( Extension('Win', ['win/Winmodule.c']) )
576+
520577
self.extensions.extend(exts)
521578

522579
# Call the method for detecting whether _tkinter can be compiled

0 commit comments

Comments
 (0)