You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-commits@lucene.apache.org by va...@apache.org on 2012/10/11 04:24:10 UTC
svn commit: r1396894 - in /lucene/pylucene/trunk/jcc: CHANGES
helpers/linux.py setup.py
Author: vajda
Date: Thu Oct 11 02:24:10 2012
New Revision: 1396894
URL: http://svn.apache.org/viewvc?rev=1396894&view=rev
Log:
- improved JCC build on Linux by mokey patching setuptools (Caleb Burns)
Modified:
lucene/pylucene/trunk/jcc/CHANGES
lucene/pylucene/trunk/jcc/helpers/linux.py
lucene/pylucene/trunk/jcc/setup.py
Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=1396894&r1=1396893&r2=1396894&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Thu Oct 11 02:24:10 2012
@@ -1,3 +1,8 @@
+Version 2.14 ->
+--------------------
+ - improved JCC build on Linux by mokey patching setuptools (Caleb Burns)
+ -
+
Version 2.13 -> 2.14
--------------------
- fixed class initialization race bug PYLUCENE-17 (with Patrick J. McNerthney)
Modified: lucene/pylucene/trunk/jcc/helpers/linux.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/helpers/linux.py?rev=1396894&r1=1396893&r2=1396894&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/helpers/linux.py (original)
+++ lucene/pylucene/trunk/jcc/helpers/linux.py Thu Oct 11 02:24:10 2012
@@ -10,7 +10,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
+import sys, os, os.path, re
+import distutils, setuptools
+
+from setuptools import dist, extension
+from setuptools.command import build_ext
+from setuptools.extension import Library as _Library
def patch_st_dir(patch_version, st_egg, jccdir):
@@ -43,22 +48,46 @@ See %s/INSTALL for more information abou
''' %(patch_version, st_egg, jccdir, patch_version, st_egg, jccdir)
+
def patch_setuptools(with_setuptools):
+ with_setuptools_c7 = ('00000000', '00000006', '*c', '00000007', '*final')
with_setuptools_c11 = ('00000000', '00000006', '*c', '00000011', '*final')
- with_setuptools_15 = ('00000000', '00000006', '00000015', '*@', '*final')
+ with_distribute_1 = ('00000000', '00000006', '00000001', '*final')
try:
from setuptools.command.build_ext import sh_link_shared_object
enable_shared = True # jcc/patches/patch.43 was applied
except ImportError:
- import setuptools
jccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
st_egg = os.path.dirname(setuptools.__path__[0])
- if with_setuptools < with_setuptools_c11: # old 0.6c7-10 series
+ if with_setuptools_c7 <= with_setuptools <= with_setuptools_c11 or with_distribute_1 <= with_setuptools:
+ # Old setuptools 0.6c7-10 series
+ # New distribute 0.6.1+ series
+
+ if with_setuptools < with_setuptools_c11 and not hasattr(dist, 'check_packages'):
+ # Old setuptools 0.6c7-10 series missing check_packages()
+ dist.check_packages = check_packages
+
+ setuptools.Library = LinuxLibrary
+ extension.Library = LinuxLibrary
+ build_ext.build_ext = LinuxBuildExt
+ if build_ext.use_stubs:
+ # Build shared libraries.
+ global sh_link_shared_object # Fix UnboundLocalError
+ build_ext.link_shared_object = sh_link_shared_object
+ else:
+ # Build static libraries every where else (unless forced)
+ build_ext.libtype = 'static'
+ build_ext.link_shared_object = st_link_shared_object
+
+ print >>sys.stderr, "Applied shared mode monkey patch to:", setuptools
+ return True # monkey patch was applied
+
+ elif with_setuptools < with_setuptools_c11: # old 0.6c7-10 series
patch_version = '0.6c7'
- elif with_setuptools >= with_setuptools_15: # new 0.6.15 and up fork
- patch_version = '0.6c7' # compatible with 0.6c9
+ elif with_setuptools >= with_distribute_1: # new 0.6.1 and up fork
+ patch_version = '0.6c7' # compatible with 0.6c7
else:
patch_version = '0.6c11' # old 0.6c11+ series
@@ -70,3 +99,68 @@ def patch_setuptools(with_setuptools):
jccdir)
return enable_shared
+
+
+class LinuxLibrary(_Library):
+ def __init__(self, *args, **kwds):
+ self.force_shared = kwds.pop('force_shared', False)
+ extension.Extension.__init__(self, *args, **kwds)
+
+
+class LinuxBuildExt(build_ext.build_ext):
+
+ def get_ext_filename(self, fullname):
+ filename = build_ext._build_ext.get_ext_filename(self, fullname)
+ if fullname in self.ext_map:
+ ext = self.ext_map[fullname]
+ if isinstance(ext, _Library):
+ if ext.force_shared and not build_ext.use_stubs:
+ libtype = 'shared'
+ else:
+ libtype = build_ext.libtype
+ fn, ext = os.path.splitext(filename)
+ return self.shlib_compiler.library_filename(fn, libtype)
+ elif build_ext.use_stubs and ext._links_to_dynamic:
+ d, fn = os.path.split(filename)
+ return os.path.join(d, 'dl-' + fn)
+ return filename
+
+ def build_extension(self, ext):
+ _compiler = self.compiler
+ try:
+ force_shared = False
+ if isinstance(ext, _Library):
+ self.compiler = self.shlib_compiler
+ force_shared = ext.force_shared and not build_ext.use_stubs
+ if force_shared:
+ self.compiler.link_shared_object = sh_link_shared_object.__get__(self.compiler)
+ build_ext._build_ext.build_extension(self, ext)
+ if ext._needs_stub:
+ self.write_stub(self.get_finalized_command('build_py').build_lib, ext)
+ finally:
+ if force_shared:
+ self.compiler.link_shared_object = build_ext.link_shared_object.__get__(self.compiler)
+ self.compiler = _compiler
+
+
+def sh_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)
+
+def st_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):
+ 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)
+
+def check_packages(dist, attr, value):
+ for pkgname in value:
+ if not re.match(r'\w+(\.\w+)*', pkgname):
+ distutils.log.warn(
+ "WARNING: %r not a valid package name; please use only"
+ ".-separated package names in setup.py", pkgname
+ )
Modified: lucene/pylucene/trunk/jcc/setup.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/setup.py?rev=1396894&r1=1396893&r2=1396894&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/setup.py (original)
+++ lucene/pylucene/trunk/jcc/setup.py Thu Oct 11 02:24:10 2012
@@ -51,7 +51,7 @@ else:
JDK = {
'darwin': JAVAHOME,
'ipod': '/usr/include/gcc',
- 'linux2': '/usr/lib/jvm/java-6-openjdk',
+ 'linux2': '/usr/lib/jvm/java-7-openjdk-amd64',
'sunos5': '/usr/jdk/instances/jdk1.6.0',
'win32': JAVAHOME,
'mingw32': JAVAHOME,