PyLucene 3.4.0-1 import
[pylucene.git] / jcc / helpers / linux.py
1 #   Licensed under the Apache License, Version 2.0 (the "License");
2 #   you may not use this file except in compliance with the License.
3 #   You may obtain a copy of the License at
4 #
5 #       http://www.apache.org/licenses/LICENSE-2.0
6 #
7 #   Unless required by applicable law or agreed to in writing, software
8 #   distributed under the License is distributed on an "AS IS" BASIS,
9 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 #   See the License for the specific language governing permissions and
11 #   limitations under the License.
12
13 import os
14
15
16 def patch_st_dir(patch_version, st_egg, jccdir):
17     return '''
18
19 Shared mode is disabled, setuptools patch.43.%s must be applied to enable it
20 or the NO_SHARED environment variable must be set to turn off this error.
21
22     sudo patch -d %s -Nup0 < %s/jcc/patches/patch.43.%s
23
24 See %s/INSTALL for more information about shared mode.
25 ''' %(patch_version, st_egg, jccdir, patch_version, jccdir)
26
27
28 def patch_st_zip(patch_version, st_egg, jccdir):
29     return '''
30
31 Shared mode is disabled, setuptools patch.43.%s must be applied to enable it
32 or the NO_SHARED environment variable must be set to turn off this error.
33
34     mkdir tmp
35     cd tmp
36     unzip -q %s
37     patch -Nup0 < %s/jcc/patches/patch.43.%s
38     sudo zip %s -f
39     cd ..
40     rm -rf tmp
41
42 See %s/INSTALL for more information about shared mode.
43 ''' %(patch_version, st_egg, jccdir, patch_version, st_egg, jccdir)
44
45
46 def patch_setuptools(with_setuptools):
47
48     with_setuptools_c11 = ('00000000', '00000006', '*c', '00000011', '*final')
49
50     try:
51         from setuptools.command.build_ext import sh_link_shared_object
52         enable_shared = True  # jcc/patches/patch.43 was applied
53     except ImportError:
54         import setuptools
55         jccdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
56         st_egg = os.path.dirname(setuptools.__path__[0])
57         if with_setuptools < with_setuptools_c11:
58             patch_version = '0.6c7'
59         else:
60             patch_version = '0.6c11'
61
62         if os.path.isdir(st_egg):
63             raise NotImplementedError, patch_st_dir(patch_version, st_egg,
64                                                     jccdir)
65         else:
66             raise NotImplementedError, patch_st_zip(patch_version, st_egg,
67                                                     jccdir)
68
69     return enable_shared