#16135: Removal of OS/2 support (posixmodule y platform dependent files)

This commit is contained in:
Jesus Cea 2012-10-05 01:48:08 +02:00
parent f6c2e894ae
commit ab70e2ab32
20 changed files with 9 additions and 8549 deletions

View File

@ -22,15 +22,11 @@
#include <crtdbg.h>
#endif
#if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS)
#if defined(MS_WINDOWS)
#define PYTHONHOMEHELP "<prefix>\\lib"
#else
#if defined(PYOS_OS2) && defined(PYCC_GCC)
#define PYTHONHOMEHELP "<prefix>/Lib"
#else
#define PYTHONHOMEHELP "<prefix>/pythonX.X"
#endif
#endif
#include "pygetopt.h"

View File

@ -1,15 +1,12 @@
/* 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
/* This file is also used for Windows NT/MS-Win. In that case the
module actually calls itself 'nt', 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. */
test macro, e.g. '__BORLANDC__' or '_MSC_VER'. */
#ifdef __APPLE__
/*
@ -43,22 +40,6 @@ disguised Unix interface). Refer to the library manual and\n\
corresponding Unix manual entries for more information on calls.");
#if defined(PYOS_OS2)
#error "PEP 11: OS/2 is now unsupported, code will be removed in Python 3.4"
#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_UIO_H
#include <sys/uio.h>
#endif
@ -143,17 +124,10 @@ corresponding Unix manual entries for more information on calls.");
/* 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 */
@ -176,8 +150,8 @@ corresponding Unix manual entries for more information on calls.");
#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 */
#if defined(__VMS)
/* Everything needed is defined in vms/pyconfig.h */
#else /* all other compilers */
/* Unix functions that the configure script doesn't check for */
#define HAVE_EXECV 1
@ -197,11 +171,10 @@ corresponding Unix manual entries for more information on calls.");
#define HAVE_SYSTEM 1
#define HAVE_WAIT 1
#define HAVE_TTYNAME 1
#endif /* PYOS_OS2 && PYCC_GCC && __VMS */
#endif /* __VMS */
#endif /* _MSC_VER */
#endif /* __BORLANDC__ */
#endif /* ! __WATCOMC__ || __QNX__ */
#endif /* ! __IBMC__ */
@ -332,10 +305,6 @@ static int win32_can_symlink = 0;
#endif
#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
@ -970,10 +939,6 @@ convertenviron(void)
#else
char **e;
#endif
#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)
@ -1041,20 +1006,6 @@ convertenviron(void)
Py_DECREF(k);
Py_DECREF(v);
}
#endif
#if defined(PYOS_OS2)
rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH);
if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */
PyObject *v = PyBytes_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 = PyBytes_FromString(buffer);
PyDict_SetItemString(d, "ENDLIBPATH", v);
Py_DECREF(v);
}
#endif
return d;
}
@ -1155,83 +1106,6 @@ path_error(char *function_name, path_t *path)
#endif
}
#if defined(PYOS_OS2)
/**********************************************************************
* Helper Function to Trim and Format OS/2 Messages
**********************************************************************/
static void
os2_formatmsg(char *msgbuf, int msglen, char *reason)
{
msgbuf[msglen] = '\0'; /* OS/2 Doesn't Guarantee a Terminator */
if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */
char *lastc = &msgbuf[ strlen(msgbuf)-1 ];
while (lastc > msgbuf && isspace(Py_CHARMASK(*lastc)))
*lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */
}
/* Add Optional Reason Text */
if (reason) {
strcat(msgbuf, " : ");
strcat(msgbuf, reason);
}
}
/**********************************************************************
* Decode an OS/2 Operating System Error Code
*
* A convenience function to lookup an OS/2 error code and return a
* text message we can use to raise a Python exception.
*
* Notes:
* The messages for errors returned from the OS/2 kernel reside in
* the file OSO001.MSG in the \OS2 directory hierarchy.
*
**********************************************************************/
static char *
os2_strerror(char *msgbuf, int msgbuflen, int errorcode, char *reason)
{
APIRET rc;
ULONG msglen;
/* Retrieve Kernel-Related Error Message from OSO001.MSG File */
Py_BEGIN_ALLOW_THREADS
rc = DosGetMessage(NULL, 0, msgbuf, msgbuflen,
errorcode, "oso001.msg", &msglen);
Py_END_ALLOW_THREADS
if (rc == NO_ERROR)
os2_formatmsg(msgbuf, msglen, reason);
else
PyOS_snprintf(msgbuf, msgbuflen,
"unknown OS error #%d", errorcode);
return msgbuf;
}
/* Set an OS/2-specific error and return NULL. OS/2 kernel
errors are not in a global variable e.g. 'errno' nor are
they congruent with posix error numbers. */
static PyObject *
os2_error(int code)
{
char text[1024];
PyObject *v;
os2_strerror(text, sizeof(text), code, "");
v = Py_BuildValue("(is)", code, text);
if (v != NULL) {
PyErr_SetObject(PyExc_OSError, v);
Py_DECREF(v);
}
return NULL; /* Signal to Python that an Exception is Pending */
}
#endif /* OS2 */
/* POSIX generic methods */
static PyObject *
@ -2569,8 +2443,6 @@ posix_chdir(PyObject *self, PyObject *args, PyObject *kwargs)
else
result = win32_chdir(path.narrow);
result = !result; /* on unix, success = 0, on windows, success = !0 */
#elif defined(PYOS_OS2) && defined(PYCC_GCC)
result = _chdir2(path.narrow);
#else
#ifdef HAVE_FCHDIR
if (path.fd != -1)
@ -3145,11 +3017,7 @@ posix_getcwd(int use_bytes)
#endif
Py_BEGIN_ALLOW_THREADS
#if defined(PYOS_OS2) && defined(PYCC_GCC)
res = _getcwd2(buf, sizeof buf);
#else
res = getcwd(buf, sizeof buf);
#endif
Py_END_ALLOW_THREADS
if (res == NULL)
return posix_error();
@ -3313,17 +3181,6 @@ posix_listdir(PyObject *self, PyObject *args, PyObject *kwargs)
Py_ssize_t len = sizeof(namebuf)-5;
PyObject *po = NULL;
wchar_t *wnamebuf = NULL;
#elif defined(PYOS_OS2)
#ifndef MAX_PATH
#define MAX_PATH CCHMAXPATH
#endif
char *pt;
PyObject *v;
char namebuf[MAX_PATH+5];
HDIR hdir = 1;
ULONG srchcnt = 1;
FILEFINDBUF3 ep;
APIRET rc;
#else
PyObject *v;
DIR *dirp = NULL;
@ -3485,68 +3342,6 @@ exit:
return list;
#elif defined(PYOS_OS2)
if (path.length >= MAX_PATH) {
PyErr_SetString(PyExc_ValueError, "path too long");
goto exit;
}
strcpy(namebuf, path.narrow);
for (pt = namebuf; *pt; pt++)
if (*pt == ALTSEP)
*pt = SEP;
if (namebuf[len-1] != SEP)
namebuf[len++] = SEP;
strcpy(namebuf + len, "*.*");
if ((list = PyList_New(0)) == NULL) {
goto exit;
}
rc = DosFindFirst(namebuf, /* Wildcard Pattern to Match */
&hdir, /* Handle to Use While Search Directory */
FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY,
&ep, sizeof(ep), /* Structure to Receive Directory Entry */
&srchcnt, /* Max and Actual Count of Entries Per Iteration */
FIL_STANDARD); /* Format of Entry (EAs or Not) */
if (rc != NO_ERROR) {
errno = ENOENT;
Py_DECREF(list);
list = posix_error_with_filename(path.narrow);
goto exit;
}
if (srchcnt > 0) { /* If Directory is NOT Totally Empty, */
do {
if (ep.achName[0] == '.'
&& (ep.achName[1] == '\0' || (ep.achName[1] == '.' && ep.achName[2] == '\0')))
continue; /* Skip Over "." and ".." Names */
strcpy(namebuf, ep.achName);
/* Leave Case of Name Alone -- In Native Form */
/* (Removed Forced Lowercasing Code) */
v = PyBytes_FromString(namebuf);
if (v == NULL) {
Py_DECREF(list);
list = NULL;
break;
}
if (PyList_Append(list, v) != 0) {
Py_DECREF(v);
Py_DECREF(list);
list = NULL;
break;
}
Py_DECREF(v);
} while (DosFindNext(hdir, &ep, sizeof(ep), &srchcnt) == NO_ERROR && srchcnt > 0);
}
exit:
path_cleanup(&path);
return list;
#else
errno = 0;
@ -4852,10 +4647,6 @@ parse_envlist(PyObject* env, Py_ssize_t *envc_ptr)
goto error;
}
#if defined(PYOS_OS2)
/* Omit Pseudo-Env Vars that Would Confuse Programs if Passed On */
if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0) {
#endif
k = PyBytes_AsString(key2);
v = PyBytes_AsString(val2);
len = PyBytes_GET_SIZE(key2) + PyBytes_GET_SIZE(val2) + 2;
@ -4871,9 +4662,6 @@ parse_envlist(PyObject* env, Py_ssize_t *envc_ptr)
envlist[envc++] = p;
Py_DECREF(key2);
Py_DECREF(val2);
#if defined(PYOS_OS2)
}
#endif
}
Py_DECREF(vals);
Py_DECREF(keys);
@ -5114,18 +4902,12 @@ posix_spawnv(PyObject *self, PyObject *args)
}
argvlist[argc] = NULL;
#if defined(PYOS_OS2) && defined(PYCC_GCC)
Py_BEGIN_ALLOW_THREADS
spawnval = spawnv(mode, path, argvlist);
Py_END_ALLOW_THREADS
#else
if (mode == _OLD_P_OVERLAY)
mode = _P_OVERLAY;
Py_BEGIN_ALLOW_THREADS
spawnval = _spawnv(mode, path, argvlist);
Py_END_ALLOW_THREADS
#endif
free_string_array(argvlist, argc);
Py_DECREF(opath);
@ -5213,18 +4995,12 @@ posix_spawnve(PyObject *self, PyObject *args)
if (envlist == NULL)
goto fail_1;
#if defined(PYOS_OS2) && defined(PYCC_GCC)
Py_BEGIN_ALLOW_THREADS
spawnval = spawnve(mode, path, argvlist, envlist);
Py_END_ALLOW_THREADS
#else
if (mode == _OLD_P_OVERLAY)
mode = _P_OVERLAY;
Py_BEGIN_ALLOW_THREADS
spawnval = _spawnve(mode, path, argvlist, envlist);
Py_END_ALLOW_THREADS
#endif
if (spawnval == -1)
(void) posix_error();
@ -5245,183 +5021,6 @@ posix_spawnve(PyObject *self, PyObject *args)
return res;
}
/* OS/2 supports spawnvp & spawnvpe natively */
#if defined(PYOS_OS2)
PyDoc_STRVAR(posix_spawnvp__doc__,
"spawnvp(mode, file, args)\n\n\
Execute the program 'file' in a new process, using the environment\n\
search path to find the file.\n\
\n\
mode: mode of process creation\n\
file: executable file name\n\
args: tuple or list of strings");
static PyObject *
posix_spawnvp(PyObject *self, PyObject *args)
{
PyObject *opath;
char *path;
PyObject *argv;
char **argvlist;
int mode, i, argc;
Py_intptr_t spawnval;
PyObject *(*getitem)(PyObject *, Py_ssize_t);
/* spawnvp has three arguments: (mode, path, argv), where
argv is a list or tuple of strings. */
if (!PyArg_ParseTuple(args, "iO&O:spawnvp", &mode,
PyUnicode_FSConverter,
&opath, &argv))
return NULL;
path = PyBytes_AsString(opath);
if (PyList_Check(argv)) {
argc = PyList_Size(argv);
getitem = PyList_GetItem;
}
else if (PyTuple_Check(argv)) {
argc = PyTuple_Size(argv);
getitem = PyTuple_GetItem;
}
else {
PyErr_SetString(PyExc_TypeError,
"spawnvp() arg 2 must be a tuple or list");
Py_DECREF(opath);
return NULL;
}
argvlist = PyMem_NEW(char *, argc+1);
if (argvlist == NULL) {
Py_DECREF(opath);
return PyErr_NoMemory();
}
for (i = 0; i < argc; i++) {
if (!fsconvert_strdup((*getitem)(argv, i),
&argvlist[i])) {
free_string_array(argvlist, i);
PyErr_SetString(
PyExc_TypeError,
"spawnvp() arg 2 must contain only strings");
Py_DECREF(opath);
return NULL;
}
}
argvlist[argc] = NULL;
Py_BEGIN_ALLOW_THREADS
#if defined(PYCC_GCC)
spawnval = spawnvp(mode, path, argvlist);
#else
spawnval = _spawnvp(mode, path, argvlist);
#endif
Py_END_ALLOW_THREADS
free_string_array(argvlist, argc);
Py_DECREF(opath);
if (spawnval == -1)
return posix_error();
else
return Py_BuildValue("l", (long) spawnval);
}
PyDoc_STRVAR(posix_spawnvpe__doc__,
"spawnvpe(mode, file, args, env)\n\n\
Execute the program 'file' in a new process, using the environment\n\
search path to find the file.\n\
\n\
mode: mode of process creation\n\
file: executable file name\n\
args: tuple or list of arguments\n\
env: dictionary of strings mapping to strings");
static PyObject *
posix_spawnvpe(PyObject *self, PyObject *args)
{
PyObject *opath;
char *path;
PyObject *argv, *env;
char **argvlist;
char **envlist;
PyObject *res=NULL;
int mode;
Py_ssize_t argc, i, envc;
Py_intptr_t spawnval;
PyObject *(*getitem)(PyObject *, Py_ssize_t);
int lastarg = 0;
/* spawnvpe has four arguments: (mode, path, argv, env), where
argv is a list or tuple of strings and env is a dictionary
like posix.environ. */
if (!PyArg_ParseTuple(args, "ietOO:spawnvpe", &mode,
PyUnicode_FSConverter,
&opath, &argv, &env))
return NULL;
path = PyBytes_AsString(opath);
if (PyList_Check(argv)) {
argc = PyList_Size(argv);
getitem = PyList_GetItem;
}
else if (PyTuple_Check(argv)) {
argc = PyTuple_Size(argv);
getitem = PyTuple_GetItem;
}
else {
PyErr_SetString(PyExc_TypeError,
"spawnvpe() arg 2 must be a tuple or list");
goto fail_0;
}
if (!PyMapping_Check(env)) {
PyErr_SetString(PyExc_TypeError,
"spawnvpe() arg 3 must be a mapping object");
goto fail_0;
}
argvlist = PyMem_NEW(char *, argc+1);
if (argvlist == NULL) {
PyErr_NoMemory();
goto fail_0;
}
for (i = 0; i < argc; i++) {
if (!fsconvert_strdup((*getitem)(argv, i),
&argvlist[i]))
{
lastarg = i;
goto fail_1;
}
}
lastarg = argc;
argvlist[argc] = NULL;
envlist = parse_envlist(env, &envc);
if (envlist == NULL)
goto fail_1;
Py_BEGIN_ALLOW_THREADS
#if defined(PYCC_GCC)
spawnval = spawnvpe(mode, path, argvlist, envlist);
#else
spawnval = _spawnvpe(mode, path, argvlist, envlist);
#endif
Py_END_ALLOW_THREADS
if (spawnval == -1)
(void) posix_error();
else
res = Py_BuildValue("l", (long) spawnval);
while (--envc >= 0)
PyMem_DEL(envlist[envc]);
PyMem_DEL(envlist);
fail_1:
free_string_array(argvlist, lastarg);
fail_0:
Py_DECREF(opath);
return res;
}
#endif /* PYOS_OS2 */
#endif /* HAVE_SPAWNV */
@ -6420,23 +6019,8 @@ posix_kill(PyObject *self, PyObject *args)
int sig;
if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i:kill", &pid, &sig))
return NULL;
#if defined(PYOS_OS2) && !defined(PYCC_GCC)
if (sig == XCPT_SIGNAL_INTR || sig == XCPT_SIGNAL_BREAK) {
APIRET rc;
if ((rc = DosSendSignalException(pid, sig)) != NO_ERROR)
return os2_error(rc);
} else if (sig == XCPT_SIGNAL_KILLPROC) {
APIRET rc;
if ((rc = DosKillProcess(DKP_PROCESS, pid)) != NO_ERROR)
return os2_error(rc);
} else
return NULL; /* Unrecognized Signal Requested */
#else
if (kill(pid, sig) == -1)
return posix_error();
#endif
Py_INCREF(Py_None);
return Py_None;
}
@ -7333,31 +6917,7 @@ Return an object containing floating point numbers indicating process\n\
times. The object behaves like a named tuple with these fields:\n\
(utime, stime, cutime, cstime, elapsed_time)");
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
static long
system_uptime(void)
{
ULONG value = 0;
Py_BEGIN_ALLOW_THREADS
DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &value, sizeof(value));
Py_END_ALLOW_THREADS
return value;
}
static PyObject *
posix_times(PyObject *self, PyObject *noargs)
{
/* Currently Only Uptime is Provided -- Others Later */
return build_times_result(
(double)0 /* t.tms_utime / HZ */,
(double)0 /* t.tms_stime / HZ */,
(double)0 /* t.tms_cutime / HZ */,
(double)0 /* t.tms_cstime / HZ */,
(double)system_uptime() / 1000);
}
#elif defined(MS_WINDOWS)
#if defined(MS_WINDOWS)
static PyObject *
posix_times(PyObject *self, PyObject *noargs)
{
@ -7379,7 +6939,7 @@ posix_times(PyObject *self, PyObject *noargs)
(double)0,
(double)0);
}
#else /* Neither Windows nor OS/2 */
#else /* Not Windows */
#define NEED_TICKS_PER_SECOND
static long ticks_per_second = -1;
static PyObject *
@ -8123,16 +7683,6 @@ Create a pipe.");
static PyObject *
posix_pipe(PyObject *self, PyObject *noargs)
{
#if defined(PYOS_OS2)
HFILE read, write;
APIRET rc;
rc = DosCreatePipe( &read, &write, 4096);
if (rc != NO_ERROR)
return os2_error(rc);
return Py_BuildValue("(ii)", read, write);
#else
#if !defined(MS_WINDOWS)
int fds[2];
int res;
@ -8151,7 +7701,6 @@ posix_pipe(PyObject *self, PyObject *noargs)
write_fd = _open_osfhandle((Py_intptr_t)write, 1);
return Py_BuildValue("(ii)", read_fd, write_fd);
#endif /* MS_WINDOWS */
#endif
}
#endif /* HAVE_PIPE */
@ -10825,10 +10374,6 @@ static PyMethodDef posix_methods[] = {
#ifdef HAVE_SPAWNV
{"spawnv", posix_spawnv, METH_VARARGS, posix_spawnv__doc__},
{"spawnve", posix_spawnve, METH_VARARGS, posix_spawnve__doc__},
#if defined(PYOS_OS2)
{"spawnvp", posix_spawnvp, METH_VARARGS, posix_spawnvp__doc__},
{"spawnvpe", posix_spawnvpe, METH_VARARGS, posix_spawnvpe__doc__},
#endif /* PYOS_OS2 */
#endif /* HAVE_SPAWNV */
#ifdef HAVE_FORK1
{"fork1", posix_fork1, METH_NOARGS, posix_fork1__doc__},
@ -11155,59 +10700,6 @@ ins(PyObject *module, char *symbol, long value)
return PyModule_AddIntConstant(module, symbol, value);
}
#if defined(PYOS_OS2)
/* Insert Platform-Specific Constant Values (Strings & Numbers) of Common Use */
static int insertvalues(PyObject *module)
{
APIRET rc;
ULONG values[QSV_MAX+1];
PyObject *v;
char *ver, tmp[50];
Py_BEGIN_ALLOW_THREADS
rc = DosQuerySysInfo(1L, QSV_MAX, &values[1], sizeof(ULONG) * QSV_MAX);
Py_END_ALLOW_THREADS
if (rc != NO_ERROR) {
os2_error(rc);
return -1;
}
if (ins(module, "meminstalled", values[QSV_TOTPHYSMEM])) return -1;
if (ins(module, "memkernel", values[QSV_TOTRESMEM])) return -1;
if (ins(module, "memvirtual", values[QSV_TOTAVAILMEM])) return -1;
if (ins(module, "maxpathlen", values[QSV_MAX_PATH_LENGTH])) return -1;
if (ins(module, "maxnamelen", values[QSV_MAX_COMP_LENGTH])) return -1;
if (ins(module, "revision", values[QSV_VERSION_REVISION])) return -1;
if (ins(module, "timeslice", values[QSV_MIN_SLICE])) return -1;
switch (values[QSV_VERSION_MINOR]) {
case 0: ver = "2.00"; break;
case 10: ver = "2.10"; break;
case 11: ver = "2.11"; break;
case 30: ver = "3.00"; break;
case 40: ver = "4.00"; break;
case 50: ver = "5.00"; break;
default:
PyOS_snprintf(tmp, sizeof(tmp),
"%d-%d", values[QSV_VERSION_MAJOR],
values[QSV_VERSION_MINOR]);
ver = &tmp[0];
}
/* Add Indicator of the Version of the Operating System */
if (PyModule_AddStringConstant(module, "version", tmp) < 0)
return -1;
/* Add Indicator of Which Drive was Used to Boot the System */
tmp[0] = 'A' + values[QSV_BOOT_DRIVE] - 1;
tmp[1] = ':';
tmp[2] = '\0';
return PyModule_AddStringConstant(module, "bootdrive", tmp);
}
#endif
#if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
static int
enable_symlink()
@ -11542,35 +11034,12 @@ all_ins(PyObject *d)
#endif
#ifdef HAVE_SPAWNV
#if defined(PYOS_OS2) && defined(PYCC_GCC)
if (ins(d, "P_WAIT", (long)P_WAIT)) return -1;
if (ins(d, "P_NOWAIT", (long)P_NOWAIT)) return -1;
if (ins(d, "P_OVERLAY", (long)P_OVERLAY)) return -1;
if (ins(d, "P_DEBUG", (long)P_DEBUG)) return -1;
if (ins(d, "P_SESSION", (long)P_SESSION)) return -1;
if (ins(d, "P_DETACH", (long)P_DETACH)) return -1;
if (ins(d, "P_PM", (long)P_PM)) return -1;
if (ins(d, "P_DEFAULT", (long)P_DEFAULT)) return -1;
if (ins(d, "P_MINIMIZE", (long)P_MINIMIZE)) return -1;
if (ins(d, "P_MAXIMIZE", (long)P_MAXIMIZE)) return -1;
if (ins(d, "P_FULLSCREEN", (long)P_FULLSCREEN)) return -1;
if (ins(d, "P_WINDOWED", (long)P_WINDOWED)) return -1;
if (ins(d, "P_FOREGROUND", (long)P_FOREGROUND)) return -1;
if (ins(d, "P_BACKGROUND", (long)P_BACKGROUND)) return -1;
if (ins(d, "P_NOCLOSE", (long)P_NOCLOSE)) return -1;
if (ins(d, "P_NOSESSION", (long)P_NOSESSION)) return -1;
if (ins(d, "P_QUOTE", (long)P_QUOTE)) return -1;
if (ins(d, "P_TILDE", (long)P_TILDE)) return -1;
if (ins(d, "P_UNRELATED", (long)P_UNRELATED)) return -1;
if (ins(d, "P_DEBUGDESC", (long)P_DEBUGDESC)) return -1;
#else
if (ins(d, "P_WAIT", (long)_P_WAIT)) return -1;
if (ins(d, "P_NOWAIT", (long)_P_NOWAIT)) return -1;
if (ins(d, "P_OVERLAY", (long)_OLD_P_OVERLAY)) return -1;
if (ins(d, "P_NOWAITO", (long)_P_NOWAITO)) return -1;
if (ins(d, "P_DETACH", (long)_P_DETACH)) return -1;
#endif
#endif
#ifdef HAVE_SCHED_H
if (ins(d, "SCHED_OTHER", (long)SCHED_OTHER)) return -1;
@ -11630,9 +11099,6 @@ all_ins(PyObject *d)
if (PyModule_AddIntMacro(d, RTLD_DEEPBIND)) return -1;
#endif
#if defined(PYOS_OS2)
if (insertvalues(d)) return -1;
#endif
return 0;
}
@ -11641,10 +11107,6 @@ all_ins(PyObject *d)
#define INITFUNC PyInit_nt
#define MODNAME "nt"
#elif defined(PYOS_OS2)
#define INITFUNC PyInit_os2
#define MODNAME "os2"
#else
#define INITFUNC PyInit_posix
#define MODNAME "posix"

