/* Configuration Options for Finding Modules */
#define PREFIX ""
#define EXEC_PREFIX ""
-//#define VPATH "."
-
-//#define PYTHONPATH PREFIX "/lib/python" VERSION DELIM \
-// PREFIX "/lib/python" VERSION "/test" DELIM \
-// EXEC_PREFIX "/lib/python" VERSION "/sharedmodules"
/***************************************************/
/* 32-Bit IBM VisualAge C/C++ v3.0 for OS/2 */
#define PYCC_VACPP /* Define Indicator of C Compiler */
/* Platform Filesystem */
- #define PYTHONPATH ".;.\\lib;.\\lib\\plat-os2;.\\lib\\dos_8x3;.\\lib\\lib-tk"
+ #define PYTHONPATH ".;.\\lib;.\\lib\\plat-win;.\\lib\\dos-8x3;.\\lib\\lib-tk"
#define DOSFILESYS /* OS/2 Uses the DOS File Naming Conventions */
/* #define IMPORT_8x3_NAMES */
/* #define WITH_READLINE 1 */
/* Define if you have clock. */
-/* #define HAVE_CLOCK */
+#define HAVE_CLOCK
/* Define if you have ftime. */
#define HAVE_FTIME
/* #undef HAVE_TCSETPGRP */
/* Define if you have times. */
-/* #undef HAVE_TIMES */
+#define HAVE_TIMES
/* Define if you have uname. */
/* #undef HAVE_UNAME */
/* Search in some common locations for the associated Python libraries.
*
- * This version always returns "" for both prefix and exec_prefix.
+ * 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.
*
#endif
static char prefix[MAXPATHLEN+1];
+static char exec_prefix[MAXPATHLEN+1];
static char progpath[MAXPATHLEN+1];
static char *module_search_path = NULL;
else
pythonhome = NULL;
}
- else
+ 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;
char *
Py_GetExecPrefix()
{
- return Py_GetPrefix();
+ if (!module_search_path)
+ calculate_path();
+
+ return exec_prefix;
}
char *
$(PATHOBJ)\MD5Module.obj \
$(PATHOBJ)\NewModule.obj \
$(PATHOBJ)\Operator.obj \
+ $(PATHOBJ)\PCREModule.obj \
+ $(PATHOBJ)\PyPCRE.obj \
+ $(PATHOBJ)\RotorModule.obj \
$(PATHOBJ)\PosixModule.obj \
$(PATHOBJ)\RegexModule.obj \
$(PATHOBJ)\RegExpr.obj \
# /Q = Omit IBM Copyright
# /W2 = Show Warnings/Errors Only
-_GEN = /G4 /Gm /Gd
+_GEN = /G4 /Gm /Gd-
# /G4 = Generate Code for 486 (Use 386 for Debugger)
# /Gm = Use Multithread Runtime
# /Gd = Dynamically Load Runtime
# /Gu = Advise Linker All Ext Data is ID'd
# /Gl = Have Linker Remove Unused Fns
-_DBG = /DHAVE_CONFIG_H /DUSE_SOCKET
+_DBG = /Wpro- /Ti- /DHAVE_CONFIG_H /DUSE_SOCKET
+ # /Wpro= Generate Compiler Warnings re Missing Prototypes
# /Ti = Embed Debugger/Analyzer Recs
# /Tm = Enable Debug Memory Fns
# /Tx = Request Full Dump Upon Exception
--- /dev/null
+IBM VisualAge C/C++ for OS/2\r
+============================\r
+\r
+To build Python for OS/2, change into ./os2vacpp and issue an 'NMAKE'\r
+command. This will build a PYTHON15.DLL containing the set of Python\r
+modules listed in config.c and a small PYTHON.EXE to start the\r
+interpreter.\r
+\r
+By changing the C compiler flag /Gd- in the makefile to /Gd+, you can\r
+reduce the size of these by causing Python to dynamically link to the\r
+C runtime DLLs instead of including their bulk in your binaries. \r
+However, this means that any system on which you run Python must have\r
+the VAC++ compiler installed in order to have those DLLs available.\r
+\r
+During the build process you may see a couple of harmless warnings:\r
+\r
+ From the C Compiler, "No function prototype given for XXX", which\r
+ comes from the use of K&R parameters within Python for portability.\r
+\r
+ From the ILIB librarian, "Module Not Found (XXX)", which comes\r
+ from its attempt to perform the (-+) operation, which removes and\r
+ then adds a .OBJ to the library. The first time a build is done,\r
+ it obviously cannot remove what is not yet built.\r
+\r
+This build includes support for most Python functionality as well as\r
+TCP/IP sockets. It omits the Posix ability to 'fork' a process but\r
+supports threads using OS/2 native capabilities. I have tried to\r
+support everything possible but here are a few usage notes.\r
+\r
+\r
+-- os.popen() Usage Warnings\r
+\r
+With respect to my implementation of popen() under OS/2:\r
+\r
+ import os\r
+\r
+ fd = os.popen("pkzip.exe -@ junk.zip", 'wb')\r
+ fd.write("file1.txt\n")\r
+ fd.write("file2.txt\n")\r
+ fd.write("file3.txt\n")\r
+ fd.write("\x1a") # Should Not Be Necessary But Is\r
+ fd.close()\r
+\r
+There is a bug, either in the VAC++ compiler or OS/2 itself, where the\r
+simple closure of the write-side of a pipe -to- a process does not\r
+send an EOF to that process. I find I must explicitly write a\r
+control-Z (EOF) before closing the pipe. This is not a problem when\r
+using popen() in read mode.\r
+\r
+One other slight difference with my popen() is that I return None\r
+from the close(), instead of the Unix convention of the return code\r
+of the spawned program. I could find no easy way to do this under\r
+OS/2.\r
+\r
+\r
+-- BEGINLIBPATH/ENDLIBPATH\r
+\r
+With respect to environment variables, this OS/2 port supports the\r
+special-to-OS/2 magic names of 'BEGINLIBPATH' and 'ENDLIBPATH' to\r
+control where to load conventional DLLs from. Those names are\r
+intercepted and converted to calls on the OS/2 kernel APIs and\r
+are inherited by child processes, whether Python-based or not.\r
+\r
+A few new attributes have been added to the os module:\r
+\r
+ os.meminstalled # Count of Bytes of RAM Installed on Machine\r
+ os.memkernel # Count of Bytes of RAM Reserved (Non-Swappable)\r
+ os.memvirtual # Count of Bytes of Virtual RAM Possible\r
+ os.timeslice # Duration of Scheduler Timeslice, in Milliseconds\r
+ os.maxpathlen # Maximum Length of a Path Specification, in chars\r
+ os.maxnamelen # Maximum Length of a Single Dir/File Name, in chars\r
+ os.version # Version of OS/2 Being Run e.g. "4.00"\r
+ os.revision # Revision of OS/2 Being Run (usually zero)\r
+ os.bootdrive # Drive that System Booted From e.g. "C:"\r
+ # (useful to find the CONFIG.SYS used to boot with)\r
+\r
+\r
+-- Using Python as the Default OS/2 Batch Language\r
+\r
+Note that OS/2 supports the Unix technique of putting the special\r
+comment line at the time of scripts e.g. "#!/usr/bin/python" in\r
+a different syntactic form. To do this, put your script into a file\r
+with a .CMD extension and added 'extproc' to the top as follows:\r
+\r
+ extproc C:\Python\Python.exe -x\r
+ import os\r
+ print "Hello from Python"\r
+\r
+The '-x' option tells Python to skip the first line of the file\r
+while processing the rest as normal Python source.\r
+\r
+\r
+-- Suggested Environment Variable Setup\r
+\r
+With respect to the environment variables for Python, I use the\r
+following setup:\r
+\r
+ Set PYTHONHOME=E:\Tau\Projects\Python;D:\DLLs\r
+ Set PYTHONPATH=.;E:\Tau\Projects\Python\Lib; \\r
+ E:\Tau\Projects\Python\Lib\plat-win\r
+\r
+The EXEC_PREFIX (optional second pathspec on PYTHONHOME) is where\r
+you put any Python extension DLLs you may create/obtain. There\r
+are none provided with this release.\r
+\r
+\r
+-- Contact Info\r
+\r
+If you have questions, suggestions or problems specifically with\r
+the OS/2 VAC++ port of Python, please contact me at:\r
+\r
+ Jeff Rush <jrush@summit-research.com>.\r
+\r
+I support no other platform but OS/2 (and eventually AmigaDOS).\r