From 2b880cc89d0ce6845c4bdd072ac518a7ed9baa08 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 23 Dec 2014 10:20:49 -0500 Subject: Use itertools.product to pair each base with each extension. --- setuptools/command/build_ext.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'setuptools/command/build_ext.py') diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py index c85351b4..2651beae 100644 --- a/setuptools/command/build_ext.py +++ b/setuptools/command/build_ext.py @@ -6,6 +6,7 @@ from distutils.errors import DistutilsError from distutils import log import os import sys +import itertools from setuptools.extension import Library @@ -199,15 +200,16 @@ class build_ext(_build_ext): return _build_ext.get_outputs(self) + self.__get_stubs_outputs() def __get_stubs_outputs(self): - outputs = [] fn_exts = ['.py', '.pyc'] if self.get_finalized_command('build_py').optimize: fn_exts.append('.pyo') ns_ext = (ext for ext in self.extensions if ext._needs_stub) - for ext in ns_ext: - base = os.path.join(self.build_lib, *ext._full_name.split('.')) - outputs.extend(base + fnext for fnext in fn_exts) - return outputs + ns_ext_bases = ( + os.path.join(self.build_lib, *ext._full_name.split('.')) + for ext in ns_ext + ) + pairs = itertools.product(ns_ext_bases, fn_exts) + return (base + fnext for base, fnext in pairs) def write_stub(self, output_dir, ext, compile=False): log.info("writing stub loader for %s to %s", ext._full_name, -- cgit v1.2.3