Commit 5d732201 authored by PJ Eby's avatar PJ Eby

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
parent 59e6023b
"""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
......
......@@ -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
)
......@@ -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
......
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",
......
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