Commit 8dfa5869 authored by Jason R. Coombs's avatar Jason R. Coombs

Use functools.partial and re.sub to construct the substitution function.

parent c8da4c33
import sys import sys
import re
import functools
import distutils.core import distutils.core
import distutils.extension import distutils.extension
...@@ -37,13 +39,10 @@ class Extension(_Extension): ...@@ -37,13 +39,10 @@ class Extension(_Extension):
if have_pyrex(): if have_pyrex():
# the build has Cython, so allow it to compile the .pyx files # the build has Cython, so allow it to compile the .pyx files
return return
def pyx_to_target(source):
lang = self.language or '' lang = self.language or ''
target_ext = '.cpp' if lang.lower() == 'c++' else '.c' target_ext = '.cpp' if lang.lower() == 'c++' else '.c'
if source.endswith('.pyx'): sub = functools.partial(re.sub, '.pyx$', target_ext)
source = source[:-4] + target_ext self.sources = list(map(sub, self.sources))
return source
self.sources = list(map(pyx_to_target, self.sources))
class Library(Extension): class Library(Extension):
"""Just like a regular Extension, but built as a library instead""" """Just like a regular Extension, but built as a library instead"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment