Commit cca060c2 authored by PJ Eby's avatar PJ Eby

Ensure installed stubs get compiled, even if there are no "pure" modules

present.  Also, don't bother compiling the stub prior to installation.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042037
parent 40c0f5e6
......@@ -67,7 +67,7 @@ class build_ext(_build_ext):
dry_run=self.dry_run
)
if ext._needs_stub:
self.write_stub(package_dir, ext, False)
self.write_stub(package_dir or os.curdir, ext)
if _build_ext is not _du_build_ext:
......@@ -101,7 +101,7 @@ class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
self.extensions = self.extensions or []
self.check_extensions_list()
self.check_extensions_list(self.extensions)
self.shlibs = [ext for ext in self.extensions
if isinstance(ext,Library)]
if self.shlibs:
......@@ -169,12 +169,14 @@ class build_ext(_build_ext):
self.compiler = self.shlib_compiler
_build_ext.build_extension(self,ext)
if ext._needs_stub:
self.write_stub(self.build_lib, ext)
self.write_stub(
self.get_finalized_command('build_py').build_lib, ext
)
finally:
self.compiler = _compiler
def write_stub(self, output_dir, ext, compile=True):
log.info("writing stub loader for %s",ext._full_name)
def write_stub(self, output_dir, ext):
log.info("writing stub loader for %s to %s",ext._full_name, output_dir)
stub_file = os.path.join(output_dir, *ext._full_name.split('.'))+'.py'
if not self.dry_run:
f = open(stub_file,'w')
......@@ -200,8 +202,6 @@ class build_ext(_build_ext):
"" # terminal \n
]))
f.close()
if compile:
self.get_finalized_command('build_py').byte_compile(stub_file)
def links_to_dynamic(self, ext):
"""Return true if 'ext' links to a dynamic lib in the same package"""
......
......@@ -14,3 +14,12 @@ class install_lib(_install_lib):
bytecode_files.append(py_file + "o")
return bytecode_files
def run(self):
self.build()
outfiles = self.install()
if outfiles is not None:
# always compile, in case we have any extension stubs to deal with
self.byte_compile(outfiles)
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