[Python-checkins] r42034 - sandbox/trunk/setuptools/setuptools/command/bdist_egg.py sandbox/trunk/setuptools/setuptools/command/build_ext.py
phillip.eby
python-checkins at python.org
Fri Jan 13 23:32:57 CET 2006
Author: phillip.eby
Date: Fri Jan 13 23:32:57 2006
New Revision: 42034
Modified:
sandbox/trunk/setuptools/setuptools/command/bdist_egg.py
sandbox/trunk/setuptools/setuptools/command/build_ext.py
Log:
Don't write .py stubs except for actual extensions that don't already
have them.
Modified: sandbox/trunk/setuptools/setuptools/command/bdist_egg.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/command/bdist_egg.py (original)
+++ sandbox/trunk/setuptools/setuptools/command/bdist_egg.py Fri Jan 13 23:32:57 2006
@@ -10,6 +10,7 @@
from distutils import log
from pkg_resources import get_platform, Distribution
from types import CodeType
+from setuptools.extension import Library
def write_stub(resource, pyfile):
f = open(pyfile,'w')
@@ -38,7 +39,6 @@
-
class bdist_egg(Command):
description = "create an \"egg\" distribution"
@@ -174,7 +174,7 @@
cmd = self.call_command('install_lib', warn_dir=0)
instcmd.root = old_root
- ext_outputs = self.get_ext_outputs()
+ all_outputs, ext_outputs = self.get_ext_outputs()
self.stubs = []
to_compile = []
for (p,ext_name) in enumerate(ext_outputs):
@@ -204,11 +204,11 @@
self.call_command('install_scripts', install_dir=script_dir)
native_libs = os.path.join(self.egg_info,"native_libs.txt")
- if ext_outputs:
+ if all_outputs:
log.info("writing %s" % native_libs)
if not self.dry_run:
libs_file = open(native_libs, 'wt')
- libs_file.write('\n'.join(ext_outputs))
+ libs_file.write('\n'.join(all_outputs))
libs_file.write('\n')
libs_file.close()
elif os.path.isfile(native_libs):
@@ -288,28 +288,28 @@
def get_ext_outputs(self):
"""Get a list of relative paths to C extensions in the output distro"""
- outputs = []
+ all_outputs = []
+ ext_outputs = []
+
paths = {self.bdist_dir:''}
for base, dirs, files in os.walk(self.bdist_dir):
for filename in files:
if os.path.splitext(filename)[1].lower() in NATIVE_EXTENSIONS:
- outputs.append(paths[base]+filename)
+ all_outputs.append(paths[base]+filename)
for filename in dirs:
paths[os.path.join(base,filename)] = paths[base]+filename+'/'
-
- if not self.distribution.has_ext_modules():
- return outputs
-
- build_cmd = self.get_finalized_command('build_ext')
- prefix_len = len(build_cmd.build_lib) + len(os.sep)
- for filename in build_cmd.get_outputs():
- if os.path.splitext(filename)[1].lower() not in NATIVE_EXTENSIONS:
- # only add files w/unrecognized extensions, since the
- # recognized ones will already be in the list
- outputs.append(filename[prefix_len:])
+ if self.distribution.has_ext_modules():
+ build_cmd = self.get_finalized_command('build_ext')
+ for ext in build_cmd.extensions:
+ if isinstance(ext,Library):
+ continue
+ fullname = build_cmd.get_ext_fullname(ext.name)
+ filename = build_cmd.get_ext_filename(fullname)
+ if not os.path.basename(filename).startswith('dl-'):
+ ext_outputs.append(filename)
- return outputs
+ return all_outputs, ext_outputs
NATIVE_EXTENSIONS = dict.fromkeys('.dll .so .dylib .pyd'.split())
Modified: sandbox/trunk/setuptools/setuptools/command/build_ext.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/command/build_ext.py (original)
+++ sandbox/trunk/setuptools/setuptools/command/build_ext.py Fri Jan 13 23:32:57 2006
@@ -165,12 +165,12 @@
def build_extension(self, ext):
_compiler = self.compiler
_rpath = ext.runtime_library_dirs
- _ldirs = library_dirs
+ _ldirs = ext.library_dirs
try:
if isinstance(ext,Library):
self.compiler = self.shlib_compiler
- if have_rtld and self.links_to_dynamic(ext):
- ext.runtime_library_dirs = _rpath + [os.curdir]
+ if self.links_to_dynamic(ext):
+ if have_rtld: ext.runtime_library_dirs = _rpath + [os.curdir]
ext.library_dirs = _ldirs + [
os.path.dirname(
os.path.join(self.build_lib,
@@ -196,12 +196,12 @@
libnames = dict.fromkeys(
[self.get_ext_fullname(lib.name) for lib in self.shlibs]
)
- if not libnames:
- return False
pkg = '.'.join(self.get_ext_fullname(ext.name).split('.')[:-1])
+ if pkg: pkg+='.'
for libname in ext.libraries:
- if ('%s.%s' % (pkg,libname)) in libnames:
- return True
+ if pkg+libname in libnames: return True
+ return False
+
if have_rtld or os.name=='nt':
# Build shared libraries
More information about the Python-checkins
mailing list