View File

@ -1,672 +0,0 @@
#####################==================----------------
#
# Top-Level Makefile for Building Python 2.6 for OS/2 using GCC/EMX
# Originally written by Andrew Zabolotny, <bit@eltech.ru> for Python 1.5.2
# Modified by Andrew MacIntyre, <andymac@pcug.org.au> for Python 2.6
#
# This makefile was developed for use with [P]GCC/EMX compiler any
# version and GNU Make.
#
# The output of the build is a largish Python26.DLL containing the
# essential modules of Python and a small Python.exe program to start
# the interpreter. When embedding Python within another program, only
# Python26.DLL is needed. We also build python_s.a static library (which
# can be converted into OMF (.lib) format using emxomf tool) and both
# python.a and python.lib import libraries. Then the optional
# extension modules, which are OS/2 DLLs renamed with a PYD file extension.
#
# Recommended build order:
# make depend (if you have makedep)
# make all
# make lx (if you have lxlite)
# make test (optional)
#
#####################==================----------------
# === Compilation mode: debug or release ===
MODE= optimize
#MODE= debug
# === Assert() enabled ===
ASSERTIONS=no
#ASSERTIONS=yes
# === Hard-wire installation location ===
FIXED_PYHOME=no
#FIXED_PYHOME=yes
# === Optional modules ===
# Do you have the InfoZip compression library installed?
HAVE_ZLIB= no
# Do you have the Ultra Fast Crypt (UFC) library installed?
HAVE_UFC= no
# Do you have the Tcl/Tk library installed?
HAVE_TCLTK= no
# Do you have the GNU readline library installed?
# NOTE: I'm using a modified version of Kai Uwe Rommel's port that
# - is compiled with multithreading enabled
# - is linked statically
# I have had no success trying to use a DLL version, even when
# compiled with multithreading enabled.
HAVE_GREADLINE= no
# Do you have the BSD DB library (v1.85) as included in the EMXBSD package?
# NOTE: this library needs to be recompiled with a structure member
# renamed to avoid problems with the multithreaded errno support
# (there is a structure member called errno, used for shadowing the
# real errno, which conflicts with the errno redefinition of -Zmt)
HAVE_BSDDB= no
# Do you have the ncurses library installed? EMX's BSD curses aren't enough!
HAVE_NCURSES= no
# Do you have the GDBM library installed?
HAVE_GDBM= no
# Do you have the BZ2 compression library installed?
HAVE_BZ2= no
# Do you have the OpenSSL libraries installed
HAVE_OPENSSL= no
# === install locations ===
# default value of PYTHONHOME
LIB_DIR=C:/Python26
# default is to have everything in or under PYTHONHOME
EXE_DIR=$(LIB_DIR)
DLL_DIR=$(EXE_DIR)
# === The Tools ===
CC= gcc
CFLAGS= -Zmt -Wall $(INCLUDE)
CFLAGS.LIB= $(CFLAGS)
LD= gcc
LDFLAGS= -Zmt -Zcrtdll -L. -lgcc
LDFLAGS.EXE= $(LDFLAGS)
LDFLAGS.DLL= $(LDFLAGS) -Zdll
LDFLAGS.A= $(LDFLAGS) $(LIBS)
ARFLAGS= crs
IMPLIB= emximp
EXPLIB= emxexp
EXEOPT= emxbind
PY_DEF= -DPy_BUILD_CORE
# adjust C compiler settings based on build options
ifeq ($(MODE),debug)
CFLAGS+= -g -O
LDFLAGS+= -g
else
CFLAGS+= -s -O3 -fomit-frame-pointer -mprobe
LDFLAGS+= -s
endif
CFLAGS+= $(PY_DEF)
ifeq ($(ASSERTIONS),no)
CFLAGS+= -DNDEBUG
endif
ifeq ($(FIXED_PYHOME),yes)
CFLAGS+= -DPREFIX=$(DQUOTE)$(LIB_DIR)$(DQUOTE)
endif
# We're using the OMF format since EMX's ld has a obscure bug
# because of which it sometimes fails to build relocations
# in .data segment that point to another .data locations
# (except for the final linking if the .EXEs)
OMF= yes
# if fork() support is required, the main executable must be linked with ld
EXEOMF= no
# File extensions
MODULE.EXT= .pyd
MODLIB.EXT= .dll
ifeq ($(OMF),yes)
O= .obj
A= .lib
AR= emxomfar
CFLAGS+= -Zomf
LDFLAGS+= -Zomf
ifeq ($(MODE),debug)
ARFLAGS= -p64 crs
else
ARFLAGS= -p32 crs
endif
else
O= .o
A= .a
AR= ar
endif
# === Build time resource settings ===
# EMX's default number of file handles is 40, which is sometimes insufficient
# (the tempfile regression test tries to create 100 temporary files)
NFILES=250
# The default stack size for child threads is 64k bytes, which is
# insufficient for some applications which do a lot of work in threads
# (such as Zope, especially in conjunction with Plone).
# Note that this setting is distinct from the stack size for the main
# thread, which is set via the %.def rule below.
# EMX documents that the thread stack size should be at least 32768 bytes;
# for Zope/Plone at least 128k bytes is recommended.
# Uncomment & adjust the next line to override the default stack size:
#CFLAGS+= -DTHREAD_STACK_SIZE=0x20000
# === The environment ===
# Source file paths
SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules
# Python contains the central core, containing the builtins and interpreter.
# Parser contains Python's Internal Parser and
# Standalone Parser Generator Program (Shares Some of Python's Modules)
# Objects contains Python Object Types
# Modules contains extension Modules (Built-In or as Separate DLLs)
# Unix shells tend to use "$" as delimiter for variable names.
# Test for this behaviour and set $(BUCK) variable correspondigly ...
__TMP__:=$(shell echo $$$$)
ifeq ($(__TMP__),$$$$)
BUCK= $$
BRO= (
BRC= )
else
BUCK= \$$
BRO= \(
BRC= \)
endif
# Compute the "double quote" variable
__TMP__:=$(shell echo "")
ifeq ($(__TMP__),"")
DQUOTE= "
else
DQUOTE= \"
endif
# Include paths
#INCLUDE= -I$(subst ;, -I, $(SRCPATH))
INCLUDE= -I. -I../../Include
# Path to search for .c files
vpath %.c .;..;$(SRCPATH)
# Top of the package tree
TOP= ../../
# Directory for output files
OUTBASE= out/
OUT= $(OUTBASE)$(MODE)/
# Additional libraries
LIBS= -lsocket
# Utility macro: replacement for $^
^^= $(filter-out %$A,$^)
# Use $(L^) to link with all libraries specified as dependencies
L^= $(addprefix -l,$(basename $(notdir $(filter %$A,$+))))
# Build rules
$(OUT)%$O: %.c
$(CC) $(CFLAGS.LIB) -c $< -o $@
%.a:
$(LD) $(LDFLAGS.A) -o $@ $(^^) $(L^)
%.dll:
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
%.pyd: $(OUT)%module$O $(OUT)%_m.def
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(PYTHON.IMPLIB) $(LIBS)
%.exe:
$(LD) $(LDFLAGS.EXE) -o $@ $(^^) $(L^)
%_m.def:
@echo Creating .DEF file: $@
@echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
ifeq ($(DESCRIPTION.$(notdir $*)$(MODULE.EXT)),)
@echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
else
@echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODULE.EXT))$(DQUOTE) >>$@
endif
@echo DATA MULTIPLE NONSHARED >>$@
@echo EXPORTS >>$@
@echo init$(notdir $*) >>$@
%.def:
@echo Creating .DEF file: $@
@echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@
@echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@
@echo STACKSIZE 2097152 >>$@
# Output file names
PYTHON_VER= 2.6
PYTHON_LIB= python34
PYTHON.LIB= $(PYTHON_LIB)_s$A
PYTHON.IMPLIB= $(PYTHON_LIB)$A
ifeq ($(EXEOMF),yes)
PYTHON.EXEIMP= $(PYTHON.IMPLIB)
LDMODE.EXE= -Zomf
else
PYTHON.EXEIMP= $(PYTHON_LIB).a
LDMODE.EXE =
endif
PYTHON.DLL= $(PYTHON_LIB).dll
PYTHON.DEF= $(PYTHON_LIB).def
PYTHON.EXE= python.exe
PYTHONPM.EXE= pythonpm.exe
PGEN.EXE= pgen.exe
LIBRARY= $(PYTHON.LIB)
LD_LIBRARY= $(PYTHON.IMPLIB)
# Additional executable parameters
EXETYPE.$(PYTHON.EXE)= WINDOWCOMPAT
EXETYPE.$(PYTHONPM.EXE)= WINDOWAPI
EXETYPE.$(PGEN.EXE)= WINDOWCOMPAT
DESCRIPTION.$(PYTHON.EXE)= Python object-oriented programming language interpreter for OS/2
DESCRIPTION.$(PYTHONPM.EXE)= $(DESCRIPTION.$(PYTHON.EXE))
DESCRIPTION.$(PGEN.EXE)= Python object-oriented programming language parser generator for OS/2
# Module descriptions
DESCRIPTION.zlib$(MODULE.EXT)= Python Extension DLL for accessing the InfoZip compression library
DESCRIPTION.crypt$(MODULE.EXT)= Python Extension DLL implementing the crypt$(BRO)$(BRC) function
DESCRIPTION._tkinter$(MODULE.EXT)= Python Extension DLL for access to Tcl/Tk Environment
DESCRIPTION.readline$(MODULE.EXT)= Python Extension DLL for access to GNU ReadLine library
DESCRIPTION._curses$(MODLIB.EXT)= Python Extension DLL for access to ncurses library
DESCRIPTION.pyexpat$(MODULE.EXT)= Python Extension DLL for access to expat library
DESCRIPTION.bz2$(MODULE.EXT)= Python Extension DLL for accessing the bz2 compression library
# Source files
SRC.OS2EMX= config.c dlfcn.c getpathp.c
SRC.MAIN= $(addprefix $(TOP), \
Modules/getbuildinfo.c \
Modules/main.c)
SRC.MODULES= $(addprefix $(TOP), \
Modules/gcmodule.c \
Modules/signalmodule.c \
Modules/posixmodule.c \
Modules/_threadmodule.c \
Modules/arraymodule.c \
Modules/binascii.c \
Modules/cmathmodule.c \
Modules/_codecsmodule.c \
Modules/collectionsmodule.c \
Modules/_csv.c \
Modules/datetimemodule.c \
Modules/errnomodule.c \
Modules/fcntlmodule.c \
Modules/_functoolsmodule.c \
Modules/_heapqmodule.c \
Modules/imageop.c \
Modules/itertoolsmodule.c \
Modules/_localemodule.c \
Modules/mathmodule.c \
Modules/operator.c \
Modules/_randommodule.c \
Modules/sha256module.c \
Modules/sha512module.c \
Modules/_sre.c \
Modules/_struct.c \
Modules/symtablemodule.c \
Modules/termios.c \
Modules/timemodule.c \
Modules/_weakref.c \
Modules/xxsubtype.c \
Modules/zipimport.c)
SRC.PARSE1= $(addprefix $(TOP), \
Parser/acceler.c \
Parser/grammar1.c \
Parser/listnode.c \
Parser/node.c \
Parser/parser.c \
Parser/parsetok.c \
Parser/bitset.c \
Parser/metagrammar.c)
SRC.PARSE2= $(addprefix $(TOP), \
Parser/tokenizer.c \
Parser/myreadline.c)
SRC.PARSER= $(SRC.PARSE1) \
$(SRC.PARSE2)
SRC.PYTHON= $(addprefix $(TOP), \
Python/Python-ast.c \
Python/asdl.c \
Python/ast.c \
Python/bltinmodule.c \
Python/exceptions.c \
Python/ceval.c \
Python/compile.c \
Python/codecs.c \
Python/dynamic_annotations.c \
Python/errors.c \
Python/frozen.c \
Python/frozenmain.c \
Python/future.c \
Python/getargs.c \
Python/getcompiler.c \
Python/getcopyright.c \
Python/getplatform.c \
Python/getversion.c \
Python/graminit.c \
Python/import.c \
Python/importdl.c \
Python/marshal.c \
Python/modsupport.c \
Python/mysnprintf.c \
Python/mystrtoul.c \
Python/pyarena.c \
Python/pyctype.c \
Python/pyfpe.c \
Python/pystate.c \
Python/pystrtod.c \
Python/pythonrun.c \
Python/structmember.c \
Python/symtable.c \
Python/sysmodule.c \
Python/traceback.c \
Python/getopt.c \
Python/dynload_shlib.c \
Python/thread.c)
SRC.OBJECT= $(addprefix $(TOP), \
Objects/abstract.c \
Objects/boolobject.c \
Objects/cellobject.c \
Objects/classobject.c \
Objects/cobject.c \
Objects/codeobject.c \
Objects/complexobject.c \
Objects/descrobject.c \
Objects/dictobject.c \
Objects/enumobject.c \
Objects/fileobject.c \
Objects/floatobject.c \
Objects/frameobject.c \
Objects/funcobject.c \
Objects/genobject.c \
Objects/iterobject.c \
Objects/listobject.c \
Objects/longobject.c \
Objects/methodobject.c \
Objects/moduleobject.c \
Objects/object.c \
Objects/obmalloc.c \
Objects/rangeobject.c \
Objects/setobject.c \
Objects/sliceobject.c \
Objects/stringobject.c \
Objects/structseq.c \
Objects/tupleobject.c \
Objects/typeobject.c \
Objects/unicodeobject.c \
Objects/unicodectype.c \
Objects/weakrefobject.c)
SRC.LIB= $(SRC.OS2EMX) \
$(SRC.MAIN) \
$(SRC.PARSER) \
$(SRC.OBJECT) \
$(SRC.PYTHON) \
$(SRC.MODULES)
OBJ.LIB= $(addprefix $(OUT),$(notdir $(SRC.LIB:.c=$O)))
SRC.PGEN= $(SRC.PARSE1) \
$(addprefix $(TOP), \
Objects/obmalloc.c) \
$(addprefix $(TOP), \
Python/mysnprintf.c) \
$(addprefix $(TOP), \
Parser/tokenizer_pgen.c \
Parser/pgenmain.c \
Parser/pgen.c \
Parser/printgrammar.c \
Parser/grammar.c \
Parser/firstsets.c) \
OBJ.PGEN= $(addprefix $(OUT),$(notdir $(SRC.PGEN:.c=$O)))
SRC.EXE= $(TOP)Modules/python.c
SRC.PMEXE= pythonpm.c
# Python modules to be dynamically loaded that:
# 1) have only single source file and require no extra libs
# 2) use the standard module naming convention
# (the 'module' in ?????module.c is assumed)
# - these can be built with implicit rules
EASYEXTMODULES= fpectl \
fpetest \
parser \
pwd \
select
# Python modules to be dynamically loaded that need explicit build rules
# (either multiple source files and/or non-standard module naming)
# (NOTE: use shortened names for modules affected by 8 char name limit)
HARDEXTMODULES= _socket \
_testcap \
unicoded
# Python modules that are used as libraries and therefore must use
# a .DLL extension
LIBEXTMODULES=
# Python external ($(MODULE.EXT)) modules - can be EASY or HARD
ifeq ($(HAVE_ZLIB),yes)
HARDEXTMODULES+= zlib
endif
ifeq ($(HAVE_UFC),yes)
HARDEXTMODULES+= crypt
endif
ifeq ($(HAVE_TCLTK),yes)
HARDEXTMODULES+= _tkinter
CFLAGS+= -DHAS_DIRENT -I/TclTk80/include
TK_LIBS+= -L/TclTk80/lib -ltcl80 -ltk80
endif
ifeq ($(HAVE_GREADLINE),yes)
HARDEXTMODULES+= readline
endif
ifeq ($(HAVE_NCURSES),yes)
LIBEXTMODULES+= _curses
HARDEXTMODULES+= _curses_
endif
ifeq ($(HAVE_GDBM),yes)
HARDEXTMODULES+= _gdbm _dbm
endif
ifeq ($(HAVE_BZ2),yes)
HARDEXTMODULES+= bz2
endif
ifeq ($(HAVE_OPENSSL),yes)
HARDEXTMODULES+= _ssl
endif
# Expat is now distributed with the Python source
HARDEXTMODULES+= pyexpat
EXPAT.INC= -I../../Modules/expat
EXPAT.DEF= -DHAVE_EXPAT_H -DXML_NS=1 -DXML_DTD=1 -DXML_BYTE_ORDER=12 \
-DXML_CONTENT_BYTES=1024 -DHAVE_MEMMOVE=1 -DHAVE_BCOPY=1
EXPAT.SRC= $(addprefix ../../Modules/expat/, \
xmlparse.c \
xmlrole.c \
xmltok.c)
# all the external modules
EXTERNDLLS= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(EASYEXTMODULES)))
EXTERNDLLS+= $(addsuffix $(MODULE.EXT),$(patsubst %module,%,$(HARDEXTMODULES)))
EXTERNDLLS+= $(addsuffix $(MODLIB.EXT),$(patsubst %module,%,$(LIBEXTMODULES)))
# Targets
all: $(OUT) $(PYTHON.LIB) $(PYTHON.DEF) $(PYTHON.IMPLIB) $(PYTHON.DLL) \
python_noncore
python_noncore:
make PY_DEF= $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) $(EXTERNDLLS)
clean:
rm -f $(OUT)*
rm -f $(PYTHON.LIB) $(PYTHON.IMPLIB) $(PYTHON.EXEIMP) $(PYTHON.DLL) \
$(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE) *$(MODULE.EXT) *.dll
find ../../Lib -name "*.py[co]" -exec rm {} ";"
lx:
@echo Packing everything with lxLite...
lxlite $(PYTHON.DLL) $(PYTHON.EXE) $(PYTHONPM.EXE) $(PGEN.EXE)
depend: $(OUTBASE)
makedep -f $(OUTBASE)python.dep -o $(BUCK)O -p $(BUCK)\(OUT\) \
-r -c $(INCLUDE) $(SRC.LIB) $(SRC.PGEN)
$(OUT): $(OUTBASE)
$(OUT) $(OUTBASE):
mkdir.exe $@
$(PYTHON.LIB): $(OBJ.LIB)
rm.exe -f $@
$(AR) $(ARFLAGS) $@ $^
# the Python core DLL .def file needs to have a number of non-static
# symbols that aren't part of the Python C API removed (commented out)
# from the DLL export list.
$(PYTHON.DEF): $(PYTHON.LIB)
@echo Creating .DEF file: $@
@echo LIBRARY $(PYTHON_LIB) INITINSTANCE TERMINSTANCE >$@
@echo DESCRIPTION $(DQUOTE)Python $(PYTHON_VER) Core DLL$(DQUOTE) >>$@
@echo PROTMODE >>$@
@echo DATA MULTIPLE NONSHARED >>$@
@echo EXPORTS >>$@
$(EXPLIB) -u $(PYTHON.LIB) |\
sed -e "/^ .init.*/s/^ /; /" \
-e "/^ .pcre_.*/s/^ /; /" \
-e "/^ .array_methods/s/^ /; /" \
-e "/^ .fast_save_leave/s/^ /; /" \
-e "/^ .dlopen/s/^ /; /" \
-e "/^ .dlsym/s/^ /; /" \
-e "/^ .dlclose/s/^ /; /" \
-e "/^ .dlerror/s/^ /; /" \
-e "/^ ._Py_re_.*/s/^ /; /" \
-e "/^ ._Py_MD5.*/s/^ /; /" >>$@
$(PYTHON.IMPLIB): $(PYTHON.DEF)
$(IMPLIB) -o $@ $^
$(PYTHON.EXEIMP): $(PYTHON.DEF)
$(IMPLIB) -o $@ $^
$(PYTHON.DLL): $(OUT)dllentry$O $(PYTHON.LIB) $(PYTHON.DEF)
# Explicit make targets for the .EXEs to be able to use LD to link
# (so that fork() will work if required)
$(PYTHON.EXE): $(SRC.EXE) $(PYTHON.EXEIMP) $(OUT)python.def
$(CC) -Zmt $(LDMODE.EXE) -Zcrtdll -Wall $(INCLUDE) -L. -lgcc -o $@ $(SRC.EXE) $(PYTHON.EXEIMP) $(LIBS) $(OUT)python.def
$(EXEOPT) -aq $(PYTHON.EXE) -h$(NFILES)
$(PYTHONPM.EXE): $(SRC.PMEXE) $(PYTHON.EXEIMP) $(OUT)pythonpm.def
$(CC) -Zmt $(LDMODE.EXE) -Zcrtdll -Wall $(INCLUDE) -L. -lgcc -o $@ $(SRC.PMEXE) $(PYTHON.EXEIMP) $(LIBS) $(OUT)pythonpm.def
$(EXEOPT) -aq $(PYTHONPM.EXE) -h$(NFILES)
$(PGEN.EXE): $(OBJ.PGEN) $(OUT)pgen.def
# Explicit building instructions for those external modules that require
# awkward handling (due e.g. to non-std naming, or multiple source files)
# - standard modules
_socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
# _testcapi needs to be renamed to be useful
_testcapi$(MODULE.EXT): $(OUT)_testcapimodule$O $(OUT)_testcapi_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
_testcap$(MODULE.EXT): _testcapi$(MODULE.EXT)
cp $^ $@
# unicodedata needs to be renamed to be useful
unicodedata$(MODULE.EXT): $(OUT)unicodedata$O $(OUT)unicodedata_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(MODULE_LIBS)
unicoded$(MODULE.EXT): unicodedata$(MODULE.EXT)
cp $^ $@
crypt$(MODULE.EXT): $(OUT)cryptmodule$O $(OUT)crypt_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) -lufc $(LIBS)
# The _curses_panel module requires a couple of ncurses library entry
# points, which are best exposed as exports from the _curses module DLL
$(OUT)_curses_m.def:
@echo Creating .DEF file: $@
@echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
@echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*)$(MODLIB.EXT))$(DQUOTE) >>$@
@echo DATA MULTIPLE NONSHARED >>$@
@echo EXPORTS >>$@
@echo init_curses >>$@
@echo wnoutrefresh >>$@
@echo _nc_panelhook >>$@
@echo is_linetouched >>$@
@echo mvwin >>$@
@echo stdscr >>$@
@echo wtouchln >>$@
$(OUT)_curses_panel_m.def:
@echo Creating .DEF file: $@
@echo LIBRARY $(notdir $*) INITINSTANCE TERMINSTANCE >$@
@echo DESCRIPTION $(DQUOTE)Python standard module $(notdir $*)$(DQUOTE) >>$@
@echo DATA MULTIPLE NONSHARED >>$@
@echo IMPORTS >>$@
@echo _curses.wnoutrefresh >>$@
@echo _curses._nc_panelhook >>$@
@echo _curses.is_linetouched >>$@
@echo _curses.mvwin >>$@
@echo _curses.stdscr >>$@
@echo _curses.wtouchln >>$@
@echo EXPORTS >>$@
@echo init_curses_panel >>$@
_curses$(MODLIB.EXT): $(OUT)_cursesmodule$O $(OUT)_curses_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lncurses
# curses_panel needs to be renamed to be useful
_curses_panel$(MODULE.EXT): $(OUT)_curses_panel$O $(OUT)_curses_panel_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lpanel
_curses_$(MODULE.EXT): _curses_panel$(MODULE.EXT)
cp $^ $@
_dbm$(MODULE.EXT): $(OUT)_dbmmodule$O $(OUT)dbm_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
_gdbm$(MODULE.EXT): $(OUT)_gdbmmodule$O $(OUT)gdbm_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lgdbm
# Expat is now distributed with Python, so use the included version
$(OUT)pyexpat$O: ../../Modules/pyexpat.c
$(CC) $(CFLAGS) $(EXPAT.INC) -c -o $@ $^
$(OUT)xmlparse$O: ../../Modules/expat/xmlparse.c
$(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
$(OUT)xmlrole$O: ../../Modules/expat/xmlrole.c
$(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
$(OUT)xmltok$O: ../../Modules/expat/xmltok.c
$(CC) $(CFLAGS) $(EXPAT.INC) $(EXPAT.DEF) -c -o $@ $^
pyexpat$(MODULE.EXT): $(OUT)pyexpat$O $(OUT)xmlparse$O $(OUT)xmlrole$O \
$(OUT)xmltok$O $(OUT)pyexpat_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
readline$(MODULE.EXT): $(OUT)readline$O $(OUT)readline_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lreadline -lncurses
#_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O $(OUT)tkappinit$O
_tkinter$(MODULE.EXT): $(OUT)_tkinter$O $(OUT)tclNotify$O \
$(OUT)_tkinter_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) $(TK_LIBS)
zlib$(MODULE.EXT): $(OUT)zlibmodule$O $(OUT)zlib_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lz
bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2
_ssl$(MODULE.EXT): $(OUT)_ssl$O $(OUT)_ssl_m.def $(PYTHON.IMPLIB)
$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lssl -lcrypto
# the test target
test:
-find ../../Lib -name "*.py[co]" -exec rm {} ";"
-./python -E ../../lib/test/regrtest.py -l -u "network"
./python -E ../../lib/test/regrtest.py -l -u "network"
-include $(OUTBASE)python.dep

View File

@ -1,663 +0,0 @@
This is a port of Python 2.6 to OS/2 using the EMX development tools
=========================================================================
What's new since the previous release
-------------------------------------
Another day, another version...
Licenses and info about Python and EMX
--------------------------------------
Please read the file README.Python-2.6 included in this package for
information about Python 2.6. This file is the README file from the
Python 2.6 source distribution available via http://www.python.org/
and its mirrors. The file LICENCE.Python-2.6 is the text of the Licence
from the Python 2.6 source distribution.
Note that the EMX package that this package depends on is released under
the GNU General Public Licence. Please refer to the documentation
accompanying the EMX Runtime libraries for more information about the
implications of this. A copy of version 2 of the GPL is included as the
file COPYING.gpl2.
Readline and GDBM are covered by the GNU General Public Licence. I think
Eberhard Mattes' porting changes to BSD DB v1.85 are also GPL'ed (BSD DB
itself is BSD Licenced). ncurses and expat appear to be covered by MIT
style licences - please refer to the source distributions for more detail.
zlib is distributable under a very free license. GNU UFC is under the
GNU LGPL (see file COPYING.lib).
My patches to the Python-2.x source distributions, and any other packages
used in this port, are placed in the public domain.
This software is provided 'as-is', without any express or implied warranty.
In no event will the author be held liable for any damages arising from the
use of the software.
I do hope however that it proves useful to someone.
Other ports
-----------
There have been ports of previous versions of Python to OS/2.
The best known would be that by Jeff Rush, most recently of version
1.5.2. Jeff used IBM's Visual Age C++ (v3) for his ports, and his
patches have been included in the Python 2.6 source distribution.
Andy Zabolotny implemented a port of Python v1.5.2 using the EMX
development tools. His patches against the Python v1.5.2 source
distribution have become the core of this port, and without his efforts
this port wouldn't exist. Andy's port also appears to have been
compiled with his port of gcc 2.95.2 to EMX, which I have but have
chosen not to use for the binary distribution of this port (see item 16
of the "YOU HAVE BEEN WARNED" section below).
It is possible to have these earlier ports still usable after installing
this port - see the README.os2emx.multiple_versions file, contributed by
Dr David Mertz, for a suggested approach to achieving this.
Software requirements
---------------------
This package requires the EMX Runtime package, available from the
Hobbes (http://hobbes.nmsu.edu/) and LEO (http://archiv.leo.org/)
archives of OS/2 software. I have used EMX version 0.9d fix04 in
developing this port.
My development system is running OS/2 v4 with fixpack 12.
3rd party software which has been linked into dynamically loaded modules:
- ncurses (see http://dickey.his.com/ for more info, v5.2)
- GNU Readline (Kai Uwe Rommel's port available from Hobbes or LEO, v2.1)
- GNU GDBM (Kai Uwe Rommel's port available from Hobbes or LEO, v1.7.3)
- zlib (derived from Hung-Chi Chu's port of v1.1.3, v1.1.4)
- expat (distributed with Python, v1.95.6)
- GNU UFC (Kai Uwe Rommel's port available from LEO, v2.0.4)
About this port
---------------
I have attempted to make this port as complete and functional as I can,
notwithstanding the issues in the "YOU HAVE BEEN WARNED" section below.
Core components:
Python.exe is linked as an a.out executable, ie using EMX method E1
to compile & link the executable. This is so that fork() works (see
"YOU HAVE BEEN WARNED" item 1).
Python26.dll is created as a normal OMF DLL, with an OMF import
library and module definition file. There is also an a.out (.a) import
library to support linking the DLL to a.out executables. The DLL
requires the EMX runtime DLLs.
This port has been built with complete support for multithreading.
Modules:
With the exception of modules that have a significant code size, or are
not recommended or desired for normal use, the standard modules are now
built into the core DLL rather than configured as dynamically loadable
modules. This is for both reasons of performance (startup time) and
memory use (lots of small DLLs fragment the address space).
I haven't yet changed the building of Python's dynamically loadable
modules over to using the DistUtils.
See "YOU HAVE BEEN WARNED" item 3 for notes about the fcntl module, and
"YOU HAVE BEEN WARNED" item 10 for notes about the pwd and grp modules.
This port supports case sensitive module import semantics, matching
the Windows release. This can be deactivated by setting the PYTHONCASEOK
environment variable (the value doesn't matter) - see "YOU HAVE BEEN WARNED"
item 12.
Optional modules:
Where I've been able to locate the required 3rd party packages already
ported to OS/2, I've built and included them.
These include ncurses (_curses, _curses_panel),
GNU GDBM (gdbm, dbm), zlib (zlib), GNU Readline (readline), and GNU UFC
(crypt).
Expat is now included in the Python release sourceball, and the pyexpat
module is always built.
I have built these modules statically linked against the 3rd party
libraries. Unfortunately my attempts to use the dll version of GNU
readline have been a dismal failure, in that when the dynamically
linked readline module is active other modules immediately provoke a
core dump when imported.
Only the BSD DB package (part of the BSD package distributed with EMX)
needs source modifications to be used for this port, pertaining to use
of errno with multithreading.
The other packages, except for ncurses and zlib, needed Makefile changes
for multithreading support but no source changes.
The _curses_panel module is a potential problem - see "YOU HAVE BEEN
WARNED" item 13.
Upstream source patches:
No updates to the Python 2.6 release have become available.
Library and other distributed Python code:
The Python standard library lives in the Lib directory. All the standard
library code included with the Python 2.6 source distribution is included
in the binary archive, with the exception of the dos-8x3 and tkinter
subdirectories which have been omitted to reduce the size of the binary
archive - the dos-8x3 components are unnecessary duplicates and Tkinter
is not supported by this port (yet). All the plat-* subdirectories in the
source distribution have also been omitted, except for the plat-os2emx
subdirectory.
The Tools and Demo directories contain a collection of Python scripts.
To reduce the size of the binary archive, the Demo/sgi, Demo/Tix,
Demo/tkinter, Tools/audiopy and Tools/IDLE subdirectories have been
omitted as not being supported by this port. The Misc directory has
also been omitted.
All subdirectories omitted from the binary archive can be reconstituted
from the Python 2.6 source distribution, if desired.
Support for building Python extensions:
The Config subdirectory contains the files describing the configuration
of the interpreter and the Makefile, import libraries for the Python DLL,
and the module definition file used to create the Python DLL. The
Include subdirectory contains all the standard Python header files
needed for building extensions.
As I don't have the Visual Age C++ compiler, I've made no attempt to
have this port support extensions built with that compiler.
Packaging
---------
This port is packaged as follows:
- python-2.6-os2emx-bin-03????.zip (binaries, library modules)
- python-2.6-os2emx-src-03???? (patches+makefiles for non-Python code)
As all the Python specific patches for the port are now part of the
Python release tarball, only the patches and makefiles involved in
building external libraries for optional extensions are included in
the source archive.
Documentation for the Python language, as well as the Python 2.6
source distibution, can be obtained from the Python website
(http://www.python.org/) or the Python project pages at Sourceforge
(http://sf.net/projects/python/).
Installation
------------
Obtain and install, as per the included instructions, the EMX runtime
package.
Unpack this archive, preserving the subdirectories, in the root directory
of the drive where you want Python to live.
Add the Python directory (eg C:\Python26) to the PATH and LIBPATH
variables in CONFIG.SYS.
You should then set the PYTHONHOME and PYTHONPATH environment variables
in CONFIG.SYS.
PYTHONHOME should be set to Python's top level directory. PYTHONPATH
should be set to the semicolon separated list of principal Python library
directories.
I use:
SET PYTHONHOME=F:/Python26
SET PYTHONPATH=F:/Python26/Lib;F:/Python26/Lib/plat-os2emx;
F:/Python26/Lib/lib-dynload;F:/Python26/Lib/site-packages
NOTE!: the PYTHONPATH setting above is linewrapped for this document - it
should all be on one line in CONFIG.SYS!
If you wish to use the curses module, you should set the TERM and TERMINFO
environment variables appropriately.
If you don't already have ncurses installed, I have included a copy of the
EMX subset of the Terminfo database included with the ncurses-5.2 source
distribution. This can be used by setting the TERMINFO environment variable
to the path of the Terminfo subdirectory below the Python home directory.
On my system this looks like:
SET TERMINFO=F:/Python26/Terminfo
For the TERM environment variable, I would try one of the following:
SET TERM=ansi
SET TERM=os2
SET TERM=window
You will have to reboot your system for these changes to CONFIG.SYS to take
effect.
If you wish to compile all the included Python library modules to bytecode,
you can change into the Python home directory and run the COMPILEALL.CMD
batch file.
You can execute the regression tests included with the Python 2.6 source
distribution by changing to the Python 2.6 home directory and executing the
REGRTEST.CMD batch file. The following tests are known to fail at this
time:
- test_mhlib (I don't know of any port of MH to OS/2);
- test_strptime (see "YOU HAVE BEEN WARNED" item 22);
- test_time (see "YOU HAVE BEEN WARNED" item 22);
- test_posixpath (see "YOU HAVE BEEN WARNED" item 23).
Note that some of the network related tests expect the loopback interface
(interface "lo", with IP address 127.0.0.1) to be enabled, which from my
experience is not the default configuration. Additionally, test_popen2
expects the "cat" utility (such as found in ports of the GNU tools) to
be installed.
Building from source
--------------------
With the EMX port now checked into Python's CVS repository, the build
infrastructure is part of the Python release sourceball.
Prerequisites
First and foremost, you need an operational EMX development installation -
EMX v0.9d with fix04 (the latest at time of writing) & the gcc 2.8.1
compiler released by Eberhard Mattes is the recommended setup.
If you have a different version of gcc installed, see "YOU HAVE BEEN
WARNED" item 16.
Other items of software required:-
- GNU make (I'm using v3.76.1)
- rm, cp, mkdir from the GNU file utilities package
- GNU find
- GNU sed
Procedure
0. all changes mentioned apply to files in the PC/os2emx subdirectory
of the Python release source tree. make is also executed from this
directory, so change into this directory before proceeding.
1. decide if you need to change the location of the Python installation.
If you wish to do this, set the value of the Makefile variable LIB_DIR
to the directory you wish to use for PYTHONHOME
(eg /usr/local/lib/python2.6).
If you want Python to find its library without the PYTHONHOME
environment variable set, set the value of the Makefile variable
FIXED_PYHOME to "yes" (uncomment the appropriate line).
2. If you wish the Python executables (python.exe, pythonpm.exe & pgen.exe)
to be installed in a directory other than the PYTHONHOME directory, set
the value of the Makefile variable EXE_DIR to the appropriate directory.
3. If you wish the Python core DLL (python34.dll) to be installed in a
directory other than the directory in which the Python executables are
installed (by default, the PYTHONHOME directory), set the value of the
Makefile variable DLL_DIR to the appropriate directory. This DLL must
be placed in a directory on the system's LIBPATH, or that gets set
with BEGINLIBPATH or ENDLIBPATH.
4. If you have installed any of the libraries that can be used to build
optional Python modules, set the value of the relevant HAVE_<package>
Makefile variable to "yes". The Makefile currently supports:
library Makefile variable
........................................
zlib (1.1.4) HAVE_ZLIB
GNU UltraFast Crypt HAVE_UFC
Tcl/Tk HAVE_TCLTK (not known to work)
GNU Readline HAVE_GREADLINE
ncurses HAVE_NCURSES
GNU gdbm HAVE_GDBM
libbz2 HAVE_BZ2
OpenSSL HAVE_OPENSSL
Please note that you need to check that what you have installed
is compatible with Python's build options. In particular, the
BSD DB v1.85 library needs to be rebuilt with a source patch for
multithread support (doesn't change the library's reentrant status
but allows it to be linked to Python which is multithreaded).
Widely available binary packages of other librarys & DLLs are
not built/linked with multithread support. Beware!
Also note that the Makefile currently expects any libraries to be
found with the default library search path. You may need to add
-L switches to the LDFLAGS Makefile variable if you have installed
libraries in directories not in the default search path (which can
be controlled by the LIBRARY_PATH environment variable used by EMX).
5. make
It is usually a good idea to redirect the stdout and stderr streams
of the make process to log files, so that you can review any messages.
6. make test
This runs the Python regression tests, and completion is a sign of
a usable build. You should check the list of skipped modules to
ensure that any optional modules you selected have been built;
checking the list of failures against the list of known failures
elsewhere in this document is also prudent.
7. make install
>>>>>> NOT YET COMPLETE <<<<<<
8. change to a directory outside the Python source tree and start Python.
Check the version and build date to confirm satisfactory installation.
YOU HAVE BEEN WARNED!!
----------------------
I know about a number of nasties in this port.
1. Eberhard Mattes, author of EMX, writes in his documentation that fork()
is very inefficient in the OS/2 environment. It also requires that the
executable be linked in a.out format rather than OMF. Use the os.exec
and/or the os.spawn family of functions where possible.
2. In the absence of GNU Readline, terminating the interpreter requires a
control-Z (^Z) followed by a carriage return. Jeff Rush documented this
problem in his Python 1.5.2 port. With Readline, a control-D (^D) works
as per the standard Unix environment.
3. EMX only has a partial implementation of fcntl(). The fcntl module
in this port supports what EMX supports. If fcntl is important to you,
please review the EMX C Library Reference (included in .INF format in the
EMXVIEW.ZIP archive as part of the complete EMX development tools suite).
Because of other side-effects I have modified the test_fcntl.py test
script to deactivate the exercising of the missing functionality.
4. The readline module has been linked against ncurses rather than the
termcap library supplied with EMX.
5. I have configured this port to use "/" as the preferred path separator
character, rather than "\" ('\\'), in line with the convention supported
by EMX. Backslashes are still supported of course, and still appear in
unexpected places due to outside sources that don't get normalised.
6. While the DistUtils components are now functional, other
packaging/binary handling tools and utilities such as those included in
the Demo and Tools directories - freeze in particular - are unlikely to
work. If you do get them going, I'd like to know about your success.
7. I haven't set out to support the [BEGIN|END]LIBPATH functionality
supported by one of the earlier ports (Rush's??). If it works let me know.
8. As a result of the limitations imposed by EMX's library routines, the
standard extension module pwd only synthesises a simple passwd database,
and the grp module cannot be supported at all.
I have written pure Python substitutes for pwd and grp, which can process
real passwd and group files for those applications (such as MailMan) that
require more than EMX emulates. I have placed pwd.py and grp.py in
Lib/plat-os2emx, which is usually before Lib/lib-dynload (which contains
pwd.pyd) in the PYTHONPATH. If you have become attached to what pwd.pyd
supports, you can put Lib/lib-dynload before Lib/plat-os2emx in PYTHONPATH
or delete/rename pwd.py & grp.py.
pwd.py & grp.py support locating their data files by looking in the
environment for them in the following sequence:
pwd.py: $ETC_PASSWD (%ETC_PASSWD%)
$ETC/passwd (%ETC%/passwd)
$PYTHONHOME/Etc/passwd (%PYTHONHOME%/Etc/passwd)
grp.py: $ETC_GROUP (%ETC_GROUP%)
$ETC/group (%ETC%/group)
$PYTHONHOME/Etc/group (%PYTHONHOME%/Etc/group)
The ETC_PASSWD and ETC_GROUP environment variables are intended to allow
support for multiple passwd/grp files, where other applications may not
support as wide a variety of input variations (drive remappings,
separators etc).
Both modules support using either the ":" character (Unix standard) or
";" (OS/2, DOS, Windows standard) field separator character, and pwd.py
implements the following drive letter conversions for the home_directory and
shell fields (for the ":" separator only):
$x -> x:
x; -> x:
Example versions of passwd and group are in the Etc subdirectory. The
regression tests (test_pwd and test_grp) will fail if valid password and
group files cannot be found, but should pass otherwise.
Be aware that Python's pwd & group modules are for reading password and
group information only.
11. EMX's termios routines don't support all of the functionality now
exposed by the termios module - refer to the EMX documentation to find
out what is supported.
12. The case sensitive import semantics introduced in Python 2.1 for other
case insensitive but case preserving file/operating systems (Windows etc),
have been incorporated into this port, and are active by default. Setting
the PYTHONCASEOK environment variable (to any value) reverts to the
previous (case insensitive) semantics. This can be an issue with some
file management utilities that do not preserve the case of file and
directory names.
13. Because I am statically linking ncurses, the _curses_panel
module has potential problems arising from separate library data areas.
To avoid this, I have configured the _curses_.pyd (imported as
"_curses_panel") to import the ncurses symbols it needs from _curses.dll
(which is the curses module, but with a .dll extension rather than .pyd
so that the dynamic loader can actually import the symbols from it as a
DLL).
The site module (Lib/site.py) has code added to tweak BEGINLIBPATH so
that _curses.dll is found when _curses_panel is imported. If you have
problems attempting to use the _curses_panel support please let me know,
and I'll have another look at this.
14. sys.platform reports "os2emx" instead of "os2". os.name still
reports "os2". This change was to make it easier to distinguish between
the VAC++ build (formerly maintained by Michael Muller) and the EMX build
(this port), principally for DistUtils.
15. it appears that the %W substitution in the EMX strftime() routine has
an off-by-one bug. strftime was listed as passing the regression tests
in previous releases, but this fact appears to have been an oversight in
the regression test suite. To fix this really requires a portable
strftime routine - I'm looking into using one from FreeBSD, but its not
ready yet.
16. I have successfully built this port with Andy Zabolotny's ports of
pgcc 2.95 and gcc 3.2.1, in addition to EM's gcc 2.8.1.
I have not attempted to compile Python with any version of gcc prior to
v2.8.1.
This release sees the default optimisation change to
"-O3 -fomit-frame-pointer -mprobe". This works fine too for pgcc 2.95
but not for gcc 3.2.1.
With gcc 3.2.1, -O3 causes 2 unexpected test failures: test_format and
test_unicode. Both these tests pass if -O2 is instead of -O3 with this
compiler, and the performance difference is negligible (in contrast to
gcc 2.8.1 and pgcc 2.95, where the performance difference between the
2 optimisation settings approaches 10%).
17. os.spawnv() and os.spawnve() expose EMX's library routines rather
than use the emulation in os.py.
In order to make use of some of the features this makes available in
the OS/2 environment, you should peruse the relevant EMX documentation
(EMXLIB.INF in the EMXVIEW.ZIP archive accompanying the EMX archives
on Hobbes or LEO). Be aware that I have exposed all the "mode" options
supported by EMX, but there are combinations that either cannot be
practically used by/in Python or have the potential to compromise your
system's stability.
18. pythonpm.exe used to be just python.exe with the WINDOWAPI linker
option set in the pythonpm.def file. In practice, this turns out to do
nothing useful.
I have written a replacement which wraps the Python DLL in a genuine
Presentation Manager application. This version actually runs the
Python interpreter in a separate thread from the PM shell, in order
that PythonPM has a functioning message queue as good PM apps should.
In its current state, PythonPM's window is hidden. It can be displayed,
although it will have no content as nothing is ever written to the
window. Only the "hide" button is available. Although the code
has support for shutting PythonPM down when the Python interpreter is
still busy (via the "control" menu), this is not well tested and given
comments I've come across in EMX documentation suggesting that the
thread killing operation has problems I would suggest caution in
relying on this capability.
PythonPM processes commandline parameters normally. The standard input,
output and error streams are only useful if redirected, as PythonPM's
window is not a console in any form and so cannot accept or display
anything. This means that the -i option is ineffective.
Because the Python thread doesn't create its own message queue, creating
PM Windows and performing most PM operations is not possible from within
this thread. How this will affect supporting PM extensions (such as
Tkinter using a PM port of Tcl/Tk, or wxPython using the PM port of
WxWindows) is still being researched.
Note that os.fork() _DOES_NOT_WORK_ in PythonPM - SYS3175s are the result
of trying. os.spawnv() _does_ work. PythonPM passes all regression tests
that the standard Python interpreter (python.exe) passes, with the exception
of test_fork1 and test_socket which both attempt to use os.fork().
I very much want feedback on the performance, behaviour and utility of
PythonPM. I would like to add a PM console capability to it, but that
will be a non-trivial effort. I may be able to leverage the code in
Illya Vaes' Tcl/Tk port, which would make it easier.
19. os.chdir() uses EMX's _chdir2(), which supports changing both drive
and directory at once. Similarly, os.getcwd() uses EMX's _getcwd()
which returns drive as well as path.
20. pyconfig.h is installed in the Include subdirectory with all
other include files.
21. the default build explicitly sets the number of file handles
available to a Python process to 250. EMX default is 40, which is
insufficient for the tempfile regression test (test_tempfile) which
tries to create 100 temporary files.
This setting can be overridden via the EMXOPT environment variable:
set EMXOPT=-h250
is equivalent to the setting currently used. The emxbind utility (if you
have it installed) can also be used to permanently change the setting in
python.exe - please refer to the EMX documentation for more information.
22. a pure python strptime module is now part of the Python standard
library, superceding a platform specific extension module. This module
leverages the strftime module, and as a result test_strptime fails
due to the EMX strftime bug in item 20 above.
23. test_posixpath attempts to exercise various Posix path related
functionality. Most of the sub-tests pass, but the "ismount" and
"samestat" subtests fail:
- EMX provides not satisfactory mount point emulation, so "ismount"
cannot succeed;
- EMX documents that successive stat() calls will produce different
results, so "samestat" cannot succeed.
test_posixpath should skip these tests on EMX.
24. I have reports of BitTorrent not working. It appears that the
EMX select() emulation, possibly in concert with bugs in the TCP/IP
stack, runs into problems under the stress imposed by this application.
I think it suffices to say that BitTorrent is a fair stress test of a
system's networking capability.
25. In the absence of an EMX implementation of the link() function, I've
implemented a crude Python emulation, in the file
Lib/plat-os2emx/_emx_link.py. This is imported into the os module, and
becomes available as os.link() in the normal way.
The emulation copies the source file in binary mode, and will fail if
disk space is exhausted. The call fails if the target already exists.
There are no guarantees to thread safety with this emulation - beware!
The emulation was written to support a link() based file locking system
used in GNU Mailman.
26. AF_UNIX sockets, otherwise known as Unix domain sockets, are now
supported. Unfortunately, there are some traps arising from the
implementation in IBM's TCP/IP stack:-
- the path name must start with '\\socket\\' ('/socket/' won't work!),
with the length of the full path name less than 108 characters;
- unlike Unix, the socket endpoints don't exist in the filesystem;
- by default, sockets are in binary mode.
27. As of Python 2.4, the mpz, rotor and xreadlines modules have been
dropped from the Python source tree.
28. The subprocess module was added to the standard library relatively
late in the 2.4 development cycle. Unfortunately I haven't had the
round tuits to adapt the module to the EMX environment yet, and
test_subprocess has a number of failures as a result.
29. The default stack size for threads has been 64k. This is proving
insufficient for some codebases, such as Zope. The thread stack size
still defaults to 64k, but this can now be increased via the stack_size()
function exposed by the threading & thread modules as well as by defining
THREAD_STACK_SIZE to an appropriate value in the Makefile (which contains
a commented out definition for 128kB thread stacks). I have seen
references to heavy Zope/Plone usage requiring 1MB thread stacks on
FreeBSD and Linux, but doubt that for most likely usage on OS/2 that
more than 256kB is necessary. The size of the required stacks (main
and thread) can vary significantly depending on which version of gcc
is used along with the compiler optimisations selected. Note that the
main thread stack size is set during linking and is currently 2MB.
... probably other issues that I've not encountered, or don't remember :-(
If you encounter other difficulties with this port, which can be
characterised as peculiar to this port rather than to the Python release,
I would like to hear about them. However I cannot promise to be able to do
anything to resolve such problems. See the Contact section below...
To do...
--------
In no particular order of apparent importance or likelihood...
- support Tkinter and/or alternative GUI (wxWindows??)
Credits
-------
In addition to people identified above, I'd like to thank:
- the BDFL, Guido van Rossum, and crew for Python;
- Dr David Mertz, for trying out a pre-release of this port;
- the Python-list/comp.lang.python community;
- John Poltorak, for input about pwd/grp.
Contact
-------
Constructive feedback, negative or positive, about this port is welcome
and should be addressed to me at the e-mail addresses below.
I have a private mailing list for announcements of fixes & updates to
this port. If you wish to receive such e-mail announcments, please send
me an e-mail requesting that you be added to this list.
Andrew MacIntyre
E-mail: andymac@bullseye.apana.org.au, or andymac@pcug.org.au
Web: http://www.andymac.org/
28 January, 2008.

View File

@ -1,164 +0,0 @@
/* -*- C -*- ***********************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Module configuration */
/* This file contains the table of built-in modules.
See init_builtin() in import.c. */
#include "Python.h"
extern void initos2();
extern void initsignal();
#ifdef WITH_THREAD
extern void init_thread();
#endif
extern void init_codecs();
extern void init_csv();
extern void init_locale();
extern void init_random();
extern void init_sre();
extern void init_symtable();
extern void init_weakref();
extern void initarray();
extern void initbinascii();
extern void initcollections();
extern void initcmath();
extern void initdatetime();
extern void initdl();
extern void initerrno();
extern void initfcntl();
extern void init_functools();
extern void init_heapq();
extern void initimageop();
extern void inititertools();
extern void initmath();
extern void init_md5();
extern void initoperator();
extern void init_sha();
extern void init_sha256();
extern void init_sha512();
extern void init_struct();
extern void inittermios();
extern void inittime();
extern void initxxsubtype();
extern void initzipimport();
#if !HAVE_DYNAMIC_LOADING
extern void init_curses();
extern void init_curses_panel();
extern void init_testcapi();
extern void initbz2();
extern void initfpectl();
extern void initfpetest();
extern void initparser();
extern void initpwd();
extern void initunicodedata();
extern void initzlib();
#ifdef USE_SOCKET
extern void init_socket();
extern void initselect();
#endif
#endif
/* -- ADDMODULE MARKER 1 -- */
extern void PyMarshal_Init();
extern void initimp();
extern void initgc();
struct _inittab _PyImport_Inittab[] = {
{"os2", initos2},
{"signal", initsignal},
#ifdef WITH_THREAD
{"_thread", init_thread},
#endif
{"_codecs", init_codecs},
{"_csv", init_csv},
{"_locale", init_locale},
{"_random", init_random},
{"_sre", init_sre},
{"_symtable", init_symtable},
{"_weakref", init_weakref},
{"array", initarray},
{"binascii", initbinascii},
{"collections", initcollections},
{"cmath", initcmath},
{"datetime", initdatetime},
{"dl", initdl},
{"errno", initerrno},
{"fcntl", initfcntl},
{"_functools", init_functools},
{"_heapq", init_heapq},
{"imageop", initimageop},
{"itertools", inititertools},
{"math", initmath},
{"operator", initoperator},
{"_sha256", init_sha256},
{"_sha512", init_sha512},
{"_struct", init_struct},
{"termios", inittermios},
{"time", inittime},
{"xxsubtype", initxxsubtype},
{"zipimport", initzipimport},
#if !HAVE_DYNAMIC_LOADING
{"_curses", init_curses},
{"_curses_panel", init_curses_panel},
{"_testcapi", init_testcapi},
{"bz2", initbz2},
{"fpectl", initfpectl},
{"fpetest", initfpetest},
{"parser", initparser},
{"pwd", initpwd},
{"unicodedata", initunicodedata},
{"zlib", initzlib},
#ifdef USE_SOCKET
{"_socket", init_socket},
{"select", initselect},
#endif
#endif
/* -- ADDMODULE MARKER 2 -- */
/* This module "lives in" with marshal.c */
{"marshal", PyMarshal_Init},
/* This lives it with import.c */
{"_imp", initimp},
/* These entries are here for sys.builtin_module_names */
{"builtins", NULL},
{"sys", NULL},
/* This lives in gcmodule.c */
{"gc", initgc},
/* Sentinel */
{0, 0}
};

View File

@ -1,223 +0,0 @@
/* -*- C -*- ***********************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* This library implements dlopen() - Unix-like dynamic linking
* emulation functions for OS/2 using DosLoadModule() and company.
*/
#define INCL_DOS
#define INCL_DOSERRORS
#define INCL_DOSSESMGR
#define INCL_WINPROGRAMLIST
#define INCL_WINFRAMEMGR
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
typedef struct _track_rec {
char *name;
HMODULE handle;
void *id;
struct _track_rec *next;
} tDLLchain, *DLLchain;
static DLLchain dlload = NULL; /* A simple chained list of DLL names */
static char dlerr [256]; /* last error text string */
static void *last_id;
static DLLchain find_id(void *id)
{
DLLchain tmp;
for (tmp = dlload; tmp; tmp = tmp->next)
if (id == tmp->id)
return tmp;
return NULL;
}
/* load a dynamic-link library and return handle */
void *dlopen(char *filename, int flags)
{
HMODULE hm;
DLLchain tmp;
char err[256];
char *errtxt;
int rc = 0, set_chain = 0;
for (tmp = dlload; tmp; tmp = tmp->next)
if (strnicmp(tmp->name, filename, 999) == 0)
break;
if (!tmp)
{
tmp = (DLLchain) malloc(sizeof(tDLLchain));
if (!tmp)
goto nomem;
tmp->name = strdup(filename);
tmp->next = dlload;
set_chain = 1;
}
switch (rc = DosLoadModule((PSZ)&err, sizeof(err), filename, &hm))
{
case NO_ERROR:
tmp->handle = hm;
if (set_chain)
{
do
last_id++;
while ((last_id == 0) || (find_id(last_id)));
tmp->id = last_id;
dlload = tmp;
}
return tmp->id;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errtxt = "module `%s' not found";
break;
case ERROR_TOO_MANY_OPEN_FILES:
case ERROR_NOT_ENOUGH_MEMORY:
case ERROR_SHARING_BUFFER_EXCEEDED:
nomem:
errtxt = "out of system resources";
break;
case ERROR_ACCESS_DENIED:
errtxt = "access denied";
break;
case ERROR_BAD_FORMAT:
case ERROR_INVALID_SEGMENT_NUMBER:
case ERROR_INVALID_ORDINAL:
case ERROR_INVALID_MODULETYPE:
case ERROR_INVALID_EXE_SIGNATURE:
case ERROR_EXE_MARKED_INVALID:
case ERROR_ITERATED_DATA_EXCEEDS_64K:
case ERROR_INVALID_MINALLOCSIZE:
case ERROR_INVALID_SEGDPL:
case ERROR_AUTODATASEG_EXCEEDS_64K:
case ERROR_RELOCSRC_CHAIN_EXCEEDS_SEGLIMIT:
errtxt = "invalid module format";
break;
case ERROR_INVALID_NAME:
errtxt = "filename doesn't match module name";
break;
case ERROR_SHARING_VIOLATION:
case ERROR_LOCK_VIOLATION:
errtxt = "sharing violation";
break;
case ERROR_INIT_ROUTINE_FAILED:
errtxt = "module initialization failed";
break;
default:
errtxt = "cause `%s', error code = %d";
break;
}
snprintf(dlerr, sizeof(dlerr), errtxt, &err, rc);
if (tmp)
{
if (tmp->name)
free(tmp->name);
free(tmp);
}
return 0;
}
/* return a pointer to the `symbol' in DLL */
void *dlsym(void *handle, char *symbol)
{
int rc = 0;
PFN addr;
char *errtxt;
int symord = 0;
DLLchain tmp = find_id(handle);
if (!tmp)
goto inv_handle;
if (*symbol == '#')
symord = atoi(symbol + 1);
switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr))
{
case NO_ERROR:
return (void *)addr;
case ERROR_INVALID_HANDLE:
inv_handle:
errtxt = "invalid module handle";
break;
case ERROR_PROC_NOT_FOUND:
case ERROR_INVALID_NAME:
errtxt = "no symbol `%s' in module";
break;
default:
errtxt = "symbol `%s', error code = %d";
break;
}
snprintf(dlerr, sizeof(dlerr), errtxt, symbol, rc);
return NULL;
}
/* free dynamically-linked library */
int dlclose(void *handle)
{
int rc;
DLLchain tmp = find_id(handle);
if (!tmp)
goto inv_handle;
switch (rc = DosFreeModule(tmp->handle))
{
case NO_ERROR:
free(tmp->name);
dlload = tmp->next;
free(tmp);
return 0;
case ERROR_INVALID_HANDLE:
inv_handle:
strcpy(dlerr, "invalid module handle");
return -1;
case ERROR_INVALID_ACCESS:
strcpy(dlerr, "access denied");
return -1;
default:
return -1;
}
}
/* return a string describing last occurred dl error */
char *dlerror()
{
return dlerr;
}

View File

@ -1,51 +0,0 @@
/* -*- C -*- ***********************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* This library implements dlopen() - Unix-like dynamic linking
* emulation functions for OS/2 using DosLoadModule() and company.
*/
#ifndef _DLFCN_H
#define _DLFCN_H
/* load a dynamic-link library and return handle */
void *dlopen(char *filename, int flags);
/* return a pointer to the `symbol' in DLL */
void *dlsym(void *handle, char *symbol);
/* free dynamically-linked library */
int dlclose(void *handle);
/* return a string describing last occurred dl error */
char *dlerror(void);
#endif /* !_DLFCN_H */

View File

@ -1,42 +0,0 @@
/*
* This is the entry point for the Python 2.3 core DLL.
*/
#define NULL 0
#define REF(s) extern void s(); void *____ref_##s = &s;
/* Make references to imported symbols to pull them from static library */
REF(Py_Main);
#include <signal.h>
extern int _CRT_init(void);
extern void _CRT_term(void);
extern void __ctordtorInit(void);
extern void __ctordtorTerm(void);
unsigned long _DLL_InitTerm(unsigned long mod_handle, unsigned long flag)
{
switch (flag)
{
case 0:
if (_CRT_init())
return 0;
__ctordtorInit();
/* Ignore fatal signals */
signal(SIGSEGV, SIG_IGN);
signal(SIGFPE, SIG_IGN);
return 1;
case 1:
__ctordtorTerm();
_CRT_term();
return 1;
default:
return 0;
}
}

View File

@ -1,418 +0,0 @@
/* Return the initial module search path. */
/* This version used by OS/2+EMX */
/* ----------------------------------------------------------------
PATH RULES FOR OS/2+EMX:
This describes how sys.path is formed on OS/2+EMX. It describes the
functionality, not the implementation (ie, the order in which these
are actually fetched is different)
* Python always adds an empty entry at the start, which corresponds
to the current directory.
* If the PYTHONPATH env. var. exists, its entries are added next.
* We attempt to locate the "Python Home" - if the PYTHONHOME env var
is set, we believe it. Otherwise, we use the path of our host .EXE's
to try and locate our "landmark" (lib\\os.py) and deduce our home.
- If we DO have a Python Home: The relevant sub-directories (Lib,
plat-win, etc) are based on the Python Home
- If we DO NOT have a Python Home, the core Python Path is
loaded from the registry. This is the main PythonPath key,
and both HKLM and HKCU are combined to form the path)
* Iff - we can not locate the Python Home, and have not had a PYTHONPATH
specified (ie, we have _nothing_ we can assume is a good path), a
default path with relative entries is used (eg. .\Lib;.\plat-win, etc)
The end result of all this is:
* When running python.exe, or any other .exe in the main Python directory
(either an installed version, or directly from the PCbuild directory),
the core path is deduced.
* When Python is hosted in another exe (different directory, embedded via
COM, etc), the Python Home will not be deduced, so the core path from
the registry is used. Other "application paths "in the registry are
always read.
* If Python can't find its home and there is no registry (eg, frozen
exe, some very strange installation setup) you get a path with
some default, but relative, paths.
---------------------------------------------------------------- */
#include "Python.h"
#include "osdefs.h"
#ifndef PYOS_OS2
#error This file only compilable on OS/2
#endif
#define INCL_DOS
#include <os2.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
/* Search in some common locations for the associated Python libraries.
*
* Py_GetPath() tries to return a sensible Python module search path.
*
* The approach is an adaptation for Windows of the strategy used in
* ../Modules/getpath.c; it uses the Windows Registry as one of its
* information sources.
*/
#ifndef LANDMARK
#if defined(PYCC_GCC)
#define LANDMARK "lib/os.py"
#else
#define LANDMARK "lib\\os.py"
#endif
#endif
static char prefix[MAXPATHLEN+1];
static char progpath[MAXPATHLEN+1];
static char *module_search_path = NULL;
static int
is_sep(char ch) /* determine if "ch" is a separator character */
{
#ifdef ALTSEP
return ch == SEP || ch == ALTSEP;
#else
return ch == SEP;
#endif
}
/* assumes 'dir' null terminated in bounds.
* Never writes beyond existing terminator.
*/
static void
reduce(char *dir)
{
size_t i = strlen(dir);
while (i > 0 && !is_sep(dir[i]))
--i;
dir[i] = '\0';
}
static int
exists(char *filename)
{
struct stat buf;
return stat(filename, &buf) == 0;
}
/* Is module (check for .pyc/.pyo too)
* Assumes 'filename' MAXPATHLEN+1 bytes long -
* may extend 'filename' by one character.
*/
static int
ismodule(char *filename)
{
if (exists(filename))
return 1;
/* Check for the compiled version of prefix. */
if (strlen(filename) < MAXPATHLEN) {
strcat(filename, Py_OptimizeFlag ? "o" : "c");
if (exists(filename))
return 1;
}
return 0;
}
/* Add a path component, by appending stuff to buffer.
buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a
NUL-terminated string with no more than MAXPATHLEN characters (not counting
the trailing NUL). It's a fatal error if it contains a string longer than
that (callers must be careful!). If these requirements are met, it's
guaranteed that buffer will still be a NUL-terminated string with no more
than MAXPATHLEN characters at exit. If stuff is too long, only as much of
stuff as fits will be appended.
*/
static void
join(char *buffer, char *stuff)
{
size_t n, k;
if (is_sep(stuff[0]))
n = 0;
else {
n = strlen(buffer);
if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN)
buffer[n++] = SEP;
}
if (n > MAXPATHLEN)
Py_FatalError("buffer overflow in getpathp.c's joinpath()");
k = strlen(stuff);
if (n + k > MAXPATHLEN)
k = MAXPATHLEN - n;
strncpy(buffer+n, stuff, k);
buffer[n+k] = '\0';
}
/* gotlandmark only called by search_for_prefix, which ensures
* 'prefix' is null terminated in bounds. join() ensures
* 'landmark' can not overflow prefix if too long.
*/
static int
gotlandmark(char *landmark)
{
int n, ok;
n = strlen(prefix);
join(prefix, landmark);
ok = ismodule(prefix);
prefix[n] = '\0';
return ok;
}
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
* assumption provided by only caller, calculate_path()
*/
static int
search_for_prefix(char *argv0_path, char *landmark)
{
/* Search from argv0_path, until landmark is found */
strcpy(prefix, argv0_path);
do {
if (gotlandmark(landmark))
return 1;
reduce(prefix);
} while (prefix[0]);
return 0;
}
static void
get_progpath(void)
{
extern char *Py_GetProgramName(void);
char *path = getenv("PATH");
char *prog = Py_GetProgramName();
PPIB pib;
if ((DosGetInfoBlocks(NULL, &pib) == 0) &&
(DosQueryModuleName(pib->pib_hmte, sizeof(progpath), progpath) == 0))
return;
if (prog == NULL || *prog == '\0')
prog = "python";
/* If there is no slash in the argv0 path, then we have to
* assume python is on the user's $PATH, since there's no
* other way to find a directory to start the search from. If
* $PATH isn't exported, you lose.
*/
#ifdef ALTSEP
if (strchr(prog, SEP) || strchr(prog, ALTSEP))
#else
if (strchr(prog, SEP))
#endif
strncpy(progpath, prog, MAXPATHLEN);
else if (path) {
while (1) {
char *delim = strchr(path, DELIM);
if (delim) {
size_t len = delim - path;
/* ensure we can't overwrite buffer */
#if !defined(PYCC_GCC)
len = min(MAXPATHLEN,len);
#else
len = MAXPATHLEN < len ? MAXPATHLEN : len;
#endif
strncpy(progpath, path, len);
*(progpath + len) = '\0';
}
else
strncpy(progpath, path, MAXPATHLEN);
/* join() is safe for MAXPATHLEN+1 size buffer */
join(progpath, prog);
if (exists(progpath))
break;
if (!delim) {
progpath[0] = '\0';
break;
}
path = delim + 1;
}
}
else
progpath[0] = '\0';
}
static void
calculate_path(void)
{
char argv0_path[MAXPATHLEN+1];
char *buf;
size_t bufsz;
char *pythonhome = Py_GetPythonHome();
char *envpath = getenv("PYTHONPATH");
char zip_path[MAXPATHLEN+1];
size_t len;
get_progpath();
/* progpath guaranteed \0 terminated in MAXPATH+1 bytes. */
strcpy(argv0_path, progpath);
reduce(argv0_path);
if (pythonhome == NULL || *pythonhome == '\0') {
if (search_for_prefix(argv0_path, LANDMARK))
pythonhome = prefix;
else
pythonhome = NULL;
}
else
strncpy(prefix, pythonhome, MAXPATHLEN);
if (envpath && *envpath == '\0')
envpath = NULL;
/* Calculate zip archive path */
strncpy(zip_path, progpath, MAXPATHLEN);
zip_path[MAXPATHLEN] = '\0';
len = strlen(zip_path);
if (len > 4) {
zip_path[len-3] = 'z'; /* change ending to "zip" */
zip_path[len-2] = 'i';
zip_path[len-1] = 'p';
}
else {
zip_path[0] = 0;
}
/* We need to construct a path from the following parts.
* (1) the PYTHONPATH environment variable, if set;
* (2) the zip archive file path;
* (3) the PYTHONPATH config macro, with the leading "."
* of each component replaced with pythonhome, if set;
* (4) the directory containing the executable (argv0_path).
* The length calculation calculates #3 first.
*/
/* Calculate size of return buffer */
if (pythonhome != NULL) {
char *p;
bufsz = 1;
for (p = PYTHONPATH; *p; p++) {
if (*p == DELIM)
bufsz++; /* number of DELIM plus one */
}
bufsz *= strlen(pythonhome);
}
else
bufsz = 0;
bufsz += strlen(PYTHONPATH) + 1;
bufsz += strlen(argv0_path) + 1;
bufsz += strlen(zip_path) + 1;
if (envpath != NULL)
bufsz += strlen(envpath) + 1;
module_search_path = buf = malloc(bufsz);
if (buf == NULL) {
/* We can't exit, so print a warning and limp along */
fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n");
if (envpath) {
fprintf(stderr, "Using environment $PYTHONPATH.\n");
module_search_path = envpath;
}
else {
fprintf(stderr, "Using default static path.\n");
module_search_path = PYTHONPATH;
}
return;
}
if (envpath) {
strcpy(buf, envpath);
buf = strchr(buf, '\0');
*buf++ = DELIM;
}
if (zip_path[0]) {
strcpy(buf, zip_path);
buf = strchr(buf, '\0');
*buf++ = DELIM;
}
if (pythonhome == NULL) {
strcpy(buf, PYTHONPATH);
buf = strchr(buf, '\0');
}
else {
char *p = PYTHONPATH;
char *q;
size_t n;
for (;;) {
q = strchr(p, DELIM);
if (q == NULL)
n = strlen(p);
else
n = q-p;
if (p[0] == '.' && is_sep(p[1])) {
strcpy(buf, pythonhome);
buf = strchr(buf, '\0');
p++;
n--;
}
strncpy(buf, p, n);
buf += n;
if (q == NULL)
break;
*buf++ = DELIM;
p = q+1;
}
}
if (argv0_path) {
*buf++ = DELIM;
strcpy(buf, argv0_path);
buf = strchr(buf, '\0');
}
*buf = '\0';
}
/* External interface */
char *
Py_GetPath(void)
{
if (!module_search_path)
calculate_path();
return module_search_path;
}
char *
Py_GetPrefix(void)
{
if (!module_search_path)
calculate_path();
return prefix;
}
char *
Py_GetExecPrefix(void)
{
return Py_GetPrefix();
}
char *
Py_GetProgramFullPath(void)
{
if (!module_search_path)
calculate_path();
return progpath;
}

View File

@ -1,332 +0,0 @@
#ifndef Py_CONFIG_H
#define Py_CONFIG_H
#error "PEP 11: OS/2 is now unsupported, code will be removed in Python 3.4"
/* config.h.
* At some time in the past, generated automatically by/from configure.
* now maintained manually.
*/
/* build environment */
#define PLATFORM "os2emx"
#define COMPILER "[EMX GCC " __VERSION__ "]"
#define PYOS_OS2 1
#define PYCC_GCC 1
/* default location(s) */
#ifndef PREFIX
#define PREFIX ""
#endif
#ifndef PYTHONPATH
#define PYTHONPATH "./Lib;./Lib/plat-" PLATFORM \
";./Lib/lib-dynload;./Lib/site-packages"
#endif
/* Debugging */
#ifndef Py_DEBUG
/*#define Py_DEBUG 1*/
#endif
/* if building an extension or wrapper executable,
* mark Python API symbols "extern" so that symbols
* imported from the Python core DLL aren't duplicated.
*/
#ifdef Py_BUILD_CORE
# define PyAPI_FUNC(RTYPE) RTYPE
#else
# define PyAPI_FUNC(RTYPE) extern RTYPE
#endif
#define PyAPI_DATA(RTYPE) extern RTYPE
#define PyMODINIT_FUNC void
/* Use OS/2 flavour of threads */
#define WITH_THREAD 1
#define OS2_THREADS 1
/* We want sockets */
#define TCPIPV4 1
#define USE_SOCKET 1
#define socklen_t int
#define FD_SETSIZE 1024
/* enable the Python object allocator */
#define WITH_PYMALLOC 1
/* enable the GC module */
#define WITH_CYCLE_GC 1
/* Define if you want documentation strings in extension modules */
#define WITH_DOC_STRINGS 1
/* Unicode related */
#define PY_UNICODE_TYPE wchar_t
#define Py_UNICODE_SIZE SIZEOF_SHORT
/* EMX defines ssize_t */
#define HAVE_SSIZE_T 1
/* system capabilities */
#define HAVE_TTYNAME 1
#define HAVE_WAIT 1
#define HAVE_GETEGID 1
#define HAVE_GETEUID 1
#define HAVE_GETGID 1
#define HAVE_GETPPID 1
#define HAVE_GETUID 1
#define HAVE_OPENDIR 1
#define HAVE_PIPE 1
#define HAVE_POPEN 1
#define HAVE_SYSTEM 1
#define HAVE_TTYNAME 1
#define HAVE_DYNAMIC_LOADING 1
/* if port of GDBM installed, it includes NDBM emulation */
#define HAVE_NDBM_H 1
/* need this for spawnv code in posixmodule (cloned from WIN32 def'n) */
typedef long intptr_t;
/* we don't have tm_zone but do have the external array tzname */
#define HAVE_TZNAME 1
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define this if you have the type long long. */
#define HAVE_LONG_LONG 1
/* Define if your compiler supports function prototypes. */
#define HAVE_PROTOTYPES 1
/* Define if your compiler supports variable length function prototypes
* (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>.
*/
#define HAVE_STDARG_PROTOTYPES 1
/* Define if malloc(0) returns a NULL pointer. */
#define MALLOC_ZERO_RETURNS_NULL 1
/* Define to force use of thread-safe errno, h_errno, and other functions. */
#define _REENTRANT 1
/* Define if you can safely include both <sys/select.h> and <sys/time.h>
* (which you can't on SCO ODT 3.0).
*/
#define SYS_SELECT_WITH_SYS_TIME 1
/* The number of bytes in an off_t. */
#define SIZEOF_OFF_T 4
/* The number of bytes in an time_t. */
#define SIZEOF_TIME_T 4
/* The number of bytes in a short. */
#define SIZEOF_SHORT 2
/* The number of bytes in a int. */
#define SIZEOF_INT 4
/* The number of bytes in a long. */
#define SIZEOF_LONG 4
/* The number of bytes in a long long. */
#define SIZEOF_LONG_LONG 8
/* The number of bytes in a void *. */
#define SIZEOF_VOID_P 4
/* The number of bytes in a size_t. */
#define SIZEOF_SIZE_T 4
/* Define if you have the alarm function. */
#define HAVE_ALARM 1
/* Define if you have the clock function. */
#define HAVE_CLOCK 1
/* Define if you have the dup2 function. */
#define HAVE_DUP2 1
/* Define if you have the execv function. */
#define HAVE_EXECV 1
/* Define if you have the spawnv function. */
#define HAVE_SPAWNV 1
/* Define if you have the flock function. */
#define HAVE_FLOCK 1
/* Define if you have the fork function. */
#define HAVE_FORK 1
/* Define if you have the fsync function. */
#define HAVE_FSYNC 1
/* Define if you have the ftime function. */
#define HAVE_FTIME 1
/* Define if you have the ftruncate function. */
#define HAVE_FTRUNCATE 1
/* Define if you have the getcwd function. */
#define HAVE_GETCWD 1
/* Define if you have the getpeername function. */
#define HAVE_GETPEERNAME 1
/* Define if you have the getpgrp function. */
#define HAVE_GETPGRP 1
/* Define if you have the getpid function. */
#define HAVE_GETPID 1
/* Define if you have the getpwent function. */
#define HAVE_GETPWENT 1
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the getwd function. */
#define HAVE_GETWD 1
/* Define if you have the hypot function. */
#define HAVE_HYPOT 1
/* Define if you have the kill function. */
#define HAVE_KILL 1
/* Define if you have the memmove function. */
#define HAVE_MEMMOVE 1
/* Define if you have the mktime function. */
#define HAVE_MKTIME 1
/* Define if you have the pause function. */
#define HAVE_PAUSE 1
/* Define if you have the putenv function. */
#define HAVE_PUTENV 1
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the setgid function. */
#define HAVE_SETGID 1
/* Define if you have the setlocale function. */
#define HAVE_SETLOCALE 1
/* Define if you have the setpgid function. */
#define HAVE_SETPGID 1
/* Define if you have the setuid function. */
#define HAVE_SETUID 1
/* Define if you have the setvbuf function. */
#define HAVE_SETVBUF 1
/* Define if you have the sigaction function. */
#define HAVE_SIGACTION 1
/* Define if you have the strerror function. */
#define HAVE_STRERROR 1
/* Define if you have the strftime function. */
#define HAVE_STRFTIME 1
/* Define if you have the tcgetpgrp function. */
#define HAVE_TCGETPGRP 1
/* Define if you have the tcsetpgrp function. */
#define HAVE_TCSETPGRP 1
/* Define if you have the tmpfile function. */
#define HAVE_TMPFILE 1
/* Define if you have the times function. */
#define HAVE_TIMES 1
/* Define if you have the truncate function. */
#define HAVE_TRUNCATE 1
/* Define if you have the uname function. */
#define HAVE_UNAME 1
/* Define if you have the waitpid function. */
#define HAVE_WAITPID 1
/* Define if you have the <conio.h> header file. */
#undef HAVE_CONIO_H
/* Define if you have the <direct.h> header file. */
#undef HAVE_DIRECT_H
/* Define if you have the <dirent.h> header file. */
#define HAVE_DIRENT_H 1
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <io.h> header file. */
#undef HAVE_IO_H
/* Define if you have the <ncurses.h> header file. */
#define HAVE_NCURSES_H 1
/* Define to 1 if you have the <process.h> header file. */
#define HAVE_PROCESS_H 1
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <sys/file.h> header file. */
#define HAVE_SYS_FILE_H 1
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/times.h> header file. */
#define HAVE_SYS_TIMES_H 1
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <sys/un.h> header file. */
#define HAVE_SYS_UN_H 1
/* Define if you have the <sys/utsname.h> header file. */
#define HAVE_SYS_UTSNAME_H 1
/* Define if you have the <sys/wait.h> header file. */
#define HAVE_SYS_WAIT_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* EMX has an snprintf(). */
#define HAVE_SNPRINTF 1
#endif /* !Py_CONFIG_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,124 +0,0 @@
/* OS/2 PM main program - creates a hidden window, and starts Python
* interpreter in a separate thread, so that Python scripts can be
* run in PM process space without a console Window. The interpreter
* is incorporated by linking in the Python DLL.
*
* As it stands, I don't think this is adequate for supporting Python
* GUI modules, as the Python thread doesn't have its own message
* queue - which is required of threads that want to create/use
* PM windows.
*
* This code owes a lot to "OS/2 Presentation Manager Programming", by
* Charles Petzold.
*
* Andrew MacIntyre <andymac@bullseye.apana.org.au>, August 2001.
* Released under the terms of the Python 2.1.1 licence - see the LICENCE
* file in the Python v2.1.1 (or later) source distribution.
* Copyright assigned to the Python Software Foundation, 2001.
*/
#define INCL_DOS
#define INCL_WIN
#include <os2.h>
#include <process.h>
#include "Python.h"
/* use structure to pass command line to Python thread */
typedef struct
{
int argc;
char **argv;
HWND Frame;
int running;
} arglist;
/* make this a global to simplify access.
* it should only be set from the Python thread, or by the code that
* initiates the Python thread when the thread cannot be created.
*/
int PythonRC;
extern DL_EXPORT(int) Py_Main(int, char **);
void PythonThread(void *);
int
main(int argc, char **argv)
{
ULONG FrameFlags = FCF_TITLEBAR |
FCF_SYSMENU |
FCF_SIZEBORDER |
FCF_HIDEBUTTON |
FCF_SHELLPOSITION |
FCF_TASKLIST;
HAB hab;
HMQ hmq;
HWND Client;
QMSG qmsg;
arglist args;
int python_tid;
/* init PM and create message queue */
hab = WinInitialize(0);
hmq = WinCreateMsgQueue(hab, 0);
/* create a (hidden) Window to house the window procedure */
args.Frame = WinCreateStdWindow(HWND_DESKTOP,
0,
&FrameFlags,
NULL,
"PythonPM",
0L,
0,
0,
&Client);
/* run Python interpreter in a thread */
args.argc = argc;
args.argv = argv;
args.running = 0;
if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args)))
{
/* couldn't start thread */
WinAlarm(HWND_DESKTOP, WA_ERROR);
PythonRC = 1;
}
else
{
/* process PM messages, until Python exits */
while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
WinDispatchMsg(hab, &qmsg);
if (args.running > 0)
DosKillThread(python_tid);
}
/* destroy window, shutdown message queue and PM */
WinDestroyWindow(args.Frame);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return PythonRC;
}
void PythonThread(void *argl)
{
HAB hab;
arglist *args;
/* PM initialisation */
hab = WinInitialize(0);
/* start Python */
args = (arglist *)argl;
args->running = 1;
PythonRC = Py_Main(args->argc, args->argv);
/* enter a critical section and send the termination message */
DosEnterCritSec();
args->running = 0;
WinPostMsg(args->Frame, WM_QUIT, NULL, NULL);
/* shutdown PM and terminate thread */
WinTerminate(hab);
_endthread();
}

View File

@ -1,8 +0,0 @@
LIBRARY _TKINTER INITINSTANCE TERMINSTANCE
DESCRIPTION 'Python Extension DLL v1.0 for Access to Tcl/Tk Environment'
PROTMODE
DATA MULTIPLE NONSHARED
EXPORTS
init_tkinter

View File

@ -1,99 +0,0 @@
/* -*- C -*- ***********************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
All rights reserved.
See the file "Misc/COPYRIGHT" for information on usage and
redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
******************************************************************/
/* Module configuration */
/* This file contains the table of built-in modules.
See init_builtin() in import.c. */
#include "Python.h"
extern void initarray(void);
extern void initaudioop(void);
extern void initbinascii(void);
extern void initcmath(void);
extern void initerrno(void);
extern void initimageop(void);
extern void initmath(void);
extern void initmd5(void);
extern void initnt(void);
extern void initos2(void);
extern void initoperator(void);
extern void initposix(void);
extern void initrgbimg(void);
extern void initsignal(void);
extern void initselect(void);
extern void init_socket(void);
extern void initstruct(void);
extern void inittime(void);
extern void init_thread(void);
extern void initpcre(void);
#ifdef WIN32
extern void initmsvcrt(void);
#endif
/* -- ADDMODULE MARKER 1 -- */
extern void PyMarshal_Init(void);
extern void initimp(void);
struct _inittab _PyImport_Inittab[] = {
{"array", initarray},
#ifdef M_I386
{"audioop", initaudioop},
#endif
{"binascii", initbinascii},
{"cmath", initcmath},
{"errno", initerrno},
// {"imageop", initimageop},
{"math", initmath},
{"md5", initmd5},
#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__)
{"nt", initnt}, /* Use the NT os functions, not posix */
#else
#if defined(PYOS_OS2)
{"os2", initos2},
#else
{"posix", initposix},
#endif
#endif
{"operator", initoperator},
// {"rgbimg", initrgbimg},
{"signal", initsignal},
#ifdef USE_SOCKET
{"_socket", init_socket},
{"select", initselect},
#endif
{"struct", initstruct},
{"time", inittime},
#ifdef WITH_THREAD
{"_thread", init_thread},
#endif
{"pcre", initpcre},
#ifdef WIN32
{"msvcrt", initmsvcrt},
#endif
/* -- ADDMODULE MARKER 2 -- */
/* This module "lives in" with marshal.c */
{"marshal", PyMarshal_Init},
/* This lives it with import.c */
{"_imp", initimp},
/* These entries are here for sys.builtin_module_names */
{"builtins", NULL},
{"sys", NULL},
/* Sentinel */
{0, 0}
};

View File

@ -1,482 +0,0 @@
/* Return the initial module search path. */
/* Used by DOS, OS/2, Windows 3.1. Works on NT too. */
#include "Python.h"
#include "osdefs.h"
#ifdef MS_WIN32
#include <windows.h>
extern BOOL PyWin_IsWin32s(void);
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
/* Search in some common locations for the associated Python libraries.
*
* Two directories must be found, the platform independent directory
* (prefix), containing the common .py and .pyc files, and the platform
* dependent directory (exec_prefix), containing the shared library
* modules. Note that prefix and exec_prefix can be the same directory,
* but for some installations, they are different.
*
* Py_GetPath() tries to return a sensible Python module search path.
*
* First, we look to see if the executable is in a subdirectory of
* the Python build directory. We calculate the full path of the
* directory containing the executable as progpath. We work backwards
* along progpath and look for $dir/Modules/Setup.in, a distinctive
* landmark. If found, we use $dir/Lib as $root. The returned
* Python path is the compiled #define PYTHONPATH with all the initial
* "./lib" replaced by $root.
*
* Otherwise, if there is a PYTHONPATH environment variable, we return that.
*
* Otherwise we try to find $progpath/lib/os.py, and if found, then
* root is $progpath/lib, and we return Python path as compiled PYTHONPATH
* with all "./lib" replaced by $root (as above).
*
*/
#ifndef LANDMARK
#define LANDMARK "lib\\os.py"
#endif
static char prefix[MAXPATHLEN+1];
static char exec_prefix[MAXPATHLEN+1];
static char progpath[MAXPATHLEN+1];
static char *module_search_path = NULL;
static int
is_sep(char ch) /* determine if "ch" is a separator character */
{
#ifdef ALTSEP
return ch == SEP || ch == ALTSEP;
#else
return ch == SEP;
#endif
}
static void
reduce(char *dir)
{
int i = strlen(dir);
while (i > 0 && !is_sep(dir[i]))
--i;
dir[i] = '\0';
}
static int
exists(char *filename)
{
struct stat buf;
return stat(filename, &buf) == 0;
}
/* Add a path component, by appending stuff to buffer.
buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a
NUL-terminated string with no more than MAXPATHLEN characters (not counting
the trailing NUL). It's a fatal error if it contains a string longer than
that (callers must be careful!). If these requirements are met, it's
guaranteed that buffer will still be a NUL-terminated string with no more
than MAXPATHLEN characters at exit. If stuff is too long, only as much of
stuff as fits will be appended.
*/
static void
join(char *buffer, char *stuff)
{
int n, k;
if (is_sep(stuff[0]))
n = 0;
else {
n = strlen(buffer);
if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN)
buffer[n++] = SEP;
}
if (n > MAXPATHLEN)
Py_FatalError("buffer overflow in getpathp.c's joinpath()");
k = strlen(stuff);
if (n + k > MAXPATHLEN)
k = MAXPATHLEN - n;
strncpy(buffer+n, stuff, k);
buffer[n+k] = '\0';
}
static int
search_for_prefix(char *argv0_path, char *landmark)
{
int n;
/* Search from argv0_path, until root is found */
strcpy(prefix, argv0_path);
do {
n = strlen(prefix);
join(prefix, landmark);
if (exists(prefix)) {
prefix[n] = '\0';
return 1;
}
prefix[n] = '\0';
reduce(prefix);
} while (prefix[0]);
return 0;
}
#ifdef MS_WIN32
#include "malloc.h" // for alloca - see comments below!
extern const char *PyWin_DLLVersionString; // a string loaded from the DLL at startup.
/* Load a PYTHONPATH value from the registry.
Load from either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER.
Returns NULL, or a pointer that should be freed.
*/
static char *
getpythonregpath(HKEY keyBase, BOOL bWin32s)
{
HKEY newKey = 0;
DWORD nameSize = 0;
DWORD dataSize = 0;
DWORD numEntries = 0;
LONG rc;
char *retval = NULL;
char *dataBuf;
const char keyPrefix[] = "Software\\Python\\PythonCore\\";
const char keySuffix[] = "\\PythonPath";
int versionLen;
char *keyBuf;
// Tried to use sysget("winver") but here is too early :-(
versionLen = strlen(PyWin_DLLVersionString);
// alloca == no free required, but memory only local to fn.
// also no heap fragmentation! Am I being silly?
keyBuf = alloca(sizeof(keyPrefix)-1 + versionLen + sizeof(keySuffix)); // chars only, plus 1 NULL.
// lots of constants here for the compiler to optimize away :-)
memcpy(keyBuf, keyPrefix, sizeof(keyPrefix)-1);
memcpy(keyBuf+sizeof(keyPrefix)-1, PyWin_DLLVersionString, versionLen);
memcpy(keyBuf+sizeof(keyPrefix)-1+versionLen, keySuffix, sizeof(keySuffix)); // NULL comes with this one!
rc=RegOpenKey(keyBase,
keyBuf,
&newKey);
if (rc==ERROR_SUCCESS) {
RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL,
&numEntries, &nameSize, &dataSize, NULL, NULL);
}
if (bWin32s && numEntries==0 && dataSize==0) {
/* must hardcode for Win32s */
numEntries = 1;
dataSize = 511;
}
if (numEntries) {
/* Loop over all subkeys. */
/* Win32s doesnt know how many subkeys, so we do
it twice */
char keyBuf[MAX_PATH+1];
int index = 0;
int off = 0;
for(index=0;;index++) {
long reqdSize = 0;
DWORD rc = RegEnumKey(newKey,
index, keyBuf, MAX_PATH+1);
if (rc) break;
rc = RegQueryValue(newKey, keyBuf, NULL, &reqdSize);
if (rc) break;
if (bWin32s && reqdSize==0) reqdSize = 512;
dataSize += reqdSize + 1; /* 1 for the ";" */
}
dataBuf = malloc(dataSize+1);
if (dataBuf==NULL)
return NULL; /* pretty serious? Raise error? */
/* Now loop over, grabbing the paths.
Subkeys before main library */
for(index=0;;index++) {
int adjust;
long reqdSize = dataSize;
DWORD rc = RegEnumKey(newKey,
index, keyBuf,MAX_PATH+1);
if (rc) break;
rc = RegQueryValue(newKey,
keyBuf, dataBuf+off, &reqdSize);
if (rc) break;
if (reqdSize>1) {
/* If Nothing, or only '\0' copied. */
adjust = strlen(dataBuf+off);
dataSize -= adjust;
off += adjust;
dataBuf[off++] = ';';
dataBuf[off] = '\0';
dataSize--;
}
}
/* Additionally, win32s doesnt work as expected, so
the specific strlen() is required for 3.1. */
rc = RegQueryValue(newKey, "", dataBuf+off, &dataSize);
if (rc==ERROR_SUCCESS) {
if (strlen(dataBuf)==0)
free(dataBuf);
else
retval = dataBuf; /* caller will free */
}
else
free(dataBuf);
}
if (newKey)
RegCloseKey(newKey);
return retval;
}
#endif /* MS_WIN32 */
static void
get_progpath(void)
{
extern char *Py_GetProgramName(void);
char *path = getenv("PATH");
char *prog = Py_GetProgramName();
#ifdef MS_WIN32
if (GetModuleFileName(NULL, progpath, MAXPATHLEN))
return;
#endif
if (prog == NULL || *prog == '\0')
prog = "python";
/* If there is no slash in the argv0 path, then we have to
* assume python is on the user's $PATH, since there's no
* other way to find a directory to start the search from. If
* $PATH isn't exported, you lose.
*/
#ifdef ALTSEP
if (strchr(prog, SEP) || strchr(prog, ALTSEP))
#else
if (strchr(prog, SEP))
#endif
strcpy(progpath, prog);
else if (path) {
while (1) {
char *delim = strchr(path, DELIM);
if (delim) {
int len = delim - path;
strncpy(progpath, path, len);
*(progpath + len) = '\0';
}
else
strcpy(progpath, path);
join(progpath, prog);
if (exists(progpath))
break;
if (!delim) {
progpath[0] = '\0';
break;
}
path = delim + 1;
}
}
else
progpath[0] = '\0';
}
static void
calculate_path(void)
{
char argv0_path[MAXPATHLEN+1];
char *buf;
int bufsz;
char *pythonhome = Py_GetPythonHome();
char *envpath = Py_GETENV("PYTHONPATH");
#ifdef MS_WIN32
char *machinepath, *userpath;
/* Are we running under Windows 3.1(1) Win32s? */
if (PyWin_IsWin32s()) {
/* Only CLASSES_ROOT is supported */
machinepath = getpythonregpath(HKEY_CLASSES_ROOT, TRUE);
userpath = NULL;
} else {
machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, FALSE);
userpath = getpythonregpath(HKEY_CURRENT_USER, FALSE);
}
#endif
get_progpath();
strcpy(argv0_path, progpath);
reduce(argv0_path);
if (pythonhome == NULL || *pythonhome == '\0') {
if (search_for_prefix(argv0_path, LANDMARK))
pythonhome = prefix;
else
pythonhome = NULL;
}
else {
char *delim;
strcpy(prefix, pythonhome);
/* Extract Any Optional Trailing EXEC_PREFIX */
/* e.g. PYTHONHOME=<prefix>:<exec_prefix> */
delim = strchr(prefix, DELIM);
if (delim) {
*delim = '\0';
strcpy(exec_prefix, delim+1);
} else
strcpy(exec_prefix, EXEC_PREFIX);
}
if (envpath && *envpath == '\0')
envpath = NULL;
/* We need to construct a path from the following parts:
(1) the PYTHONPATH environment variable, if set;
(2) for Win32, the machinepath and userpath, if set;
(3) the PYTHONPATH config macro, with the leading "."
of each component replaced with pythonhome, if set;
(4) the directory containing the executable (argv0_path).
The length calculation calculates #3 first.
*/
/* Calculate size of return buffer */
if (pythonhome != NULL) {
char *p;
bufsz = 1;
for (p = PYTHONPATH; *p; p++) {
if (*p == DELIM)
bufsz++; /* number of DELIM plus one */
}
bufsz *= strlen(pythonhome);
}
else
bufsz = 0;
bufsz += strlen(PYTHONPATH) + 1;
if (envpath != NULL)
bufsz += strlen(envpath) + 1;
bufsz += strlen(argv0_path) + 1;
#ifdef MS_WIN32
if (machinepath)
bufsz += strlen(machinepath) + 1;
if (userpath)
bufsz += strlen(userpath) + 1;
#endif
module_search_path = buf = malloc(bufsz);
if (buf == NULL) {
/* We can't exit, so print a warning and limp along */
fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n");
if (envpath) {
fprintf(stderr, "Using default static $PYTHONPATH.\n");
module_search_path = envpath;
}
else {
fprintf(stderr, "Using environment $PYTHONPATH.\n");
module_search_path = PYTHONPATH;
}
return;
}
if (envpath) {
strcpy(buf, envpath);
buf = strchr(buf, '\0');
*buf++ = DELIM;
}
#ifdef MS_WIN32
if (machinepath) {
strcpy(buf, machinepath);
buf = strchr(buf, '\0');
*buf++ = DELIM;
}
if (userpath) {
strcpy(buf, userpath);
buf = strchr(buf, '\0');
*buf++ = DELIM;
}
#endif
if (pythonhome == NULL) {
strcpy(buf, PYTHONPATH);
buf = strchr(buf, '\0');
}
else {
char *p = PYTHONPATH;
char *q;
int n;
for (;;) {
q = strchr(p, DELIM);
if (q == NULL)
n = strlen(p);
else
n = q-p;
if (p[0] == '.' && is_sep(p[1])) {
strcpy(buf, pythonhome);
buf = strchr(buf, '\0');
p++;
n--;
}
strncpy(buf, p, n);
buf += n;
if (q == NULL)
break;
*buf++ = DELIM;
p = q+1;
}
}
if (argv0_path) {
*buf++ = DELIM;
strcpy(buf, argv0_path);
buf = strchr(buf, '\0');
}
*buf = '\0';
}
/* External interface */
char *
Py_GetPath(void)
{
if (!module_search_path)
calculate_path();
return module_search_path;
}
char *
Py_GetPrefix(void)
{
if (!module_search_path)
calculate_path();
return prefix;
}
char *
Py_GetExecPrefix(void)
{
if (!module_search_path)
calculate_path();
return exec_prefix;
}
char *
Py_GetProgramFullPath(void)
{
if (!module_search_path)
calculate_path();
return progpath;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,212 +0,0 @@
#ifndef Py_CONFIG_H
#define Py_CONFIG_H
/**********************************************************************
* pyconfig.h. NOT Generated automatically by configure.
*
* This is a manually maintained version used for the IBM VisualAge
* C/C++ compiler on the OS/2 platform. It is a standard part of
* the Python distribution.
*
* FILESYSTEM DEFINES:
* The code specific to a particular way of naming files and
* directory paths should be wrapped around one of the following
* #defines:
*
* DOSFILESYS PCDOS-Style (for PCDOS, Windows and OS/2)
* MACFILESYS Macintosh-Style
* UNIXFILESYS Unix-Style
* AMIGAFILESYS AmigaDOS-Style
*
* Because of the different compilers and operating systems in
* use on the Intel platform, neither the compiler name nor
* the operating system name is sufficient.
*
* OS/2 DEFINES:
* The code specific to OS/2's Program API should be wrapped around
*
* __TOS_OS2__ Target Operating System, OS/2
*
* Any code specific to the compiler itself should be wrapped with
*
* __IBMC__ IBM C Compiler
* __IBMCPP__ IBM C++ Compiler
*
* Note that since the VisualAge C/C++ compiler is also available
* for the Windows platform, it may be necessary to use both a
* __TOS_OS2__ and a __IBMC__ to select a very specific environment.
*
**********************************************************************/
/*
* Some systems require special declarations for data items imported
* or exported from dynamic link libraries. Note that the definition
* of DL_IMPORT covers both cases. Define USE_DL_IMPORT for the client
* of a DLL. Define USE_DL_EXPORT when making a DLL.
*/
#include <io.h>
/* Configuration Options for Finding Modules */
#define PREFIX ""
#define EXEC_PREFIX ""
/* Provide a default library so writers of extension modules
* won't have to explicitly specify it anymore
*/
#pragma library("Python24.lib")
/***************************************************/
/* 32-Bit IBM VisualAge C/C++ v3.0 for OS/2 */
/* (Convert Compiler Flags into Useful Switches) */
/***************************************************/
#define PLATFORM "os2"
#define COMPILER "[VisualAge C/C++]"
#define PYOS_OS2 /* Define Indicator of Operating System */
#define PYCC_VACPP /* Define Indicator of C Compiler */
/* Platform Filesystem */
#define PYTHONPATH ".;.\\lib;.\\lib\\plat-win"
#define DOSFILESYS /* OS/2 Uses the DOS File Naming Conventions */
/* #define IMPORT_8x3_NAMES (let's move up to long filenames) */
/* Platform CPU-Mode Dependencies */
#define WORD_BIT 32 /* OS/2 is a 32-Bit Operating System */
#define LONG_BIT 32
#define SIZEOF_INT 4 /* Count of Bytes in an (int) */
#define SIZEOF_LONG 4 /* Count of Bytes in a (long) */
#define SIZEOF_VOID_P 4 /* Count of Bytes in a (void *) */
/* #define HAVE_LONG_LONG 1 */ /* VAC++ does not support (long long) */
/* #define SIZEOF_LONG_LONG 8 */ /* Count of Bytes in a (long long) */
/* unicode definines */
#define PY_UNICODE_TYPE wchar_t
#define Py_UNICODE_SIZE SIZEOF_SHORT
/* dynamic loading */
#define HAVE_DYNAMIC_LOADING 1
/* Define if type char is unsigned and you are not using gcc. */
#ifndef __CHAR_UNSIGNED__
/* #undef __CHAR_UNSIGNED__ */
#endif
typedef int mode_t;
typedef int uid_t;
typedef int gid_t;
typedef int pid_t;
#if defined(__MULTI__) /* If Compiler /Gt+ Multithread Option Enabled, */
#define WITH_THREAD 1 /* Enable Threading Throughout Python */
#define OS2_THREADS 1 /* And Use the OS/2 Flavor of Threads */
/* #define _REENTRANT 1 */ /* Use thread-safe errno, h_errno, and other fns */
#endif
/* Compiler Runtime Library Capabilities */
#include <ctype.h>
#include <direct.h>
/* #undef BAD_STATIC_FORWARD */ /* if compiler botches static fwd decls */
#define STDC_HEADERS 1 /* VAC++ is an ANSI C Compiler */
#define HAVE_HYPOT 1 /* hypot() */
#define HAVE_PUTENV 1 /* putenv() */
/* #define VA_LIST_IS_ARRAY 1 */ /* if va_list is an array of some kind */
/* #define HAVE_CONIO_H 1 */ /* #include <conio.h> */
#define HAVE_ERRNO_H 1 /* #include <errno.h> */
#define HAVE_SYS_STAT_H 1 /* #include <sys/stat.h> */
#define HAVE_SYS_TYPES_H 1 /* #include <sys/types.h> */
/* Variable-Arguments/Prototypes */
#define HAVE_PROTOTYPES 1 /* VAC++ supports C Function Prototypes */
#define HAVE_STDARG_PROTOTYPES 1 /* Our <stdarg.h> has prototypes */
/* String/Memory/Locale Operations */
#define HAVE_MEMMOVE 1 /* memmove() */
#define HAVE_STRERROR 1 /* strerror() */
#define HAVE_SETLOCALE 1 /* setlocale() */
#define MALLOC_ZERO_RETURNS_NULL 1 /* Our malloc(0) returns a NULL ptr */
/* Signal Handling */
#define HAVE_SIGNAL_H 1 /* signal.h */
#define RETSIGTYPE void /* Return type of handlers (int or void) */
/* #undef WANT_SIGFPE_HANDLER */ /* Handle SIGFPE (see Include/pyfpe.h) */
/* #define HAVE_ALARM 1 */ /* alarm() */
/* #define HAVE_SIGINTERRUPT 1 */ /* siginterrupt() */
/* #define HAVE_SIGRELSE 1 */ /* sigrelse() */
#define DONT_HAVE_SIG_ALARM 1
#define DONT_HAVE_SIG_PAUSE 1
/* Clock/Time Support */
#define HAVE_FTIME 1 /* We have ftime() in <sys/timeb.h> */
#define HAVE_CLOCK 1 /* clock() */
#define HAVE_STRFTIME 1 /* strftime() */
#define HAVE_MKTIME 1 /* mktime() */
#define HAVE_TZNAME 1 /* No tm_zone but do have tzname[] */
#define HAVE_TIMES 1 /* #include <sys/times.h> */
#define HAVE_SYS_UTIME_H 1 /* #include <sys/utime.h> */
/* #define HAVE_UTIME_H 1 */ /* #include <utime.h> */
#define HAVE_SYS_TIME_H 1 /* #include <sys/time.h> */
/* #define TM_IN_SYS_TIME 1 */ /* <sys/time.h> declares struct tm */
#define HAVE_GETTIMEOFDAY 1 /* gettimeofday() */
/* #define GETTIMEOFDAY_NO_TZ 1 */ /* gettimeofday() does not have 2nd arg */
/* #define HAVE_TIMEGM 1 */ /* timegm() */
#define TIME_WITH_SYS_TIME 1 /* Mix <sys/time.h> and <time.h> */
#define SYS_SELECT_WITH_SYS_TIME 1 /* Mix <sys/select.h> and <sys/time.h> */
/* #define HAVE_ALTZONE 1 */ /* if <time.h> defines altzone */
/* Network/Sockets Support */
#define HAVE_SYS_SELECT_H 1 /* #include <sys/select.h> */
#define BSD_SELECT 1 /* Use BSD versus OS/2 form of select() */
#define HAVE_SELECT 1 /* select() */
#define HAVE_GETPEERNAME 1 /* getpeername() */
/* #undef HAVE_GETHOSTNAME_R 1 */ /* gethostname_r() */
/* File I/O */
#define HAVE_DUP2 1 /* dup2() */
#define HAVE_EXECV 1 /* execv() */
#define HAVE_SETVBUF 1 /* setvbuf() */
#define HAVE_GETCWD 1 /* getcwd() */
#define HAVE_PIPE 1 /* pipe() [OS/2-specific code added] */
#define HAVE_IO_H 1 /* #include <io.h> */
#define HAVE_FCNTL_H 1 /* #include <fcntl.h> */
#define HAVE_DIRECT_H 1 /* #include <direct.h> */
/* #define HAVE_FLOCK 1 */ /* flock() */
/* #define HAVE_TRUNCATE 1 */ /* truncate() */
/* #define HAVE_FTRUNCATE 1 */ /* ftruncate() */
/* #define HAVE_LSTAT 1 */ /* lstat() */
/* #define HAVE_DIRENT_H 1 */ /* #include <dirent.h> */
/* #define HAVE_OPENDIR 1 */ /* opendir() */
/* Process Operations */
#define HAVE_PROCESS_H 1 /* #include <process.h> */
#define HAVE_GETPID 1 /* getpid() */
#define HAVE_SYSTEM 1 /* system() */
#define HAVE_WAIT 1 /* wait() */
#define HAVE_KILL 1 /* kill() [OS/2-specific code added] */
#define HAVE_POPEN 1 /* popen() [OS/2-specific code added] */
/* #define HAVE_GETPPID 1 */ /* getppid() */
/* #define HAVE_WAITPID 1 */ /* waitpid() */
/* #define HAVE_FORK 1 */ /* fork() */
/* User/Group ID Queries */
/* #define HAVE_GETEGID 1 */
/* #define HAVE_GETEUID 1 */
/* #define HAVE_GETGID 1 */
/* #define HAVE_GETUID 1 */
/* Unix-Specific */
/* #define HAVE_SYS_UN_H 1 /* #include <sys/un.h> */
/* #define HAVE_SYS_UTSNAME_H 1 */ /* #include <sys/utsname.h> */
/* #define HAVE_SYS_WAIT_H 1 */ /* #include <sys/wait.h> */
/* #define HAVE_UNISTD_H 1 */ /* #include <unistd.h> */
/* #define HAVE_UNAME 1 */ /* uname () */
/* Define if you want documentation strings in extension modules */
#define WITH_DOC_STRINGS 1
#ifdef USE_DL_EXPORT
#define DL_IMPORT(RTYPE) RTYPE _System
#endif
#endif /* !Py_CONFIG_H */

View File

@ -1,479 +0,0 @@
LIBRARY PYTHON24 INITINSTANCE TERMINSTANCE
DESCRIPTION 'Python 2.4 Core DLL'
PROTMODE
DATA MULTIPLE NONSHARED
EXPORTS
; Data
PyCFunction_Type
PyCapsule_Type
PyCObject_Type
PyClass_Type
PyCode_Type
PyComplex_Type
PyDict_Type
PyExc_ArithmeticError
PyExc_AssertionError
PyExc_AttributeError
PyExc_EOFError
PyExc_EnvironmentError
PyExc_Exception
PyExc_FloatingPointError
PyExc_IOError
PyExc_ImportError
PyExc_IndexError
PyExc_KeyError
PyExc_KeyboardInterrupt
PyExc_LookupError
PyExc_MemoryError
PyExc_MemoryErrorInst
PyExc_NameError
PyExc_OSError
PyExc_OverflowError
PyExc_RuntimeError
PyExc_SyntaxError
PyExc_SystemError
PyExc_SystemExit
PyExc_TypeError
PyExc_ValueError
PyExc_ZeroDivisionError
PyFile_Type
PyFloat_Type
PyFrame_Type
PyFunction_Type
PyImport_FrozenModules
PyImport_Inittab
PyInstance_Type
PyInt_Type
PyList_Type
PyLong_Type
PyMethod_Type
PyModule_Type
PyOS_InputHook
PyOS_ReadlineFunctionPointer
PyRange_Type
PySlice_Type
PyString_Type
PyTraceBack_Type
PyTuple_Type
PyType_Type
Py_DebugFlag
Py_FrozenFlag
Py_InteractiveFlag
Py_NoSiteFlag
Py_OptimizeFlag
Py_UseClassExceptionsFlag
Py_VerboseFlag
_PyImport_Filetab
_PyImport_Inittab
_PyParser_Grammar
_PyParser_TokenNames
_Py_EllipsisObject
_Py_NoneStruct
_Py_PackageContext
_Py_TrueStruct
_Py_ZeroStruct
_Py_abstract_hack
_Py_capsule_hack
_Py_re_syntax
_Py_re_syntax_table
; Code
PyArg_Parse
PyArg_ParseTuple
PyArg_ParseTupleAndKeywords
PyArg_VaParse
PyCFunction_Fini
PyCFunction_GetFlags
PyCFunction_GetFunction
PyCFunction_GetSelf
PyCFunction_New
PyCapsule_GetContext
PyCapsule_GetDestructor
PyCapsule_GetName
PyCapsule_GetPointer
PyCapsule_Import
PyCapsule_IsValid
PyCapsule_New
PyCapsule_SetContext
PyCapsule_SetDestructor
PyCapsule_SetName
PyCapsule_SetPointer
PyCObject_AsVoidPtr
PyCObject_FromVoidPtrAndDesc
PyCObject_FromVoidPtr
PyCObject_GetDesc
PyCObject_Import
PyCallable_Check
PyClass_IsSubclass
PyClass_New
PyCode_Addr2Line
PyCode_New
PyComplex_AsCComplex
PyComplex_FromCComplex
PyComplex_FromDoubles
PyComplex_ImagAsDouble
PyComplex_RealAsDouble
PyDict_Clear
PyDict_DelItem
PyDict_DelItemString
PyDict_GetItem
PyDict_GetItemString
PyDict_Items
PyDict_Keys
PyDict_New
PyDict_Next
PyDict_SetItem
PyDict_SetItemString
PyDict_Size
PyDict_Values
PyErr_BadArgument
PyErr_BadInternalCall
PyErr_CheckSignals
PyErr_Clear
PyErr_ExceptionMatches
PyErr_Fetch
PyErr_Format
PyErr_GivenExceptionMatches
PyErr_NewException
PyErr_NoMemory
PyErr_NormalizeException
PyErr_Occurred
PyErr_Print
PyErr_PrintEx
PyErr_Restore
PyErr_SetFromErrno
PyErr_SetFromErrnoWithFilename
PyErr_SetInterrupt
PyErr_SetNone
PyErr_SetObject
PyErr_SetString
PyEval_AcquireLock
PyEval_AcquireThread
PyEval_CallFunction
PyEval_CallMethod
PyEval_CallObject
PyEval_CallObjectWithKeywords
PyEval_EvalCode
PyEval_GetBuiltins
PyEval_GetFrame
PyEval_GetGlobals
PyEval_GetLocals
PyEval_GetRestricted
PyEval_InitThreads
PyEval_ReleaseLock
PyEval_ReleaseThread
PyEval_RestoreThread
PyEval_SaveThread
PyFile_AsFile
PyFile_FromFile
PyFile_FromString
PyFile_GetLine
PyFile_Name
PyFile_SetBufSize
PyFile_SoftSpace
PyFile_WriteObject
PyFile_WriteString
PyFloat_AsDouble
PyFloat_AsString
PyFloat_Fini
PyFloat_FromDouble
PyFrame_BlockPop
PyFrame_BlockSetup
PyFrame_FastToLocals
PyFrame_Fini
PyFrame_LocalsToFast
PyFrame_New
PyFunction_GetCode
PyFunction_GetDefaults
PyFunction_GetGlobals
PyFunction_New
PyFunction_SetDefaults
PyGrammar_AddAccelerators
PyGrammar_FindDFA
PyGrammar_LabelRepr
PyGrammar_RemoveAccelerators
PyImport_AddModule
PyImport_AppendInittab
PyImport_Cleanup
PyImport_ExecCodeModule
PyImport_ExecCodeModuleEx
PyImport_ExtendInittab
PyImport_GetMagicNumber
PyImport_GetModuleDict
PyImport_Import
PyImport_ImportFrozenModule
PyImport_ImportModule
PyImport_ImportModuleEx
PyImport_ReloadModule
PyInstance_DoBinOp
PyInstance_New
PyInt_AsLong
PyInt_Fini
PyInt_FromLong
PyInt_GetMax
PyInterpreterState_Clear
PyInterpreterState_Delete
PyInterpreterState_New
PyList_Append
PyList_AsTuple
PyList_GetItem
PyList_GetSlice
PyList_Insert
PyList_New
PyList_Reverse
PyList_SetItem
PyList_SetSlice
PyList_Size
PyList_Sort
PyLong_AsDouble
PyLong_AsLong
; PyLong_AsLongLong
PyLong_AsUnsignedLong
; PyLong_AsUnsignedLongLong
PyLong_AsVoidPtr
PyLong_FromDouble
PyLong_FromLong
; PyLong_FromLongLong
PyLong_FromString
PyLong_FromUnsignedLong
; PyLong_FromUnsignedLongLong
PyLong_FromVoidPtr
PyMapping_Check
PyMapping_GetItemString
PyMapping_HasKey
PyMapping_HasKeyString
PyMapping_Length
PyMapping_SetItemString
PyMarshal_Init
PyMarshal_ReadLongFromFile
PyMarshal_ReadObjectFromFile
PyMarshal_ReadObjectFromString
PyMarshal_WriteLongToFile
PyMarshal_WriteObjectToFile
PyMarshal_WriteObjectToString
PyMem_Free
PyMem_Malloc
PyMem_Realloc
PyMethod_Class
PyMethod_Fini
PyMethod_Function
PyMethod_New
PyMethod_Self
PyModule_GetDict
PyModule_GetName
PyModule_New
PyNode_AddChild
PyNode_Compile
PyNode_Free
; PyNode_ListTree
PyNode_New
PyNumber_Absolute
PyNumber_Add
PyNumber_And
PyNumber_Check
PyNumber_Coerce
PyNumber_CoerceEx
PyNumber_Divide
PyNumber_Divmod
PyNumber_Float
PyNumber_Int
PyNumber_Invert
PyNumber_Long
PyNumber_Lshift
PyNumber_Multiply
PyNumber_Negative
PyNumber_Or
PyNumber_Positive
PyNumber_Power
PyNumber_Remainder
PyNumber_Rshift
PyNumber_Subtract
PyNumber_Xor
PyOS_AfterFork
PyOS_FiniInterrupts
PyOS_InitInterrupts
PyOS_InterruptOccurred
PyOS_Readline
PyOS_StdioReadline
PyOS_strtol
PyOS_strtoul
PyObject_CallFunction
PyObject_CallMethod
PyObject_CallObject
PyObject_Cmp
PyObject_Compare
PyObject_DelItem
PyObject_GetAttr
PyObject_GetAttrString
PyObject_GetItem
PyObject_HasAttr
PyObject_HasAttrString
PyObject_Hash
PyObject_IsTrue
PyObject_Length
PyObject_Not
PyObject_Print
PyObject_Repr
PyObject_SetAttr
PyObject_SetAttrString
PyObject_SetItem
PyObject_Str
PyObject_Type
PyParser_AddToken
PyParser_Delete
PyParser_New
PyParser_ParseFile
PyParser_ParseString
PyParser_SimpleParseFile
PyParser_SimpleParseString
PyRange_New
PyRun_AnyFile
PyRun_File
PyRun_InteractiveLoop
PyRun_InteractiveOne
PyRun_SimpleFile
PyRun_SimpleString
PyRun_String
PySequence_Check
PySequence_Concat
PySequence_Contains
PySequence_Count
PySequence_DelItem
PySequence_DelSlice
PySequence_GetItem
PySequence_GetSlice
PySequence_In
PySequence_Index
PySequence_Length
PySequence_List
PySequence_Repeat
PySequence_SetItem
PySequence_SetSlice
PySequence_Tuple
PySlice_GetIndices
PySlice_New
PyString_AsString
PyString_Concat
PyString_ConcatAndDel
PyString_Fini
PyString_Format
PyString_FromString
PyString_FromStringAndSize
PyString_InternFromString
PyString_InternInPlace
PyString_Size
PySys_GetFile
PySys_GetObject
PySys_SetArgv
PySys_SetObject
PySys_SetPath
PySys_WriteStderr
PySys_WriteStdout
PyThreadState_Clear
PyThreadState_Delete
PyThreadState_Get
PyThreadState_GetDict
PyThreadState_New
PyThreadState_Swap
PyThread_acquire_lock
PyThread_allocate_lock
PyThread_allocate_sema
PyThread_down_sema
PyThread_exit_thread
PyThread_free_lock
PyThread_free_sema
PyThread_get_thread_ident
PyThread_init_thread
PyThread_release_lock
PyThread_start_new_thread
PyThread_up_sema
PyToken_OneChar
PyToken_TwoChars
PyTokenizer_Free
PyTokenizer_FromFile
PyTokenizer_FromString
PyTokenizer_Get
PyTraceBack_Here
PyTraceBack_Print
PyTuple_Fini
PyTuple_GetItem
PyTuple_GetSlice
PyTuple_New
PyTuple_SetItem
PyTuple_Size
Py_AddPendingCall
Py_AtExit
Py_BuildValue
Py_CompileString
Py_EndInterpreter
Py_Exit
Py_FatalError
Py_FdIsInteractive
Py_Finalize
Py_FindMethod
Py_FindMethodInChain
Py_FlushLine
Py_Free
Py_GetArgcArgv
Py_GetBuildInfo
Py_GetCompiler
Py_GetCopyright
Py_GetExecPrefix
Py_GetPath
Py_GetPlatform
Py_GetPrefix
Py_GetProgramFullPath
Py_GetProgramName
Py_GetPythonHome
Py_GetVersion
Py_InitModule4
Py_Initialize
Py_IsInitialized
Py_Main
Py_MakePendingCalls
Py_Malloc
Py_NewInterpreter
Py_Realloc
Py_ReprEnter
Py_ReprLeave
Py_SetProgramName
Py_SetPythonHome
Py_VaBuildValue
_PyBuiltin_Fini_1
_PyBuiltin_Fini_2
_PyBuiltin_Init_1
_PyBuiltin_Init_2
_PyImport_FindExtension
_PyImport_Fini
_PyImport_FixupExtension
_PyImport_Init
_PyImport_LoadDynamicModule
_PyLong_New
_PyModule_Clear
_PyObject_New
_PyObject_NewVar
_PyString_Resize
_PySys_Init
_PyTuple_Resize
_Py_MD5Final
_Py_MD5Init
_Py_MD5Update
; _Py_addbit
_Py_c_diff
_Py_c_neg
_Py_c_pow
_Py_c_prod
_Py_c_quot
_Py_c_sum
; _Py_delbitset
; _Py_mergebitset
; _Py_meta_grammar
; _Py_newbitset
; _Py_samebitset
PyBuffer_Type
PyBuffer_FromObject
PyBuffer_FromMemory
PyBuffer_FromReadWriteMemory
PyBuffer_New

View File

@ -1,119 +0,0 @@
IBM VisualAge C/C++ for OS/2
============================
To build Python for OS/2, change into ./os2vacpp and issue an 'NMAKE'
command. This will build a PYTHON15.DLL containing the set of Python
modules listed in config.c and a small PYTHON.EXE to start the
interpreter.
By changing the C compiler flag /Gd- in the makefile to /Gd+, you can
reduce the size of these by causing Python to dynamically link to the
C runtime DLLs instead of including their bulk in your binaries.
However, this means that any system on which you run Python must have
the VAC++ compiler installed in order to have those DLLs available.
During the build process you may see a couple of harmless warnings:
From the C Compiler, "No function prototype given for XXX", which
comes from the use of K&R parameters within Python for portability.
From the ILIB librarian, "Module Not Found (XXX)", which comes
from its attempt to perform the (-+) operation, which removes and
then adds a .OBJ to the library. The first time a build is done,
it obviously cannot remove what is not yet built.
This build includes support for most Python functionality as well as
TCP/IP sockets. It omits the Posix ability to 'fork' a process but
supports threads using OS/2 native capabilities. I have tried to
support everything possible but here are a few usage notes.
-- os.popen() Usage Warnings
With respect to my implementation of popen() under OS/2:
import os
fd = os.popen("pkzip.exe -@ junk.zip", 'wb')
fd.write("file1.txt\n")
fd.write("file2.txt\n")
fd.write("file3.txt\n")
fd.write("\x1a") # Should Not Be Necessary But Is
fd.close()
There is a bug, either in the VAC++ compiler or OS/2 itself, where the
simple closure of the write-side of a pipe -to- a process does not
send an EOF to that process. I find I must explicitly write a
control-Z (EOF) before closing the pipe. This is not a problem when
using popen() in read mode.
One other slight difference with my popen() is that I return None
from the close(), instead of the Unix convention of the return code
of the spawned program. I could find no easy way to do this under
OS/2.
-- BEGINLIBPATH/ENDLIBPATH
With respect to environment variables, this OS/2 port supports the
special-to-OS/2 magic names of 'BEGINLIBPATH' and 'ENDLIBPATH' to
control where to load conventional DLLs from. Those names are
intercepted and converted to calls on the OS/2 kernel APIs and
are inherited by child processes, whether Python-based or not.
A few new attributes have been added to the os module:
os.meminstalled # Count of Bytes of RAM Installed on Machine
os.memkernel # Count of Bytes of RAM Reserved (Non-Swappable)
os.memvirtual # Count of Bytes of Virtual RAM Possible
os.timeslice # Duration of Scheduler Timeslice, in Milliseconds
os.maxpathlen # Maximum Length of a Path Specification, in chars
os.maxnamelen # Maximum Length of a Single Dir/File Name, in chars
os.version # Version of OS/2 Being Run e.g. "4.00"
os.revision # Revision of OS/2 Being Run (usually zero)
os.bootdrive # Drive that System Booted From e.g. "C:"
# (useful to find the CONFIG.SYS used to boot with)
-- Using Python as the Default OS/2 Batch Language
Note that OS/2 supports the Unix technique of putting the special
comment line at the time of scripts e.g. "#!/usr/bin/python" in
a different syntactic form. To do this, put your script into a file
with a .CMD extension and added 'extproc' to the top as follows:
extproc C:\Python\Python.exe -x
import os
print "Hello from Python"
The '-x' option tells Python to skip the first line of the file
while processing the rest as normal Python source.
-- Suggested Environment Variable Setup
With respect to the environment variables for Python, I use the
following setup:
Set PYTHONHOME=E:\Tau\Projects\Python;D:\DLLs
Set PYTHONPATH=.;E:\Tau\Projects\Python\Lib; \
E:\Tau\Projects\Python\Lib\plat-win
The EXEC_PREFIX (optional second pathspec on PYTHONHOME) is where
you put any Python extension DLLs you may create/obtain. There
are none provided with this release.
-- Contact Info
Jeff Rush is no longer supporting the VACPP port :-(
I don't have the VACPP compiler, so can't reliably maintain this port.
Anyone with VACPP who can contribute patches to keep this port buildable
should upload them to the Python Patch Manager at Sourceforge and
assign them to me for review/checkin.
Andrew MacIntyre
aimacintyre at users.sourceforge.net
August 18, 2002.