Commit 0d107a8a authored by Stefan Behnel's avatar Stefan Behnel

allow explicitly excluding certain modules from the command line

parent f0aa55e1
...@@ -22,7 +22,7 @@ from Cython.Compiler import Options ...@@ -22,7 +22,7 @@ from Cython.Compiler import Options
Options.error_on_unknown_names = False Options.error_on_unknown_names = False
Options.error_on_uninitialized = False Options.error_on_uninitialized = False
excludes = ['**/test/**/*.py', '**/tests/**/*.py', '**/__init__.py'] exclude_patterns = ['**/test/**/*.py', '**/tests/**/*.py', '**/__init__.py']
broken = [ broken = [
'idlelib/MultiCall.py', 'idlelib/MultiCall.py',
'email/utils.py', 'email/utils.py',
...@@ -79,12 +79,13 @@ special_directives = [ ...@@ -79,12 +79,13 @@ special_directives = [
del special_directives[:] # currently unused del special_directives[:] # currently unused
def build_extensions(includes='**/*.py', def build_extensions(includes='**/*.py',
excludes=excludes+broken, excludes=None,
special_directives=special_directives, special_directives=special_directives,
language_level=sys.version_info[0], language_level=sys.version_info[0],
parallel=None): parallel=None):
if isinstance(includes, str): if isinstance(includes, str):
includes = [includes] includes = [includes]
excludes = list(excludes or ()) + exclude_patterns + broken
all_groups = (special_directives or []) + [(includes, {})] all_groups = (special_directives or []) + [(includes, {})]
extensions = [] extensions = []
...@@ -98,13 +99,14 @@ def build_extensions(includes='**/*.py', ...@@ -98,13 +99,14 @@ def build_extensions(includes='**/*.py',
d.update(directives) d.update(directives)
extensions.extend( extensions.extend(
cythonize(modules, cythonize(
modules,
exclude=exclude_now, exclude=exclude_now,
exclude_failures=True, exclude_failures=True,
language_level=language_level, language_level=language_level,
compiler_directives=d, compiler_directives=d,
nthreads=parallel, nthreads=parallel,
)) ))
return extensions return extensions
...@@ -137,6 +139,9 @@ def parse_args(): ...@@ -137,6 +139,9 @@ def parse_args():
'-j', '--jobs', dest='parallel_jobs', metavar='N', '-j', '--jobs', dest='parallel_jobs', metavar='N',
type=int, default=1, type=int, default=1,
help='run builds in N parallel jobs (default: 1)') help='run builds in N parallel jobs (default: 1)')
parser.add_option(
'-x', '--exclude', dest='excludes', metavar='PATTERN',
action="append", help='exclude modules/packages matching PATTERN')
options, args = parser.parse_args() options, args = parser.parse_args()
if not args: if not args:
args = ['./Lib'] args = ['./Lib']
...@@ -164,7 +169,9 @@ if __name__ == '__main__': ...@@ -164,7 +169,9 @@ if __name__ == '__main__':
print("Not building in parallel") print("Not building in parallel")
parallel_jobs = 0 parallel_jobs = 0
extensions = build_extensions(parallel=parallel_jobs) extensions = build_extensions(
parallel=parallel_jobs,
excludes=options.excludes)
sys_args = ['build_ext', '-i'] sys_args = ['build_ext', '-i']
if pool is not None: if pool is not None:
results = pool.map(_build, [(sys_args, ext) for ext in extensions]) results = pool.map(_build, [(sys_args, ext) for ext in extensions])
......
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