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

Skip to content

Commit e653a7d

Browse files
author
Tarek Ziadé
committed
Merged revisions 73354 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r73354 | tarek.ziade | 2009-06-11 11:55:09 +0200 (Thu, 11 Jun 2009) | 1 line pep8-fied cygwinccompiler module ........
1 parent ff54336 commit e653a7d

1 file changed

Lines changed: 29 additions & 63 deletions

File tree

Lib/distutils/cygwinccompiler.py

Lines changed: 29 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ def get_msvcr():
8484
raise ValueError("Unknown MS Compiler version %s " % msc_ver)
8585

8686

87-
class CygwinCCompiler (UnixCCompiler):
88-
87+
class CygwinCCompiler(UnixCCompiler):
88+
""" Handles the Cygwin port of the GNU C compiler to Windows.
89+
"""
8990
compiler_type = 'cygwin'
9091
obj_extension = ".o"
9192
static_lib_extension = ".a"
@@ -94,11 +95,11 @@ class CygwinCCompiler (UnixCCompiler):
9495
shared_lib_format = "%s%s"
9596
exe_extension = ".exe"
9697

97-
def __init__ (self, verbose=0, dry_run=0, force=0):
98+
def __init__(self, verbose=0, dry_run=0, force=0):
9899

99-
UnixCCompiler.__init__ (self, verbose, dry_run, force)
100+
UnixCCompiler.__init__(self, verbose, dry_run, force)
100101

101-
(status, details) = check_config_h()
102+
status, details = check_config_h()
102103
self.debug_print("Python's GCC status: %s (details: %s)" %
103104
(status, details))
104105
if status is not CONFIG_H_OK:
@@ -153,10 +154,8 @@ def __init__ (self, verbose=0, dry_run=0, force=0):
153154
# with MSVC 7.0 or later.
154155
self.dll_libraries = get_msvcr()
155156

156-
# __init__ ()
157-
158-
159157
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
158+
"""Compiles the source by spawing GCC and windres if needed."""
160159
if ext == '.rc' or ext == '.res':
161160
# gcc needs '.res' and '.rc' compiled to object files !!!
162161
try:
@@ -170,21 +169,11 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
170169
except DistutilsExecError as msg:
171170
raise CompileError(msg)
172171

173-
def link (self,
174-
target_desc,
175-
objects,
176-
output_filename,
177-
output_dir=None,
178-
libraries=None,
179-
library_dirs=None,
180-
runtime_library_dirs=None,
181-
export_symbols=None,
182-
debug=0,
183-
extra_preargs=None,
184-
extra_postargs=None,
185-
build_temp=None,
186-
target_lang=None):
187-
172+
def link(self, target_desc, objects, output_filename, output_dir=None,
173+
libraries=None, library_dirs=None, runtime_library_dirs=None,
174+
export_symbols=None, debug=0, extra_preargs=None,
175+
extra_postargs=None, build_temp=None, target_lang=None):
176+
"""Link the objects."""
188177
# use separate copies, so we can modify the lists
189178
extra_preargs = copy.copy(extra_preargs or [])
190179
libraries = copy.copy(libraries or [])
@@ -249,63 +238,44 @@ def link (self,
249238
if not debug:
250239
extra_preargs.append("-s")
251240

252-
UnixCCompiler.link(self,
253-
target_desc,
254-
objects,
255-
output_filename,
256-
output_dir,
257-
libraries,
258-
library_dirs,
241+
UnixCCompiler.link(self, target_desc, objects, output_filename,
242+
output_dir, libraries, library_dirs,
259243
runtime_library_dirs,
260244
None, # export_symbols, we do this in our def-file
261-
debug,
262-
extra_preargs,
263-
extra_postargs,
264-
build_temp,
245+
debug, extra_preargs, extra_postargs, build_temp,
265246
target_lang)
266247

267-
# link ()
268-
269248
# -- Miscellaneous methods -----------------------------------------
270249

271-
# overwrite the one from CCompiler to support rc and res-files
272-
def object_filenames (self,
273-
source_filenames,
274-
strip_dir=0,
275-
output_dir=''):
276-
if output_dir is None: output_dir = ''
250+
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
251+
"""Adds supports for rc and res files."""
252+
if output_dir is None:
253+
output_dir = ''
277254
obj_names = []
278255
for src_name in source_filenames:
279256
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
280-
(base, ext) = os.path.splitext (os.path.normcase(src_name))
257+
base, ext = os.path.splitext(os.path.normcase(src_name))
281258
if ext not in (self.src_extensions + ['.rc','.res']):
282259
raise UnknownFileError("unknown file type '%s' (from '%s')" % \
283260
(ext, src_name))
284261
if strip_dir:
285262
base = os.path.basename (base)
286-
if ext == '.res' or ext == '.rc':
263+
if ext in ('.res', '.rc'):
287264
# these need to be compiled to object files
288-
obj_names.append (os.path.join (output_dir,
289-
base + ext + self.obj_extension))
265+
obj_names.append (os.path.join(output_dir,
266+
base + ext + self.obj_extension))
290267
else:
291-
obj_names.append (os.path.join (output_dir,
292-
base + self.obj_extension))
268+
obj_names.append (os.path.join(output_dir,
269+
base + self.obj_extension))
293270
return obj_names
294271

295-
# object_filenames ()
296-
297-
# class CygwinCCompiler
298-
299-
300272
# the same as cygwin plus some additional parameters
301-
class Mingw32CCompiler (CygwinCCompiler):
302-
273+
class Mingw32CCompiler(CygwinCCompiler):
274+
""" Handles the Mingw32 port of the GNU C compiler to Windows.
275+
"""
303276
compiler_type = 'mingw32'
304277

305-
def __init__ (self,
306-
verbose=0,
307-
dry_run=0,
308-
force=0):
278+
def __init__(self, verbose=0, dry_run=0, force=0):
309279

310280
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
311281

@@ -341,10 +311,6 @@ def __init__ (self,
341311
# with MSVC 7.0 or later.
342312
self.dll_libraries = get_msvcr()
343313

344-
# __init__ ()
345-
346-
# class Mingw32CCompiler
347-
348314
# Because these compilers aren't configured in Python's pyconfig.h file by
349315
# default, we should at least warn the user if he is using a unmodified
350316
# version.

0 commit comments

Comments
 (0)