update Thu Feb 11 18:37:00 PST 2010
[pkgsrc.git] / lang / python26 / patches / patch-am
1 $NetBSD: patch-am,v 1.10 2010/02/11 21:09:50 tnn Exp $
2
3 Disabled modules for normal build:
4 bsdddb
5 curses
6 curses_panel
7 elementtree
8 Those have separate packages.
9
10 Only check the BUILDLINK_DIR for libraries etc, do not pick up random
11 headers and libraries from the system.
12
13 Build the 1.85 compat module all the time against the BDB version of choice.
14
15 --- setup.py.orig       2009-10-08 09:48:32.000000000 +0000
16 +++ setup.py
17 @@ -17,7 +17,7 @@ from distutils.command.install import in
18  from distutils.command.install_lib import install_lib
19  
20  # This global variable is used to hold the list of modules to be disabled.
21 -disabled_module_list = []
22 +disabled_module_list = ["_bsddb", "_curses", "_curses_panel", "_elementtree", "_sqlite3", "_tkinter", "gdbm", "pyexpat", "readline"]
23  
24  def add_dir_to_list(dirlist, dir):
25      """Add the directory 'dir' to the list 'dirlist' (at the front) if
26 @@ -309,9 +309,15 @@ class PyBuildExt(build_ext):
27          return sys.platform
28  
29      def detect_modules(self):
30 -        # Ensure that /usr/local is always used
31 -        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
32 -        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
33 +        # Add the buildlink directories for pkgsrc
34 +        if os.environ.has_key('BUILDLINK_DIR'):
35 +            dir = os.environ['BUILDLINK_DIR']
36 +            libdir = dir + '/lib'
37 +            incdir = dir + '/include'
38 +            if libdir not in self.compiler.library_dirs:
39 +                self.compiler.library_dirs.insert(0, libdir)
40 +            if incdir not in self.compiler.include_dirs:
41 +                self.compiler.include_dirs.insert(0, incdir)
42  
43          # Add paths specified in the environment variables LDFLAGS and
44          # CPPFLAGS for header and library files.
45 @@ -626,9 +632,7 @@ class PyBuildExt(build_ext):
46              if krb5_h:
47                  ssl_incs += krb5_h
48          ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
49 -                                     ['/usr/local/ssl/lib',
50 -                                      '/usr/contrib/ssl/lib/'
51 -                                     ] )
52 +                                     [] )
53  
54          if (ssl_incs is not None and
55              ssl_libs is not None):
56 @@ -738,151 +742,6 @@ class PyBuildExt(build_ext):
57              else:
58                  raise ValueError("unknown major BerkeleyDB version", major)
59  
60 -        # construct a list of paths to look for the header file in on
61 -        # top of the normal inc_dirs.
62 -        db_inc_paths = [
63 -            '/usr/include/db4',
64 -            '/usr/local/include/db4',
65 -            '/opt/sfw/include/db4',
66 -            '/usr/include/db3',
67 -            '/usr/local/include/db3',
68 -            '/opt/sfw/include/db3',
69 -            # Fink defaults (http://fink.sourceforge.net/)
70 -            '/sw/include/db4',
71 -            '/sw/include/db3',
72 -        ]
73 -        # 4.x minor number specific paths
74 -        for x in gen_db_minor_ver_nums(4):
75 -            db_inc_paths.append('/usr/include/db4%d' % x)
76 -            db_inc_paths.append('/usr/include/db4.%d' % x)
77 -            db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
78 -            db_inc_paths.append('/usr/local/include/db4%d' % x)
79 -            db_inc_paths.append('/pkg/db-4.%d/include' % x)
80 -            db_inc_paths.append('/opt/db-4.%d/include' % x)
81 -            # MacPorts default (http://www.macports.org/)
82 -            db_inc_paths.append('/opt/local/include/db4%d' % x)
83 -        # 3.x minor number specific paths
84 -        for x in gen_db_minor_ver_nums(3):
85 -            db_inc_paths.append('/usr/include/db3%d' % x)
86 -            db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
87 -            db_inc_paths.append('/usr/local/include/db3%d' % x)
88 -            db_inc_paths.append('/pkg/db-3.%d/include' % x)
89 -            db_inc_paths.append('/opt/db-3.%d/include' % x)
90 -
91 -        # Add some common subdirectories for Sleepycat DB to the list,
92 -        # based on the standard include directories. This way DB3/4 gets
93 -        # picked up when it is installed in a non-standard prefix and
94 -        # the user has added that prefix into inc_dirs.
95 -        std_variants = []
96 -        for dn in inc_dirs:
97 -            std_variants.append(os.path.join(dn, 'db3'))
98 -            std_variants.append(os.path.join(dn, 'db4'))
99 -            for x in gen_db_minor_ver_nums(4):
100 -                std_variants.append(os.path.join(dn, "db4%d"%x))
101 -                std_variants.append(os.path.join(dn, "db4.%d"%x))
102 -            for x in gen_db_minor_ver_nums(3):
103 -                std_variants.append(os.path.join(dn, "db3%d"%x))
104 -                std_variants.append(os.path.join(dn, "db3.%d"%x))
105 -
106 -        db_inc_paths = std_variants + db_inc_paths
107 -        db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)]
108 -
109 -        db_ver_inc_map = {}
110 -
111 -        class db_found(Exception): pass
112 -        try:
113 -            # See whether there is a Sleepycat header in the standard
114 -            # search path.
115 -            for d in inc_dirs + db_inc_paths:
116 -                f = os.path.join(d, "db.h")
117 -                if db_setup_debug: print "db: looking for db.h in", f
118 -                if os.path.exists(f):
119 -                    f = open(f).read()
120 -                    m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f)
121 -                    if m:
122 -                        db_major = int(m.group(1))
123 -                        m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f)
124 -                        db_minor = int(m.group(1))
125 -                        db_ver = (db_major, db_minor)
126 -
127 -                        # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug
128 -                        if db_ver == (4, 6):
129 -                            m = re.search(r"#define\WDB_VERSION_PATCH\W(\d+)", f)
130 -                            db_patch = int(m.group(1))
131 -                            if db_patch < 21:
132 -                                print "db.h:", db_ver, "patch", db_patch,
133 -                                print "being ignored (4.6.x must be >= 4.6.21)"
134 -                                continue
135 -
136 -                        if ( (not db_ver_inc_map.has_key(db_ver)) and
137 -                            allow_db_ver(db_ver) ):
138 -                            # save the include directory with the db.h version
139 -                            # (first occurrence only)
140 -                            db_ver_inc_map[db_ver] = d
141 -                            if db_setup_debug:
142 -                                print "db.h: found", db_ver, "in", d
143 -                        else:
144 -                            # we already found a header for this library version
145 -                            if db_setup_debug: print "db.h: ignoring", d
146 -                    else:
147 -                        # ignore this header, it didn't contain a version number
148 -                        if db_setup_debug:
149 -                            print "db.h: no version number version in", d
150 -
151 -            db_found_vers = db_ver_inc_map.keys()
152 -            db_found_vers.sort()
153 -
154 -            while db_found_vers:
155 -                db_ver = db_found_vers.pop()
156 -                db_incdir = db_ver_inc_map[db_ver]
157 -
158 -                # check lib directories parallel to the location of the header
159 -                db_dirs_to_check = [
160 -                    db_incdir.replace("include", 'lib64'),
161 -                    db_incdir.replace("include", 'lib'),
162 -                ]
163 -                db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
164 -
165 -                # Look for a version specific db-X.Y before an ambiguoius dbX
166 -                # XXX should we -ever- look for a dbX name?  Do any
167 -                # systems really not name their library by version and
168 -                # symlink to more general names?
169 -                for dblib in (('db-%d.%d' % db_ver),
170 -                              ('db%d%d' % db_ver),
171 -                              ('db%d' % db_ver[0])):
172 -                    dblib_file = self.compiler.find_library_file(
173 -                                    db_dirs_to_check + lib_dirs, dblib )
174 -                    if dblib_file:
175 -                        dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ]
176 -                        raise db_found
177 -                    else:
178 -                        if db_setup_debug: print "db lib: ", dblib, "not found"
179 -
180 -        except db_found:
181 -            if db_setup_debug:
182 -                print "bsddb using BerkeleyDB lib:", db_ver, dblib
183 -                print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
184 -            db_incs = [db_incdir]
185 -            dblibs = [dblib]
186 -            # We add the runtime_library_dirs argument because the
187 -            # BerkeleyDB lib we're linking against often isn't in the
188 -            # system dynamic library search path.  This is usually
189 -            # correct and most trouble free, but may cause problems in
190 -            # some unusual system configurations (e.g. the directory
191 -            # is on an NFS server that goes away).
192 -            exts.append(Extension('_bsddb', ['_bsddb.c'],
193 -                                  depends = ['bsddb.h'],
194 -                                  library_dirs=dblib_dir,
195 -                                  runtime_library_dirs=dblib_dir,
196 -                                  include_dirs=db_incs,
197 -                                  libraries=dblibs))
198 -        else:
199 -            if db_setup_debug: print "db: no appropriate library found"
200 -            db_incs = None
201 -            dblibs = []
202 -            dblib_dir = None
203 -            missing.append('_bsddb')
204 -
205          # The sqlite interface
206          sqlite_setup_debug = False   # verbose debug prints from this script?
207  
208 @@ -989,25 +848,12 @@ class PyBuildExt(build_ext):
209          # we do not build this one.  Otherwise this build will pick up
210          # the more recent berkeleydb's db.h file first in the include path
211          # when attempting to compile and it will fail.
212 -        f = "/usr/include/db.h"
213 -        if os.path.exists(f) and not db_incs:
214 -            data = open(f).read()
215 -            m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
216 -            if m is not None:
217 -                # bingo - old version used hash file format version 2
218 -                ### XXX this should be fixed to not be platform-dependent
219 -                ### but I don't have direct access to an osf1 platform and
220 -                ### seemed to be muffing the search somehow
221 -                libraries = platform == "osf1" and ['db'] or None
222 -                if libraries is not None:
223 -                    exts.append(Extension('bsddb185', ['bsddbmodule.c'],
224 -                                          libraries=libraries))
225 -                else:
226 -                    exts.append(Extension('bsddb185', ['bsddbmodule.c']))
227 -            else:
228 -                missing.append('bsddb185')
229 +        libraries = os.getenv("PY_BDB_TYPE", "")
230 +        if libraries:
231 +            exts.append(Extension('bsddb185', ['bsddbmodule.c'],
232 +                                  libraries=["db"]))
233          else:
234 -            missing.append('bsddb185')
235 +            exts.append(Extension('bsddb185', ['bsddbmodule.c']))
236  
237          # The standard Unix dbm module:
238          if platform not in ['cygwin']:
239 @@ -1020,7 +866,7 @@ class PyBuildExt(build_ext):
240                  exts.append( Extension('dbm', ['dbmmodule.c'],
241                                         define_macros=[('HAVE_NDBM_H',None)],
242                                         libraries = ndbm_libs ) )
243 -            elif self.compiler.find_library_file(lib_dirs, 'gdbm'):
244 +            elif 1==0 and self.compiler.find_library_file(lib_dirs, 'gdbm'):
245                  gdbm_libs = ['gdbm']
246                  if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'):
247                      gdbm_libs.append('gdbm_compat')
248 @@ -1036,14 +882,11 @@ class PyBuildExt(build_ext):
249                          libraries = gdbm_libs ) )
250                  else:
251                      missing.append('dbm')
252 -            elif db_incs is not None:
253 +            elif 1==1:
254                  exts.append( Extension('dbm', ['dbmmodule.c'],
255 -                                       library_dirs=dblib_dir,
256 -                                       runtime_library_dirs=dblib_dir,
257 -                                       include_dirs=db_incs,
258                                         define_macros=[('HAVE_BERKDB_H',None),
259                                                        ('DB_DBM_HSEARCH',None)],
260 -                                       libraries=dblibs))
261 +                                       libraries=["db"]))
262              else:
263                  missing.append('dbm')
264  
265 @@ -1300,6 +1143,14 @@ class PyBuildExt(build_ext):
266                  )
267              libraries = []
268  
269 +       elif platform.startswith('dragonfly'):
270 +           macros = dict(
271 +               HAVE_SEM_OPEN=0,
272 +               HAVE_SEM_TIMEDWAIT=0,
273 +               HAVE_FD_TRANSFER=1,
274 +               )
275 +           libraries = []
276 +
277          else:                                   # Linux and other unices
278              macros = dict(
279                  HAVE_SEM_OPEN=1,
280 @@ -1900,9 +1751,9 @@ def main():
281            ext_modules=[Extension('_struct', ['_struct.c'])],
282  
283            # Scripts to install
284 -          scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
285 +          scripts = ['Tools/scripts/pydoc2.6',
286                       'Tools/scripts/2to3',
287 -                     'Lib/smtpd.py']
288 +                     'Lib/smtpd2.6.py']
289          )
290  
291  # --install-platlib