Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / lang / python26 / patches / patch-am
blobe3d951f0a27ff5f9404388343e560318f7e4661e
1 $NetBSD: patch-am,v 1.18 2011/10/31 06:50:54 sbd Exp $
3 Disabled modules for normal build:
4 bsddb
5 curses
6 curses_panel
7 elementtree
8 sqlite3
9 tkinter
10 gdbm
11 pyexpat
12 readline
13 {linux,oss,sun}audiodev
14 spwd
15 Those have separate packages where needed.
17 Only check the BUILDLINK_DIR for libraries etc, do not pick up random
18 headers and libraries from the system.
20 Build the 1.85 compat module all the time against the BDB version of choice.
22 Add in Debian multiarch support (retrofitted from Python 2.7.2) to
23 support building the "nis" and "crypt" modules.
25 --- setup.py    2010-07-18 00:31:09.000000000 +1200
26 +++ setup.py    2011-09-23 01:51:17.757519638 +1200
27 @@ -18,7 +18,7 @@
28  from distutils.spawn import find_executable
30  # This global variable is used to hold the list of modules to be disabled.
31 -disabled_module_list = []
32 +disabled_module_list = ["_bsddb", "_curses", "_curses_panel", "_elementtree", "_sqlite3", "_tkinter", "gdbm", "pyexpat", "readline", "linuxaudiodev", "ossaudiodev", "spwd", "sunaudiodev"]
34  def add_dir_to_list(dirlist, dir):
35      """Add the directory 'dir' to the list 'dirlist' (at the front) if
36 @@ -354,10 +354,40 @@
37                  return platform
38          return sys.platform
40 +    def add_multiarch_paths(self):
41 +        # Debian/Ubuntu multiarch support.
42 +        # https://wiki.ubuntu.com/MultiarchSpec
43 +        if not find_executable('dpkg-architecture'):
44 +            return
45 +        tmpfile = os.path.join(self.build_temp, 'multiarch')
46 +        if not os.path.exists(self.build_temp):
47 +            os.makedirs(self.build_temp)
48 +        ret = os.system(
49 +            'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
50 +            tmpfile)
51 +        try:
52 +            if ret >> 8 == 0:
53 +                with open(tmpfile) as fp:
54 +                    multiarch_path_component = fp.readline().strip()
55 +                add_dir_to_list(self.compiler.library_dirs,
56 +                                '/usr/lib/' + multiarch_path_component)
57 +                add_dir_to_list(self.compiler.include_dirs,
58 +                                '/usr/include/' + multiarch_path_component)
59 +        finally:
60 +            os.unlink(tmpfile)
62      def detect_modules(self):
63 -        # Ensure that /usr/local is always used
64 -        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
65 -        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
66 +        # Add the buildlink directories for pkgsrc
67 +        if os.environ.has_key('BUILDLINK_DIR'):
68 +            dir = os.environ['BUILDLINK_DIR']
69 +            libdir = dir + '/lib'
70 +            incdir = dir + '/include'
71 +            if libdir not in self.compiler.library_dirs:
72 +                self.compiler.library_dirs.insert(0, libdir)
73 +            if incdir not in self.compiler.include_dirs:
74 +                self.compiler.include_dirs.insert(0, incdir)
76 +        self.add_multiarch_paths()
78          # Add paths specified in the environment variables LDFLAGS and
79          # CPPFLAGS for header and library files.
80 @@ -703,9 +733,7 @@
81              if krb5_h:
82                  ssl_incs += krb5_h
83          ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
84 -                                     ['/usr/local/ssl/lib',
85 -                                      '/usr/contrib/ssl/lib/'
86 -                                     ] )
87 +                                     [] )
89          if (ssl_incs is not None and
90              ssl_libs is not None):
91 @@ -815,172 +843,6 @@
92              else:
93                  raise ValueError("unknown major BerkeleyDB version", major)
95 -        # construct a list of paths to look for the header file in on
96 -        # top of the normal inc_dirs.
97 -        db_inc_paths = [
98 -            '/usr/include/db4',
99 -            '/usr/local/include/db4',
100 -            '/opt/sfw/include/db4',
101 -            '/usr/include/db3',
102 -            '/usr/local/include/db3',
103 -            '/opt/sfw/include/db3',
104 -            # Fink defaults (http://fink.sourceforge.net/)
105 -            '/sw/include/db4',
106 -            '/sw/include/db3',
107 -        ]
108 -        # 4.x minor number specific paths
109 -        for x in gen_db_minor_ver_nums(4):
110 -            db_inc_paths.append('/usr/include/db4%d' % x)
111 -            db_inc_paths.append('/usr/include/db4.%d' % x)
112 -            db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
113 -            db_inc_paths.append('/usr/local/include/db4%d' % x)
114 -            db_inc_paths.append('/pkg/db-4.%d/include' % x)
115 -            db_inc_paths.append('/opt/db-4.%d/include' % x)
116 -            # MacPorts default (http://www.macports.org/)
117 -            db_inc_paths.append('/opt/local/include/db4%d' % x)
118 -        # 3.x minor number specific paths
119 -        for x in gen_db_minor_ver_nums(3):
120 -            db_inc_paths.append('/usr/include/db3%d' % x)
121 -            db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
122 -            db_inc_paths.append('/usr/local/include/db3%d' % x)
123 -            db_inc_paths.append('/pkg/db-3.%d/include' % x)
124 -            db_inc_paths.append('/opt/db-3.%d/include' % x)
126 -        # Add some common subdirectories for Sleepycat DB to the list,
127 -        # based on the standard include directories. This way DB3/4 gets
128 -        # picked up when it is installed in a non-standard prefix and
129 -        # the user has added that prefix into inc_dirs.
130 -        std_variants = []
131 -        for dn in inc_dirs:
132 -            std_variants.append(os.path.join(dn, 'db3'))
133 -            std_variants.append(os.path.join(dn, 'db4'))
134 -            for x in gen_db_minor_ver_nums(4):
135 -                std_variants.append(os.path.join(dn, "db4%d"%x))
136 -                std_variants.append(os.path.join(dn, "db4.%d"%x))
137 -            for x in gen_db_minor_ver_nums(3):
138 -                std_variants.append(os.path.join(dn, "db3%d"%x))
139 -                std_variants.append(os.path.join(dn, "db3.%d"%x))
141 -        db_inc_paths = std_variants + db_inc_paths
142 -        db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)]
144 -        db_ver_inc_map = {}
146 -        if sys.platform == 'darwin':
147 -            sysroot = macosx_sdk_root()
149 -        class db_found(Exception): pass
150 -        try:
151 -            # See whether there is a Sleepycat header in the standard
152 -            # search path.
153 -            for d in inc_dirs + db_inc_paths:
154 -                f = os.path.join(d, "db.h")
156 -                if sys.platform == 'darwin' and is_macosx_sdk_path(d):
157 -                    f = os.path.join(sysroot, d[1:], "db.h")
159 -                if db_setup_debug: print "db: looking for db.h in", f
160 -                if os.path.exists(f):
161 -                    f = open(f).read()
162 -                    m = re.search(r"#define\WDB_VERSION_MAJOR\W(\d+)", f)
163 -                    if m:
164 -                        db_major = int(m.group(1))
165 -                        m = re.search(r"#define\WDB_VERSION_MINOR\W(\d+)", f)
166 -                        db_minor = int(m.group(1))
167 -                        db_ver = (db_major, db_minor)
169 -                        # Avoid 4.6 prior to 4.6.21 due to a BerkeleyDB bug
170 -                        if db_ver == (4, 6):
171 -                            m = re.search(r"#define\WDB_VERSION_PATCH\W(\d+)", f)
172 -                            db_patch = int(m.group(1))
173 -                            if db_patch < 21:
174 -                                print "db.h:", db_ver, "patch", db_patch,
175 -                                print "being ignored (4.6.x must be >= 4.6.21)"
176 -                                continue
178 -                        if ( (db_ver not in db_ver_inc_map) and
179 -                            allow_db_ver(db_ver) ):
180 -                            # save the include directory with the db.h version
181 -                            # (first occurrence only)
182 -                            db_ver_inc_map[db_ver] = d
183 -                            if db_setup_debug:
184 -                                print "db.h: found", db_ver, "in", d
185 -                        else:
186 -                            # we already found a header for this library version
187 -                            if db_setup_debug: print "db.h: ignoring", d
188 -                    else:
189 -                        # ignore this header, it didn't contain a version number
190 -                        if db_setup_debug:
191 -                            print "db.h: no version number version in", d
193 -            db_found_vers = db_ver_inc_map.keys()
194 -            db_found_vers.sort()
196 -            while db_found_vers:
197 -                db_ver = db_found_vers.pop()
198 -                db_incdir = db_ver_inc_map[db_ver]
200 -                # check lib directories parallel to the location of the header
201 -                db_dirs_to_check = [
202 -                    db_incdir.replace("include", 'lib64'),
203 -                    db_incdir.replace("include", 'lib'),
204 -                ]
206 -                if sys.platform != 'darwin':
207 -                    db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
209 -                else:
210 -                    # Same as other branch, but takes OSX SDK into account
211 -                    tmp = []
212 -                    for dn in db_dirs_to_check:
213 -                        if is_macosx_sdk_path(dn):
214 -                            if os.path.isdir(os.path.join(sysroot, dn[1:])):
215 -                                tmp.append(dn)
216 -                        else:
217 -                            if os.path.isdir(dn):
218 -                                tmp.append(dn)
219 -                    db_dirs_to_check = tmp
221 -                # Look for a version specific db-X.Y before an ambiguoius dbX
222 -                # XXX should we -ever- look for a dbX name?  Do any
223 -                # systems really not name their library by version and
224 -                # symlink to more general names?
225 -                for dblib in (('db-%d.%d' % db_ver),
226 -                              ('db%d%d' % db_ver),
227 -                              ('db%d' % db_ver[0])):
228 -                    dblib_file = self.compiler.find_library_file(
229 -                                    db_dirs_to_check + lib_dirs, dblib )
230 -                    if dblib_file:
231 -                        dblib_dir = [ os.path.abspath(os.path.dirname(dblib_file)) ]
232 -                        raise db_found
233 -                    else:
234 -                        if db_setup_debug: print "db lib: ", dblib, "not found"
236 -        except db_found:
237 -            if db_setup_debug:
238 -                print "bsddb using BerkeleyDB lib:", db_ver, dblib
239 -                print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
240 -            db_incs = [db_incdir]
241 -            dblibs = [dblib]
242 -            # We add the runtime_library_dirs argument because the
243 -            # BerkeleyDB lib we're linking against often isn't in the
244 -            # system dynamic library search path.  This is usually
245 -            # correct and most trouble free, but may cause problems in
246 -            # some unusual system configurations (e.g. the directory
247 -            # is on an NFS server that goes away).
248 -            exts.append(Extension('_bsddb', ['_bsddb.c'],
249 -                                  depends = ['bsddb.h'],
250 -                                  library_dirs=dblib_dir,
251 -                                  runtime_library_dirs=dblib_dir,
252 -                                  include_dirs=db_incs,
253 -                                  libraries=dblibs))
254 -        else:
255 -            if db_setup_debug: print "db: no appropriate library found"
256 -            db_incs = None
257 -            dblibs = []
258 -            dblib_dir = None
259 -            missing.append('_bsddb')
261          # The sqlite interface
262          sqlite_setup_debug = False   # verbose debug prints from this script?
264 @@ -1094,35 +956,40 @@
265          # we do not build this one.  Otherwise this build will pick up
266          # the more recent berkeleydb's db.h file first in the include path
267          # when attempting to compile and it will fail.
268 -        f = "/usr/include/db.h"
270 -        if sys.platform == 'darwin':
271 -            if is_macosx_sdk_path(f):
272 -                sysroot = macosx_sdk_root()
273 -                f = os.path.join(sysroot, f[1:])
275 -        if os.path.exists(f) and not db_incs:
276 -            data = open(f).read()
277 -            m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
278 -            if m is not None:
279 -                # bingo - old version used hash file format version 2
280 -                ### XXX this should be fixed to not be platform-dependent
281 -                ### but I don't have direct access to an osf1 platform and
282 -                ### seemed to be muffing the search somehow
283 -                libraries = platform == "osf1" and ['db'] or None
284 -                if libraries is not None:
285 -                    exts.append(Extension('bsddb185', ['bsddbmodule.c'],
286 -                                          libraries=libraries))
287 -                else:
288 -                    exts.append(Extension('bsddb185', ['bsddbmodule.c']))
289 -            else:
290 -                missing.append('bsddb185')
291 +        libraries = os.getenv("PY_BDB_TYPE", "")
292 +        if libraries:
293 +            exts.append(Extension('bsddb185', ['bsddbmodule.c'],
294 +                                  libraries=["db"]))
295          else:
296 -            missing.append('bsddb185')
297 +            exts.append(Extension('bsddb185', ['bsddbmodule.c']))
299          # The standard Unix dbm module:
300          if platform not in ['cygwin']:
301 -            if find_file("ndbm.h", inc_dirs, []) is not None:
303 +            ## Top half based on find_file
304 +            def find_ndbm_h(dirs):
305 +                ret = None
306 +                if sys.platform == 'darwin':
307 +                    sysroot = macosx_sdk_root()
308 +                for dir in dirs:
309 +                    f = os.path.join(dir, 'ndbm.h')
310 +                    if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
311 +                        f = os.path.join(sysroot, dir[1:], 'ndbm.h')
312 +                    if not os.path.exists(f): continue
314 +                    ret = 'True'
315 +                    input = text_file.TextFile(f)
316 +                    while 1:
317 +                        line = input.readline()
318 +                        if not line: break
319 +                        if re.search('This file is part of GDBM', line):
320 +                            ret = None
321 +                            break
322 +                    input.close()
323 +                    break
324 +                return ret
326 +            if find_ndbm_h(inc_dirs) is not None:
327                  # Some systems have -lndbm, others don't
328                  if self.compiler.find_library_file(lib_dirs, 'ndbm'):
329                      ndbm_libs = ['ndbm']
330 @@ -1131,7 +998,7 @@
331                  exts.append( Extension('dbm', ['dbmmodule.c'],
332                                         define_macros=[('HAVE_NDBM_H',None)],
333                                         libraries = ndbm_libs ) )
334 -            elif self.compiler.find_library_file(lib_dirs, 'gdbm'):
335 +            elif 1==0 and self.compiler.find_library_file(lib_dirs, 'gdbm'):
336                  gdbm_libs = ['gdbm']
337                  if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'):
338                      gdbm_libs.append('gdbm_compat')
339 @@ -1147,14 +1014,12 @@
340                          libraries = gdbm_libs ) )
341                  else:
342                      missing.append('dbm')
343 -            elif db_incs is not None:
345 +            if not module_enabled(exts, 'dbm'):
346                  exts.append( Extension('dbm', ['dbmmodule.c'],
347 -                                       library_dirs=dblib_dir,
348 -                                       runtime_library_dirs=dblib_dir,
349 -                                       include_dirs=db_incs,
350                                         define_macros=[('HAVE_BERKDB_H',None),
351                                                        ('DB_DBM_HSEARCH',None)],
352 -                                       libraries=dblibs))
353 +                                       libraries=["db"]))
354              else:
355                  missing.append('dbm')
357 @@ -1408,6 +1273,14 @@
358                  )
359              libraries = []
361 +       elif platform.startswith('dragonfly'):
362 +           macros = dict(
363 +               HAVE_SEM_OPEN=0,
364 +               HAVE_SEM_TIMEDWAIT=0,
365 +               HAVE_FD_TRANSFER=1,
366 +               )
367 +           libraries = []
369          else:                                   # Linux and other unices
370              macros = dict(
371                  HAVE_SEM_OPEN=1,
372 @@ -2026,9 +1899,9 @@
373            ext_modules=[Extension('_struct', ['_struct.c'])],
375            # Scripts to install
376 -          scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
377 -                     'Tools/scripts/2to3',
378 -                     'Lib/smtpd.py']
379 +          scripts = ['Tools/scripts/pydoc2.6',
380 +                     'Tools/scripts/2to3-2.6',
381 +                     'Lib/smtpd2.6.py']
382          )
384  # --install-platlib