summaryrefslogtreecommitdiff
path: root/package/python2
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2013-11-29 16:06:00 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2013-11-29 16:06:00 +0100
commit8e8512391c668fc7074f812f15eabe8f176fb01e (patch)
treef9f0862dd6eb962fe3fc4803180b431843f6c5be /package/python2
parentc491653a1f9574a42965025805d472c3d145f699 (diff)
parentae3d4616ed9c19a29d656193254657f93d612fa2 (diff)
Merge branch 'master' of git+ssh://openadk.org/git/openadk
Diffstat (limited to 'package/python2')
-rw-r--r--package/python2/Makefile159
-rw-r--r--package/python2/files/build_scripts.py99
-rw-r--r--package/python2/files/patch-Lib_distutils_sysconfig_py10
-rw-r--r--package/python2/files/patch-Misc_python-config_in21
-rw-r--r--package/python2/files/posixmodule.c9365
-rw-r--r--package/python2/files/python-config.in57
-rw-r--r--package/python2/files/setup.py2076
-rw-r--r--package/python2/files/sysconfig.py572
-rw-r--r--package/python2/patches/patch-Makefile_pre_in201
-rw-r--r--package/python2/patches/patch-configure26
-rw-r--r--package/python2/patches/patch-configure_ac22
-rw-r--r--package/python2/patches/patch-setup_py196
12 files changed, 308 insertions, 12496 deletions
diff --git a/package/python2/Makefile b/package/python2/Makefile
index 075920912..1fa0cce94 100644
--- a/package/python2/Makefile
+++ b/package/python2/Makefile
@@ -4,97 +4,126 @@
include ${TOPDIR}/rules.mk
PKG_NAME:= python2
-PKG_VERSION:= 2.7.1
-PKG_RELEASE:= 3
-PKG_MD5SUM:= 15ed56733655e3fab785e49a7278d2fb
+PKG_VERSION:= 2.7.5
+PKG_RELEASE:= 6
+PKG_MD5SUM:= b4f01a1d0ba0b46b05c73b2ac909b1df
PKG_DESCR:= Python scripting language (Version 2)
PKG_SECTION:= lang
-PKG_BUILDDEP:= zlib libffi openssl readline bzip2
-PKG_DEPENDS:= libpthread zlib libffi libopenssl libgcc
+PKG_BUILDDEP:= autotool libffi python2-host
+PKG_DEPENDS:= libpthread libffi libgcc
PKG_URL:= http://www.python.org/
PKG_SITES:= http://www.python.org/ftp/python/${PKG_VERSION}/
-PKG_OPTS:= noscripts
+PKG_OPTS:= dev noscripts
PKG_HOST_DEPENDS:= !netbsd !openbsd
DISTFILES= Python-${PKG_VERSION}.tgz
WRKDIST= ${WRKDIR}/Python-${PKG_VERSION}
-PKG_SUBPKGS:= PYTHON2 PYTHON2_READLINE PYTHON2_BZIP2
-PKGSS_PYTHON2_READLINE:=libreadline
-PKGSS_PYTHON2_BZIP2:= bzip2
+PKG_FLAVOURS_PYTHON2:= MOD_ZLIB MOD_BZ2 MOD_EXPAT MOD_SQLITE MOD_GDBM
+PKG_FLAVOURS_PYTHON2+= MOD_NCURSES MOD_SSL MOD_READLINE
+
+PKGFD_MOD_ZLIB:= ZLIB support
+PKGFB_MOD_ZLIB:= zlib
+PKGFS_MOD_ZLIB:= zlib
+PKGFD_MOD_BZ2:= BZIP2 support
+PKGFB_MOD_BZ2:= bzip2
+PKGFS_MOD_BZ2:= libbz2
+PKGFD_MOD_EXPAT:= XML support
+PKGFB_MOD_EXPAT:= expat
+PKGFS_MOD_EXPAT:= libexpat
+PKGFD_MOD_SQLITE:= SQLITE support
+PKGFB_MOD_SQLITE:= sqlite
+PKGFS_MOD_SQLITE:= libsqlite
+PKGFD_MOD_GDBM:= GDBM support
+PKGFB_MOD_GDBM:= gdbm
+PKGFS_MOD_GDBM:= libgdbm
+PKGFD_MOD_NCURSES:= NCURSES support
+PKGFB_MOD_NCURSES:= ncurses
+PKGFS_MOD_NCURSES:= libncurses
+PKGFD_MOD_READLINE:= READLINE support
+PKGFB_MOD_READLINE:= readline
+PKGFS_MOD_READLINE:= libreadline
+PKGFD_MOD_SSL:= OpenSSL support
+PKGFB_MOD_SSL:= openssl
+PKGFS_MOD_SSL:= libopenssl
+include ${TOPDIR}/mk/host.mk
include ${TOPDIR}/mk/package.mk
-$(eval $(call PKG_template,PYTHON2,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
-$(eval $(call PKG_template,PYTHON2_BZIP2,${PKG_NAME}-bzip2,${PKG_VERSION}-${PKG_RELEASE},${PKGSS_PYTHON2_BZIP2},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
-$(eval $(call PKG_template,PYTHON2_READLINE,${PKG_NAME}-readline,${PKG_VERSION}-${PKG_RELEASE},${PKGSS_PYTHON2_READLINE},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
-
-ifeq ($(ADK_HOST_CYGWIN),y)
-EXE:= .exe
-endif
-
-TARGET_CFLAGS+= -fPIC
-TARGET_LDFLAGS+= -L.
-MAKE_ENV+= OPT="$(TARGET_CFLAGS)" \
- RANLIB="${TARGET_CROSS}ranlib" \
- HOSTPYTHON=./hostpython \
- HOSTPGEN=./Parser/hostpgen
-CONFIGURE_ENV+= OPT="$(TARGET_CFLAGS)" \
- ac_cv_have_long_long_format=yes
+$(eval $(call HOST_template,PYTHON2,python2,${PKG_VERSION}-${PKG_RELEASE}))
+$(eval $(call PKG_template,PYTHON2,python2,${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
+
+define PKG_mod_template
+
+INSTALL_MODS_$${ADK_PACKAGE_${1}}+= ${2}-install
+
+${2}-install:
+ echo foo $(1)
+ ${INSTALL_DIR} $$(IDIR_$(1))/usr/lib/python2.7/lib-dynload
+ for m in ${2}; do \
+ ${INSTALL_DATA} $(WRKINST)/usr/lib/python2.7/lib-dynload/$$$${m}*.so $$(IDIR_$(1))/usr/lib/python2.7/lib-dynload ;\
+ done
+endef
+
+$(eval $(call PKG_template,PYTHON2_MOD_ZLIB,python2-mod-zlib,$(PKG_VERSION)-${PKG_RELEASE},${PKGFS_MOD_ZLIB},${PKGFD_MOD_ZLIB},${PKG_SECTION}))
+$(eval $(call PKG_template,PYTHON2_MOD_BZ2,python2-mod-bz2,$(PKG_VERSION)-${PKG_RELEASE},${PKGFS_MOD_BZ2},${PKGFD_MOD_BZ2},${PKG_SECTION}))
+$(eval $(call PKG_template,PYTHON2_MOD_EXPAT,python2-mod-expat,$(PKG_VERSION)-${PKG_RELEASE},${PKGFS_MOD_EXPAT},${PKGFD_MOD_EXPAT},${PKG_SECTION}))
+$(eval $(call PKG_template,PYTHON2_MOD_SQLITE,python2-mod-sqlite,$(PKG_VERSION)-${PKG_RELEASE},${PKGFS_MOD_SQLITE},${PKGFD_MOD_SQLITE},${PKG_SECTION}))
+$(eval $(call PKG_template,PYTHON2_MOD_GDBM,python2-mod-gdbm,$(PKG_VERSION)-${PKG_RELEASE},${PKGFS_MOD_GDBM},${PKGFD_MOD_GDBM},${PKG_SECTION}))
+$(eval $(call PKG_template,PYTHON2_MOD_NCURSES,python2-mod-ncurses,$(PKG_VERSION)-${PKG_RELEASE},${PKGFS_MOD_NCURSES},${PKGFD_MOD_NCURSES},${PKG_SECTION}))
+$(eval $(call PKG_template,PYTHON2_MOD_SSL,python2-mod-ssl,$(PKG_VERSION)-${PKG_RELEASE},${PKGFS_MOD_SSL},${PKGFD_MOD_SSL},${PKG_SECTION}))
+$(eval $(call PKG_template,PYTHON2_MOD_READLINE,python2-mod-readline,$(PKG_VERSION)-${PKG_RELEASE},${PKGFS_MOD_READLINE},${PKGFD_MOD_READLINE},${PKG_SECTION}))
+
+$(eval $(call PKG_mod_template,PYTHON2_MOD_ZLIB,zlib))
+$(eval $(call PKG_mod_template,PYTHON2_MOD_BZ2,bz2))
+$(eval $(call PKG_mod_template,PYTHON2_MOD_EXPAT,pyexpat))
+$(eval $(call PKG_mod_template,PYTHON2_MOD_SQLITE,_sqlite))
+$(eval $(call PKG_mod_template,PYTHON2_MOD_GDBM,gdbm))
+$(eval $(call PKG_mod_template,PYTHON2_MOD_NCURSES,_curses))
+$(eval $(call PKG_mod_template,PYTHON2_MOD_SSL,_ssl))
+$(eval $(call PKG_mod_template,PYTHON2_MOD_READLINE,readline))
+
+AUTOTOOL_STYLE:= autoreconf
+MAKE_ENV+= HOSTPGEN=$(STAGING_HOST_DIR)/usr/bin/pgen
+CONFIGURE_ENV+= ac_cv_have_long_long_format=yes \
+ ac_cv_file__dev_ptmx=yes \
+ ac_cv_file__dev_ptc=no
CONFIGURE_ARGS:= --with-threads \
+ --disable-ipv6 \
--disable-toolbox-glue \
--with-system-ffi \
--without-cxx-main
-post-extract:
- $(CP) ${WRKBUILD}/setup.py ${WRKBUILD}/setup.py.sav
- $(CP) ./files/setup.py ${WRKBUILD}/setup.py
- $(CP) ./files/posixmodule.c ${WRKBUILD}/Modules/posixmodule.c
- $(CP) ./files/python-config.in ${WRKBUILD}/Misc/python-config.in
- $(CP) ./files/build_scripts.py ${WRKBUILD}/Lib/distutils/command/build_scripts.py
- $(CP) ./files/sysconfig.py ${WRKBUILD}/Lib/distutils/sysconfig.py
- (cd ${WRKBUILD}; rm -rf config.{cache,status} ; \
- OPT="$(CFLAGS_FOR_BUILD)" \
- ./configure --without-cxx-main --with-threads \
- --prefix=$(STAGING_HOST_DIR)/usr \
- );
- $(MAKE) -C ${WRKBUILD} python$(EXE) Parser/pgen$(EXE)
- $(MAKE) -C ${WRKBUILD} install
- ${CP} ${WRKBUILD}/Parser/pgen ${STAGING_HOST_DIR}/usr/bin/pgen
- ${CP} ${WRKBUILD}/python ${STAGING_HOST_DIR}/usr/bin/hostpython
- ${CP} ${WRKBUILD}/Parser/pgen ${WRKBUILD}/Parser/hostpgen
- ${CP} ${WRKBUILD}/python ${WRKBUILD}/hostpython
- $(MAKE) -C ${WRKBUILD} distclean
- $(CP) ${WRKBUILD}/setup.py.sav ${WRKBUILD}/setup.py
+HOST_STYLE:= auto
+HOST_CONFIGURE_ARGS:= --with-threads \
+ --disable-toolbox-glue \
+ --without-cxx-main
+
+hostpost-install:
+ $(INSTALL_BIN) ${WRKBUILD}/Parser/pgen \
+ $(STAGING_HOST_DIR)/usr/bin/pgen
pre-configure:
- $(SED) "s#@@CPU_ARCH@@#$(CPU_ARCH)#" ${WRKBUILD}/configure
- $(SED) "s#@@STAGING_DIR@@#$(STAGING_DIR)#" ${WRKBUILD}/setup.py
+ (cd $(WRKBUILD) && patch -p1 < \
+ $(TOPDIR)/package/python2/files/patch-Lib_distutils_sysconfig_py )
+ (cd $(WRKBUILD) && patch -p1 < \
+ $(TOPDIR)/package/python2/files/patch-Misc_python-config_in )
+ $(SED) "s#@EXENAME@#$(STAGING_HOST_DIR)/usr/bin/python#" \
+ $(WRKBUILD)/Misc/python-config.in
-post-install:
+python2-install: ${INSTALL_MODS_y} ${INSTALL_MODS_m}
${INSTALL_DIR} ${IDIR_PYTHON2}/usr/bin ${IDIR_PYTHON2}/usr/lib
${INSTALL_DIR} ${IDIR_PYTHON2}/usr/lib/python2.7
${INSTALL_DIR} ${IDIR_PYTHON2}/usr/include/python2.7
${INSTALL_BIN} ${WRKINST}/usr/bin/python ${IDIR_PYTHON2}/usr/bin
${CP} ${WRKINST}/usr/lib/libpython*.so* ${IDIR_PYTHON2}/usr/lib
${CP} ${WRKINST}/usr/lib/python2.7/* ${IDIR_PYTHON2}/usr/lib/python2.7
- ${CP} ${WRKINST}/usr/include/python2.7/* ${IDIR_PYTHON2}/usr/include/python2.7
- -find ${IDIR_PYTHON2} -name "\*.pyc" -o -name "*\.pyo" -exec rm {} \;
- -rm ${IDIR_PYTHON2}/usr/lib/python2.7/lib-dynload/readline.so
- -rm ${IDIR_PYTHON2}/usr/lib/python2.7/lib-dynload/bz2.so
- # workaround, copy host python-config to target scripts directory
- ${CP} ${STAGING_HOST_DIR}/usr/bin/python*-config ${STAGING_DIR}/scripts
- (cd ${STAGING_DIR}/usr/bin/ && ln -sf $(STAGING_HOST_DIR)/usr/bin/hostpython hostpython)
-
-python2-readline-install:
- ${INSTALL_DIR} ${IDIR_PYTHON2_READLINE}/usr/lib/python2.7/lib-dynload
- ${CP} ${WRKINST}/usr/lib/python2.7/lib-dynload/readline.so \
- ${IDIR_PYTHON2_READLINE}/usr/lib/python2.7/lib-dynload
-
-python2-bzip2-install:
- ${INSTALL_DIR} ${IDIR_PYTHON2_BZIP2}/usr/lib/python2.7/lib-dynload
- ${CP} ${WRKINST}/usr/lib/python2.7/lib-dynload/bz2.so \
- ${IDIR_PYTHON2_BZIP2}/usr/lib/python2.7/lib-dynload
+ ${CP} ${WRKINST}/usr/include/python2.7/pyconfig.h \
+ ${IDIR_PYTHON2}/usr/include/python2.7
+ @-for i in zlib bz2 _curses _ssl gdbm _sqlite pyexpat readline; do \
+ rm ${IDIR_PYTHON2}/usr/lib/python2.7/lib-dynload/$${i}*so; \
+ done
+include ${TOPDIR}/mk/host-bottom.mk
include ${TOPDIR}/mk/pkg-bottom.mk
diff --git a/package/python2/files/build_scripts.py b/package/python2/files/build_scripts.py
deleted file mode 100644
index fe81a5341..000000000
--- a/package/python2/files/build_scripts.py
+++ /dev/null
@@ -1,99 +0,0 @@
-"""distutils.command.build_scripts
-
-Implements the Distutils 'build_scripts' command."""
-
-__revision__ = "$Id: build_scripts.py 77704 2010-01-23 09:23:15Z tarek.ziade $"
-
-import os, re
-from stat import ST_MODE
-from distutils.core import Command
-from distutils.dep_util import newer
-from distutils.util import convert_path
-from distutils import log
-
-# check if Python is called on the first line with this expression
-first_line_re = re.compile('^#!.*python[0-9.]*([ \t].*)?$')
-
-class build_scripts (Command):
-
- description = "\"build\" scripts (copy and fixup #! line)"
-
- user_options = [
- ('build-dir=', 'd', "directory to \"build\" (copy) to"),
- ('force', 'f', "forcibly build everything (ignore file timestamps"),
- ('executable=', 'e', "specify final destination interpreter path"),
- ]
-
- boolean_options = ['force']
-
-
- def initialize_options (self):
- self.build_dir = None
- self.scripts = None
- self.force = None
- self.executable = None
- self.outfiles = None
-
- def finalize_options (self):
- self.set_undefined_options('build',
- ('build_scripts', 'build_dir'),
- ('force', 'force'),
- ('executable', 'executable'))
- self.scripts = self.distribution.scripts
-
- def get_source_files(self):
- return self.scripts
-
- def run (self):
- if not self.scripts:
- return
- self.copy_scripts()
-
-
- def copy_scripts (self):
- """Copy each script listed in 'self.scripts'; if it's marked as a
- Python script in the Unix way (first line matches 'first_line_re',
- ie. starts with "\#!" and contains "python"), then adjust the first
- line to refer to the current Python interpreter as we copy.
- """
- _sysconfig = __import__('sysconfig')
- self.mkpath(self.build_dir)
- outfiles = []
- for script in self.scripts:
- adjust = 0
- script = convert_path(script)
- outfile = os.path.join(self.build_dir, os.path.basename(script))
- outfiles.append(outfile)
-
- if not self.force and not newer(script, outfile):
- log.debug("not copying %s (up-to-date)", script)
- continue
-
- # Always open the file, but ignore failures in dry-run mode --
- # that way, we'll get accurate feedback if we can read the
- # script.
- try:
- f = open(script, "r")
- except IOError:
- if not self.dry_run:
- raise
- f = None
- if f:
- f.close()
- self.copy_file(script, outfile)
-
- if os.name == 'posix':
- for file in outfiles:
- if self.dry_run:
- log.info("changing mode of %s", file)
- else:
- oldmode = os.stat(file)[ST_MODE] & 07777
- newmode = (oldmode | 0555) & 07777
- if newmode != oldmode:
- log.info("changing mode of %s from %o to %o",
- file, oldmode, newmode)
- os.chmod(file, newmode)
-
- # copy_scripts ()
-
-# class build_scripts
diff --git a/package/python2/files/patch-Lib_distutils_sysconfig_py b/package/python2/files/patch-Lib_distutils_sysconfig_py
new file mode 100644
index 000000000..30aae0816
--- /dev/null
+++ b/package/python2/files/patch-Lib_distutils_sysconfig_py
@@ -0,0 +1,10 @@
+--- Python-2.7.5.orig/Lib/distutils/sysconfig.py 2013-05-12 05:32:42.000000000 +0200
++++ Python-2.7.5/Lib/distutils/sysconfig.py 2013-11-03 18:03:53.000000000 +0100
+@@ -76,6 +76,7 @@ def get_python_inc(plat_specific=0, pref
+ """
+ if prefix is None:
+ prefix = plat_specific and EXEC_PREFIX or PREFIX
++ prefix = re.sub('host_', 'target_', prefix)
+
+ if os.name == "posix":
+ if python_build:
diff --git a/package/python2/files/patch-Misc_python-config_in b/package/python2/files/patch-Misc_python-config_in
new file mode 100644
index 000000000..9734d4fbd
--- /dev/null
+++ b/package/python2/files/patch-Misc_python-config_in
@@ -0,0 +1,21 @@
+--- Python-2.7.5.orig/Misc/python-config.in 2013-05-12 05:32:49.000000000 +0200
++++ Python-2.7.5/Misc/python-config.in 2013-10-30 21:29:47.000000000 +0100
+@@ -3,6 +3,7 @@
+ import sys
+ import os
+ import getopt
++import re
+ from distutils import sysconfig
+
+ valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
+@@ -37,8 +38,8 @@ for opt in opt_flags:
+ print sysconfig.EXEC_PREFIX
+
+ elif opt in ('--includes', '--cflags'):
+- flags = ['-I' + sysconfig.get_python_inc(),
+- '-I' + sysconfig.get_python_inc(plat_specific=True)]
++ flags = ['-I' + re.sub('host_', 'target_', sysconfig.get_python_inc()),
++ '-I' + re.sub('host_', 'target_', sysconfig.get_python_inc(plat_specific=True))]
+ if opt == '--cflags':
+ flags.extend(getvar('CFLAGS').split())
+ print ' '.join(flags)
diff --git a/package/python2/files/posixmodule.c b/package/python2/files/posixmodule.c
deleted file mode 100644
index 312861b65..000000000
--- a/package/python2/files/posixmodule.c
+++ /dev/null
@@ -1,9365 +0,0 @@
-
-/* POSIX module implementation */
-
-/* This file is also used for Windows NT/MS-Win and OS/2. In that case the
- module actually calls itself 'nt' or 'os2', not 'posix', and a few
- functions are either unimplemented or implemented differently. The source
- assumes that for Windows NT, the macro 'MS_WINDOWS' is defined independent
- of the compiler used. Different compilers define their own feature
- test macro, e.g. '__BORLANDC__' or '_MSC_VER'. For OS/2, the compiler
- independent macro PYOS_OS2 should be defined. On OS/2 the default
- compiler is assumed to be IBM's VisualAge C++ (VACPP). PYCC_GCC is used
- as the compiler specific macro for the EMX port of gcc to OS/2. */
-
-/* See also ../Dos/dosmodule.c */
-
-#ifdef __APPLE__
- /*
- * Step 1 of support for weak-linking a number of symbols existing on
- * OSX 10.4 and later, see the comment in the #ifdef __APPLE__ block
- * at the end of this file for more information.
- */
-# pragma weak lchown
-# pragma weak statvfs
-# pragma weak fstatvfs
-
-#endif /* __APPLE__ */
-
-#define PY_SSIZE_T_CLEAN
-
-#include "Python.h"
-#include "structseq.h"
-
-#if defined(__VMS)
-# include <unixio.h>
-#endif /* defined(__VMS) */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-PyDoc_STRVAR(posix__doc__,
-"This module provides access to operating system functionality that is\n\
-standardized by the C Standard and the POSIX standard (a thinly\n\
-disguised Unix interface). Refer to the library manual and\n\
-corresponding Unix manual entries for more information on calls.");
-
-#ifndef Py_USING_UNICODE
-/* This is used in signatures of functions. */
-#define Py_UNICODE void
-#endif
-
-#if defined(PYOS_OS2)
-#define INCL_DOS
-#define INCL_DOSERRORS
-#define INCL_DOSPROCESS
-#define INCL_NOPMAPI
-#include <os2.h>
-#if defined(PYCC_GCC)
-#include <ctype.h>
-#include <io.h>
-#include <stdio.h>
-#include <process.h>
-#endif
-#include "osdefs.h"
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif /* HAVE_SYS_TYPES_H */
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif /* HAVE_SYS_STAT_H */
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h> /* For WNOHANG */
-#endif
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
-
-#ifdef HAVE_GRP_H
-#include <grp.h>
-#endif
-
-#ifdef HAVE_SYSEXITS_H
-#include <sysexits.h>
-#endif /* HAVE_SYSEXITS_H */
-
-#ifdef HAVE_SYS_LOADAVG_H
-#include <sys/loadavg.h>
-#endif
-
-/* Various compilers have only certain posix functions */
-/* XXX Gosh I wish these were all moved into pyconfig.h */
-#if defined(PYCC_VACPP) && defined(PYOS_OS2)
-#include <process.h>
-#else
-#if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */
-#define HAVE_GETCWD 1
-#define HAVE_OPENDIR 1
-#define HAVE_SYSTEM 1
-#if defined(__OS2__)
-#define HAVE_EXECV 1
-#define HAVE_WAIT 1
-#endif
-#include <process.h>
-#else
-#ifdef __BORLANDC__ /* Borland compiler */
-#define HAVE_EXECV 1
-#define HAVE_GETCWD 1
-#define HAVE_OPENDIR 1
-#define HAVE_PIPE 1
-#define HAVE_POPEN 1
-#define HAVE_SYSTEM 1
-#define HAVE_WAIT 1
-#else
-#ifdef _MSC_VER /* Microsoft compiler */
-#define HAVE_GETCWD 1
-#define HAVE_SPAWNV 1
-#define HAVE_EXECV 1
-#define HAVE_PIPE 1
-#define HAVE_POPEN 1
-#define HAVE_SYSTEM 1
-#define HAVE_CWAIT 1
-#define HAVE_FSYNC 1
-#define fsync _commit
-#else
-#if defined(PYOS_OS2) && defined(PYCC_GCC) || defined(__VMS)
-/* Everything needed is defined in PC/os2emx/pyconfig.h or vms/pyconfig.h */
-#else /* all other compilers */
-/* Unix functions that the configure script doesn't check for */
-#define HAVE_EXECV 1
-#define HAVE_FORK 1
-#if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */
-#define HAVE_FORK1 1
-#endif
-#define HAVE_GETCWD 1
-#define HAVE_GETEGID 1
-#define HAVE_GETEUID 1
-#define HAVE_GETGID 1
-#define HAVE_GETPPID 1
-#define HAVE_GETUID 1
-#define HAVE_KILL 1
-#define HAVE_OPENDIR 1
-#define HAVE_PIPE 1
-#ifndef __rtems__
-#define HAVE_POPEN 1
-#endif
-#define HAVE_SYSTEM 1
-#define HAVE_WAIT 1
-#define HAVE_TTYNAME 1
-#endif /* PYOS_OS2 && PYCC_GCC && __VMS */
-#endif /* _MSC_VER */
-#endif /* __BORLANDC__ */
-#endif /* ! __WATCOMC__ || __QNX__ */
-#endif /* ! __IBMC__ */
-
-#ifndef _MSC_VER
-
-#if defined(__sgi)&&_COMPILER_VERSION>=700
-/* declare ctermid_r if compiling with MIPSPro 7.x in ANSI C mode
- (default) */
-extern char *ctermid_r(char *);
-#endif
-
-#ifndef HAVE_UNISTD_H
-#if defined(PYCC_VACPP)
-extern int mkdir(char *);
-#else
-#if ( defined(__WATCOMC__) || defined(_MSC_VER) ) && !defined(__QNX__)
-extern int mkdir(const char *);
-#else
-extern int mkdir(const char *, mode_t);
-#endif
-#endif
-#if defined(__IBMC__) || defined(__IBMCPP__)
-extern int chdir(char *);
-extern int rmdir(char *);
-#else
-extern int chdir(const char *);
-extern int rmdir(const char *);
-#endif
-#ifdef __BORLANDC__
-extern int chmod(const char *, int);
-#else
-extern int chmod(const char *, mode_t);
-#endif
-/*#ifdef HAVE_FCHMOD
-extern int fchmod(int, mode_t);
-#endif*/
-/*#ifdef HAVE_LCHMOD
-extern int lchmod(const char *, mode_t);
-#endif*/
-extern int chown(const char *, uid_t, gid_t);
-extern char *getcwd(char *, int);
-extern char *strerror(int);
-extern int link(const char *, const char *);
-extern int rename(const char *, const char *);
-extern int stat(const char *, struct stat *);
-extern int unlink(const char *);
-extern int pclose(FILE *);
-#ifdef HAVE_SYMLINK
-extern int symlink(const char *, const char *);
-#endif /* HAVE_SYMLINK */
-#ifdef HAVE_LSTAT
-extern int lstat(const char *, struct stat *);
-#endif /* HAVE_LSTAT */
-#endif /* !HAVE_UNISTD_H */
-
-#endif /* !_MSC_VER */
-
-#ifdef HAVE_UTIME_H
-#include <utime.h>
-#endif /* HAVE_UTIME_H */
-
-#ifdef HAVE_SYS_UTIME_H
-#include <sys/utime.h>
-#define HAVE_UTIME_H /* pretend we do for the rest of this file */
-#endif /* HAVE_SYS_UTIME_H */
-
-#ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#endif /* HAVE_SYS_TIMES_H */
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif /* HAVE_SYS_PARAM_H */
-
-#ifdef HAVE_SYS_UTSNAME_H
-#include <sys/utsname.h>
-#endif /* HAVE_SYS_UTSNAME_H */
-
-#ifdef HAVE_DIRENT_H
-#include <dirent.h>
-#define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-#if defined(__WATCOMC__) && !defined(__QNX__)
-#include <direct.h>
-#define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-#define dirent direct
-#define NAMLEN(dirent) (dirent)->d_namlen
-#endif
-#ifdef HAVE_SYS_NDIR_H
-#include <sys/ndir.h>
-#endif
-#ifdef HAVE_SYS_DIR_H
-#include <sys/dir.h>
-#endif
-#ifdef HAVE_NDIR_H
-#include <ndir.h>
-#endif
-#endif
-
-#ifdef _MSC_VER
-#ifdef HAVE_DIRECT_H
-#include <direct.h>
-#endif
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-#ifdef HAVE_PROCESS_H
-#include <process.h>
-#endif
-#include "osdefs.h"
-#include <malloc.h>
-#include <windows.h>
-#include <shellapi.h> /* for ShellExecute() */
-#define popen _popen
-#define pclose _pclose
-#endif /* _MSC_VER */
-
-#if defined(PYCC_VACPP) && defined(PYOS_OS2)
-#include <io.h>
-#endif /* OS2 */
-
-#ifndef MAXPATHLEN
-#if defined(PATH_MAX) && PATH_MAX > 1024
-#define MAXPATHLEN PATH_MAX
-#else
-#define MAXPATHLEN 1024
-#endif
-#endif /* MAXPATHLEN */
-
-#ifdef UNION_WAIT
-/* Emulate some macros on systems that have a union instead of macros */
-
-#ifndef WIFEXITED
-#define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump)
-#endif
-
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1)
-#endif
-
-#ifndef WTERMSIG
-#define WTERMSIG(u_wait) ((u_wait).w_termsig)
-#endif
-
-#define WAIT_TYPE union wait
-#define WAIT_STATUS_INT(s) (s.w_status)
-
-#else /* !UNION_WAIT */
-#define WAIT_TYPE int
-#define WAIT_STATUS_INT(s) (s)
-#endif /* UNION_WAIT */
-
-/* Issue #1983: pid_t can be longer than a C long on some systems */
-#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT
-#define PARSE_PID "i"
-#define PyLong_FromPid PyInt_FromLong
-#define PyLong_AsPid PyInt_AsLong
-#elif SIZEOF_PID_T == SIZEOF_LONG
-#define PARSE_PID "l"
-#define PyLong_FromPid PyInt_FromLong
-#define PyLong_AsPid PyInt_AsLong
-#elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG
-#define PARSE_PID "L"
-#define PyLong_FromPid PyLong_FromLongLong
-#define PyLong_AsPid PyInt_AsLongLong
-#else
-#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)"
-#endif /* SIZEOF_PID_T */
-
-/* Don't use the "_r" form if we don't need it (also, won't have a
- prototype for it, at least on Solaris -- maybe others as well?). */
-#if defined(HAVE_CTERMID_R) && defined(WITH_THREAD)
-#define USE_CTERMID_R
-#endif
-
-#if defined(HAVE_TMPNAM_R) && defined(WITH_THREAD)
-#define USE_TMPNAM_R
-#endif
-
-/* choose the appropriate stat and fstat functions and return structs */
-#undef STAT
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
-# define STAT win32_stat
-# define FSTAT win32_fstat
-# define STRUCT_STAT struct win32_stat
-#else
-# define STAT stat
-# define FSTAT fstat
-# define STRUCT_STAT struct stat
-#endif
-
-#if defined(MAJOR_IN_MKDEV)
-#include <sys/mkdev.h>
-#else
-#if defined(MAJOR_IN_SYSMACROS)
-#include <sys/sysmacros.h>
-#endif
-#if defined(HAVE_MKNOD) && defined(HAVE_SYS_MKDEV_H)
-#include <sys/mkdev.h>
-#endif
-#endif
-
-#if defined _MSC_VER && _MSC_VER >= 1400
-/* Microsoft CRT in VS2005 and higher will verify that a filehandle is
- * valid and throw an assertion if it isn't.
- * Normally, an invalid fd is likely to be a C program error and therefore
- * an assertion can be useful, but it does contradict the POSIX standard
- * which for write(2) states:
- * "Otherwise, -1 shall be returned and errno set to indicate the error."
- * "[EBADF] The fildes argument is not a valid file descriptor open for
- * writing."
- * Furthermore, python allows the user to enter any old integer
- * as a fd and should merely raise a python exception on error.
- * The Microsoft CRT doesn't provide an official way to check for the
- * validity of a file descriptor, but we can emulate its internal behaviour
- * by using the exported __pinfo data member and knowledge of the
- * internal structures involved.
- * The structures below must be updated for each version of visual studio
- * according to the file internal.h in the CRT source, until MS comes
- * up with a less hacky way to do this.
- * (all of this is to avoid globally modifying the CRT behaviour using
- * _set_invalid_parameter_handler() and _CrtSetReportMode())
- */
-/* The actual size of the structure is determined at runtime.
- * Only the first items must be present.
- */
-typedef struct {
- intptr_t osfhnd;
- char osfile;
-} my_ioinfo;
-
-extern __declspec(dllimport) char * __pioinfo[];
-#define IOINFO_L2E 5
-#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
-#define IOINFO_ARRAYS 64
-#define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
-#define FOPEN 0x01
-#define _NO_CONSOLE_FILENO (intptr_t)-2
-
-/* This function emulates what the windows CRT does to validate file handles */
-int
-_PyVerify_fd(int fd)
-{
- const int i1 = fd >> IOINFO_L2E;
- const int i2 = fd & ((1 << IOINFO_L2E) - 1);
-
- static int sizeof_ioinfo = 0;
-
- /* Determine the actual size of the ioinfo structure,
- * as used by the CRT loaded in memory
- */
- if (sizeof_ioinfo == 0 && __pioinfo[0] != NULL) {
- sizeof_ioinfo = _msize(__pioinfo[0]) / IOINFO_ARRAY_ELTS;
- }
- if (sizeof_ioinfo == 0) {
- /* This should not happen... */
- goto fail;
- }
-
- /* See that it isn't a special CLEAR fileno */
- if (fd != _NO_CONSOLE_FILENO) {
- /* Microsoft CRT would check that 0<=fd<_nhandle but we can't do that. Instead
- * we check pointer validity and other info
- */
- if (0 <= i1 && i1 < IOINFO_ARRAYS && __pioinfo[i1] != NULL) {
- /* finally, check that the file is open */
- my_ioinfo* info = (my_ioinfo*)(__pioinfo[i1] + i2 * sizeof_ioinfo);
- if (info->osfile & FOPEN) {
- return 1;
- }
- }
- }
- fail:
- errno = EBADF;
- return 0;
-}
-
-/* the special case of checking dup2. The target fd must be in a sensible range */
-static int
-_PyVerify_fd_dup2(int fd1, int fd2)
-{
- if (!_PyVerify_fd(fd1))
- return 0;
- if (fd2 == _NO_CONSOLE_FILENO)
- return 0;
- if ((unsigned)fd2 < _NHANDLE_)
- return 1;
- else
- return 0;
-}
-#else
-/* dummy version. _PyVerify_fd() is already defined in fileobject.h */
-#define _PyVerify_fd_dup2(A, B) (1)
-#endif
-
-/* Return a dictionary corresponding to the POSIX environment table */
-#ifdef WITH_NEXT_FRAMEWORK
-/* On Darwin/MacOSX a shared library or framework has no access to
-** environ directly, we must obtain it with _NSGetEnviron().
-*/
-#include <crt_externs.h>
-static char **environ;
-#elif !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
-extern char **environ;
-#endif /* !_MSC_VER */
-
-static PyObject *
-convertenviron(void)
-{
- PyObject *d;
- char **e;
-#if defined(PYOS_OS2)
- APIRET rc;
- char buffer[1024]; /* OS/2 Provides a Documented Max of 1024 Chars */
-#endif
- d = PyDict_New();
- if (d == NULL)
- return NULL;
-#ifdef WITH_NEXT_FRAMEWORK
- if (environ == NULL)
- environ = *_NSGetEnviron();
-#endif
- if (environ == NULL)
- return d;
- /* This part ignores errors */
- for (e = environ; *e != NULL; e++) {
- PyObject *k;
- PyObject *v;
- char *p = strchr(*e, '=');
- if (p == NULL)
- continue;
- k = PyString_FromStringAndSize(*e, (int)(p-*e));
- if (k == NULL) {
- PyErr_Clear();
- continue;
- }
- v = PyString_FromString(p+1);
- if (v == NULL) {
- PyErr_Clear();
- Py_DECREF(k);
- continue;
- }
- if (PyDict_GetItem(d, k) == NULL) {
- if (PyDict_SetItem(d, k, v) != 0)
- PyErr_Clear();
- }
- Py_DECREF(k);
- Py_DECREF(v);
- }
-#if defined(PYOS_OS2)
- rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH);
- if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */
- PyObject *v = PyString_FromString(buffer);
- PyDict_SetItemString(d, "BEGINLIBPATH", v);
- Py_DECREF(v);
- }
- rc = DosQueryExtLIBPATH(buffer, END_LIBPATH);
- if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'END_LIBPATH') */
- PyObject *v = PyString_FromString(buffer);
- PyDict_SetItemString(d, "ENDLIBPATH", v);
- Py_DECREF(v);
- }
-#endif
- return d;
-}
-
-
-/* Set a POSIX-specific error from errno, and return NULL */
-
-static PyObject *
-posix_error(void)
-{
- return PyErr_SetFromErrno(PyExc_OSError);
-}
-static PyObject *
-posix_error_with_filename(char* name)
-{
- return PyErr_SetFromErrnoWithFilename(PyExc_OSError, name);
-}
-
-#ifdef MS_WINDOWS
-static PyObject *
-posix_error_with_unicode_filename(Py_UNICODE* name)
-{
- return PyErr_SetFromErrnoWithUnicodeFilename(PyExc_OSError, name);
-}
-#endif /* MS_WINDOWS */
-
-
-static PyObject *
-posix_error_with_allocated_filename(char* name)
-{
- PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, name);
- PyMem_Free(name);
- return rc;
-}
-
-#ifdef MS_WINDOWS
-static PyObject *
-win32_error(char* function, char* filename)
-{
- /* XXX We should pass the function name along in the future.
- (_winreg.c also wants to pass the function name.)
- This would however require an additional param to the
- Windows error object, which is non-trivial.
- */
- errno = GetLastError();
- if (filename)
- return PyErr_SetFromWindowsErrWithFilename(errno, filename);
- else
- return PyErr_SetFromWindowsErr(errno);
-}
-
-static PyObject *
-win32_error_unicode(char* function, Py_UNICODE* filename)
-{
- /* XXX - see win32_error for comments on 'function' */
- errno = GetLastError();
- if (filename)
- return PyErr_SetFromWindowsErrWithUnicodeFilename(errno, filename);
- else
- return PyErr_SetFromWindowsErr(errno);
-}
-
-static int
-convert_to_unicode(PyObject **param)
-{
- if (PyUnicode_CheckExact(*param))
- Py_INCREF(*param);
- else if (PyUnicode_Check(*param))
- /* For a Unicode subtype that's not a Unicode object,
- return a true Unicode object with the same data. */
- *param = PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(*param),
- PyUnicode_GET_SIZE(*param));
- else
- *param = PyUnicode_FromEncodedObject(*param,
- Py_FileSystemDefaultEncoding,
- "strict");
- return (*param) != NULL;
-}
-
-#endif /* MS_WINDOWS */
-
-#if defined(PYOS_OS2)
-/**********************************************************************
- * Helper Function to Trim and Format OS/2 Messages
- **********************************************************************/
-static void
-os2_formatmsg(char *msgbuf, int msglen, char *reason)
-{