diff options
author | PJ Eby <distutils-sig@python.org> | 2006-01-06 19:57:36 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2006-01-06 19:57:36 +0000 |
commit | 5d732201ae2c910ebd00a882d33d70bc47056662 (patch) | |
tree | 477abc232e66761da651880d67d4390c98b9f243 | |
parent | 59e6023baf87bd578ca73bd534d35917592f3a76 (diff) | |
download | external_python_setuptools-5d732201ae2c910ebd00a882d33d70bc47056662.tar.gz external_python_setuptools-5d732201ae2c910ebd00a882d33d70bc47056662.tar.bz2 external_python_setuptools-5d732201ae2c910ebd00a882d33d70bc47056662.zip |
SharedLibrary -> Library. For now, Windows libs get built as shared,
and other platforms get static. :(
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041941
-rw-r--r-- | setuptools/__init__.py | 2 | ||||
-rw-r--r-- | setuptools/command/build_ext.py | 88 | ||||
-rw-r--r-- | setuptools/extension.py | 4 | ||||
-rwxr-xr-x | tests/shlib_test/setup.py | 4 |
4 files changed, 49 insertions, 49 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 4c14fe3a..d51fdb49 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -1,5 +1,5 @@ """Extensions to the 'distutils' for large or complex distributions""" -from setuptools.extension import Extension, SharedLibrary +from setuptools.extension import Extension, Library from setuptools.dist import Distribution, Feature, _get_unpatched import distutils.core, setuptools.command from setuptools.depends import Require diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py index ec8a8038..f063d51e 100644 --- a/setuptools/command/build_ext.py +++ b/setuptools/command/build_ext.py @@ -7,7 +7,7 @@ except ImportError: import os, sys from distutils.file_util import copy_file -from setuptools.extension import SharedLibrary +from setuptools.extension import Library from distutils.ccompiler import new_compiler from distutils.sysconfig import customize_compiler @@ -52,7 +52,7 @@ class build_ext(_build_ext): for ext in self.shlibs: if self.get_ext_fullname(ext.name)==fullname: fn, ext = os.path.splitext(filename) - return self.shlib_compiler.library_filename(fn,'shared') + return self.shlib_compiler.library_filename(fn,libtype) return filename def initialize_options(self): @@ -63,7 +63,7 @@ class build_ext(_build_ext): def finalize_options(self): _build_ext.finalize_options(self) self.shlibs = [ext for ext in self.extensions or () - if isinstance(ext,SharedLibrary)] + if isinstance(ext,Library)] if self.shlibs: self.setup_shlib_compiler() self.library_dirs.append(self.build_lib) @@ -71,7 +71,7 @@ class build_ext(_build_ext): def build_extension(self, ext): _compiler = self.compiler try: - if isinstance(ext,SharedLibrary): + if isinstance(ext,Library): self.compiler = self.shlib_compiler _build_ext.build_extension(self,ext) finally: @@ -107,22 +107,11 @@ class build_ext(_build_ext): if self.link_objects is not None: compiler.set_link_objects(self.link_objects) - # hack so distutils' build_extension() builds a shared lib instead - # - def link_shared_object(self, objects, output_libname, output_dir=None, - libraries=None, library_dirs=None, runtime_library_dirs=None, - export_symbols=None, debug=0, extra_preargs=None, - extra_postargs=None, build_temp=None, target_lang=None - ): self.link( - self.SHARED_LIBRARY, objects, output_libname, - output_dir, libraries, library_dirs, runtime_library_dirs, - export_symbols, debug, extra_preargs, extra_postargs, - build_temp, target_lang - ) + # hack so distutils' build_extension() builds a library instead compiler.link_shared_object = link_shared_object.__get__(compiler) def get_export_symbols(self, ext): - if isinstance(ext,SharedLibrary): + if isinstance(ext,Library): return ext.export_symbols return _build_ext.get_export_symbols(self,ext) @@ -132,33 +121,44 @@ class build_ext(_build_ext): - - - - - - - - - - - - - - - - - - - - - - - - - - - +if os.name=='nt': + # Build shared libraries on Windows + libtype = 'shared' + def link_shared_object(self, objects, output_libname, output_dir=None, + libraries=None, library_dirs=None, runtime_library_dirs=None, + export_symbols=None, debug=0, extra_preargs=None, + extra_postargs=None, build_temp=None, target_lang=None + ): self.link( + self.SHARED_LIBRARY, objects, output_libname, + output_dir, libraries, library_dirs, runtime_library_dirs, + export_symbols, debug, extra_preargs, extra_postargs, + build_temp, target_lang + ) +else: + # Build static libraries everywhere else + libtype = 'static' + def link_shared_object(self, objects, output_libname, output_dir=None, + libraries=None, library_dirs=None, runtime_library_dirs=None, + export_symbols=None, debug=0, extra_preargs=None, + extra_postargs=None, build_temp=None, target_lang=None + ): + # XXX we need to either disallow these attrs on Library instances, + # or warn/abort here if set, or something... + #libraries=None, library_dirs=None, runtime_library_dirs=None, + #export_symbols=None, extra_preargs=None, extra_postargs=None, + #build_temp=None + + assert output_dir is None # distutils build_ext doesn't pass this + output_dir,filename = os.path.split(output_libname) + basename, ext = os.path.splitext(filename) + if self.library_filename("x").startswith('lib'): + # strip 'lib' prefix; this is kludgy if some platform uses + # a different prefix + basename = basename[3:] + + self.create_static_lib( + objects, basename, output_dir, debug, target_lang + ) diff --git a/setuptools/extension.py b/setuptools/extension.py index 33b870f0..2bef84e5 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -25,8 +25,8 @@ class Extension(_Extension): sources.append(s) self.sources = sources -class SharedLibrary(Extension): - """Just like a regular Extension, but built as a shared library instead""" +class Library(Extension): + """Just like a regular Extension, but built as a library instead""" import sys, distutils.core, distutils.extension distutils.core.Extension = Extension diff --git a/tests/shlib_test/setup.py b/tests/shlib_test/setup.py index 122de77c..b0c93996 100755 --- a/tests/shlib_test/setup.py +++ b/tests/shlib_test/setup.py @@ -1,9 +1,9 @@ -from setuptools import setup, Extension, SharedLibrary +from setuptools import setup, Extension, Library setup( name="shlib_test", ext_modules = [ - SharedLibrary("hellolib", ["hellolib.c"]), + Library("hellolib", ["hellolib.c"]), Extension("hello", ["hello.pyx"], libraries=["hellolib"]) ], test_suite="test_hello.HelloWorldTest", |