Import Upstream version 2.7.18

This commit is contained in:
geos_one
2025-08-15 16:28:06 +02:00
commit ba1f69ab39
4521 changed files with 1778434 additions and 0 deletions

8
PC/os2vacpp/_tkinter.def Normal file
View File

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

106
PC/os2vacpp/config.c Normal file
View File

@@ -0,0 +1,106 @@
/* -*- 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 initstrop(void);
extern void initstruct(void);
extern void inittime(void);
extern void initthread(void);
extern void initcStringIO(void);
extern void initcPickle(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
{"strop", initstrop},
{"struct", initstruct},
{"time", inittime},
#ifdef WITH_THREAD
{"thread", initthread},
#endif
{"cStringIO", initcStringIO},
{"cPickle", initcPickle},
{"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 */
{"__main__", NULL},
{"__builtin__", NULL},
{"sys", NULL},
/* Sentinel */
{0, 0}
};

482
PC/os2vacpp/getpathp.c Normal file
View File

@@ -0,0 +1,482 @@
/* 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;
}

1880
PC/os2vacpp/makefile Normal file

File diff suppressed because it is too large Load Diff

1271
PC/os2vacpp/makefile.omk Normal file

File diff suppressed because it is too large Load Diff

213
PC/os2vacpp/pyconfig.h Normal file
View File

@@ -0,0 +1,213 @@
#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;.\\lib\\lib-tk"
#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_USING_UNICODE
#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 */

484
PC/os2vacpp/python.def Normal file
View File

@@ -0,0 +1,484 @@
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_StandardError
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_TabcheckFlag
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_cobject_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
PyMember_Get
PyMember_Set
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

119
PC/os2vacpp/readme.txt Normal file
View File

@@ -0,0 +1,119 @@
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.