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

Skip to content

Commit 34febf5

Browse files
committed
Modified version of part of patch #102409 for Cygwin:
Get platform-specific modules right on Cygwin Getting a string value for the platform has been factored out into get_platform()
1 parent 1ae43c4 commit 34febf5

1 file changed

Lines changed: 27 additions & 15 deletions

File tree

setup.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ def build_extensions(self):
9999

100100
build_ext.build_extensions(self)
101101

102+
def get_platform (self):
103+
# Get value of sys.platform
104+
platform = sys.platform
105+
if platform[:6] =='cygwin':
106+
platform = 'cygwin'
107+
108+
return platform
109+
102110
def detect_modules(self):
103111
# Ensure that /usr/local is always used
104112
if '/usr/local/lib' not in self.compiler.library_dirs:
@@ -113,9 +121,11 @@ def detect_modules(self):
113121
inc_dirs = ['/usr/include'] + self.compiler.include_dirs
114122
exts = []
115123

124+
platform = self.get_platform()
125+
116126
# Check for MacOS X, which doesn't need libm.a at all
117127
math_libs = ['m']
118-
if sys.platform == 'Darwin1.2':
128+
if platform == 'Darwin1.2':
119129
math_libs = []
120130

121131
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
@@ -268,11 +278,12 @@ def detect_modules(self):
268278
# similar functionality (but slower of course) implemented in Python.
269279

270280
# The standard Unix dbm module:
271-
if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
272-
exts.append( Extension('dbm', ['dbmmodule.c'],
273-
libraries = ['ndbm'] ) )
274-
else:
275-
exts.append( Extension('dbm', ['dbmmodule.c']) )
281+
if platform not in ['cygwin']:
282+
if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
283+
exts.append( Extension('dbm', ['dbmmodule.c'],
284+
libraries = ['ndbm'] ) )
285+
else:
286+
exts.append( Extension('dbm', ['dbmmodule.c']) )
276287

277288
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
278289
if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
@@ -321,19 +332,20 @@ def detect_modules(self):
321332

322333

323334
# Unix-only modules
324-
if sys.platform not in ['mac', 'win32']:
335+
if platform not in ['mac', 'win32']:
325336
# Steen Lumholt's termios module
326337
exts.append( Extension('termios', ['termios.c']) )
327338
# Jeremy Hylton's rlimit interface
328-
exts.append( Extension('resource', ['resource.c']) )
339+
if platform not in ['cygwin']:
340+
exts.append( Extension('resource', ['resource.c']) )
329341

330342
if (self.compiler.find_library_file(lib_dirs, 'nsl')):
331343
exts.append( Extension('nis', ['nismodule.c'],
332344
libraries = ['nsl']) )
333345

334346
# Curses support, requring the System V version of curses, often
335347
# provided by the ncurses library.
336-
if sys.platform == 'sunos4':
348+
if platform == 'sunos4':
337349
include_dirs += ['/usr/5include']
338350
lib_dirs += ['/usr/5lib']
339351

@@ -363,7 +375,7 @@ def detect_modules(self):
363375
# The library to link fpectl with is platform specific.
364376
# Choose *one* of the options below for fpectl:
365377

366-
if sys.platform == 'irix5':
378+
if platform == 'irix5':
367379
# For SGI IRIX (tested on 5.3):
368380
exts.append( Extension('fpectl', ['fpectlmodule.c'],
369381
libraries=['fpe']) )
@@ -420,12 +432,11 @@ def detect_modules(self):
420432
libraries = ['expat']) )
421433

422434
# Platform-specific libraries
423-
plat = sys.platform
424-
if plat == 'linux2':
435+
if platform == 'linux2':
425436
# Linux-specific modules
426437
exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
427438

428-
if plat == 'sunos5':
439+
if platform == 'sunos5':
429440
# SunOS specific modules
430441
exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
431442

@@ -484,7 +495,8 @@ def detect_tkinter(self, inc_dirs, lib_dirs):
484495
include_dirs.append(dir)
485496

486497
# Check for various platform-specific directories
487-
if sys.platform == 'sunos5':
498+
platform = self.get_platform()
499+
if platform == 'sunos5':
488500
include_dirs.append('/usr/openwin/include')
489501
added_lib_dirs.append('/usr/openwin/lib')
490502
elif os.path.exists('/usr/X11R6/include'):
@@ -512,7 +524,7 @@ def detect_tkinter(self, inc_dirs, lib_dirs):
512524
libs.append('tk'+version)
513525
libs.append('tcl'+version)
514526

515-
if sys.platform in ['aix3', 'aix4']:
527+
if platform in ['aix3', 'aix4']:
516528
libs.append('ld')
517529

518530
# Finally, link with the X11 libraries

0 commit comments

Comments
 (0)