Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a34c313

Browse files
committed
New batch of patches by Jeff Rush; moved his readme.txt portion here.
1 parent cee1dca commit a34c313

5 files changed

Lines changed: 148 additions & 13 deletions

File tree

PC/os2vacpp/config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern void inittime();
6363
extern void initthread();
6464
extern void initcStringIO();
6565
extern void initcPickle();
66+
extern void initpcre();
6667
#ifdef WIN32
6768
extern void initmsvcrt();
6869
#endif
@@ -113,6 +114,7 @@ struct _inittab _PyImport_Inittab[] = {
113114
#endif
114115
{"cStringIO", initcStringIO},
115116
{"cPickle", initcPickle},
117+
{"pcre", initpcre},
116118
#ifdef WIN32
117119
{"msvcrt", initmsvcrt},
118120
#endif

PC/os2vacpp/config.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@
7474
/* Configuration Options for Finding Modules */
7575
#define PREFIX ""
7676
#define EXEC_PREFIX ""
77-
//#define VPATH "."
78-
79-
//#define PYTHONPATH PREFIX "/lib/python" VERSION DELIM \
80-
// PREFIX "/lib/python" VERSION "/test" DELIM \
81-
// EXEC_PREFIX "/lib/python" VERSION "/sharedmodules"
8277

8378
/***************************************************/
8479
/* 32-Bit IBM VisualAge C/C++ v3.0 for OS/2 */
@@ -91,7 +86,7 @@
9186
#define PYCC_VACPP /* Define Indicator of C Compiler */
9287

9388
/* Platform Filesystem */
94-
#define PYTHONPATH ".;.\\lib;.\\lib\\plat-os2;.\\lib\\dos_8x3;.\\lib\\lib-tk"
89+
#define PYTHONPATH ".;.\\lib;.\\lib\\plat-win;.\\lib\\dos-8x3;.\\lib\\lib-tk"
9590
#define DOSFILESYS /* OS/2 Uses the DOS File Naming Conventions */
9691
/* #define IMPORT_8x3_NAMES */
9792

@@ -483,7 +478,7 @@
483478
/* #define WITH_READLINE 1 */
484479

485480
/* Define if you have clock. */
486-
/* #define HAVE_CLOCK */
481+
#define HAVE_CLOCK
487482

488483
/* Define if you have ftime. */
489484
#define HAVE_FTIME
@@ -540,7 +535,7 @@
540535
/* #undef HAVE_TCSETPGRP */
541536

542537
/* Define if you have times. */
543-
/* #undef HAVE_TIMES */
538+
#define HAVE_TIMES
544539

545540
/* Define if you have uname. */
546541
/* #undef HAVE_UNAME */

PC/os2vacpp/getpathp.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ extern BOOL PyWin_IsWin32s();
5050

5151
/* Search in some common locations for the associated Python libraries.
5252
*
53-
* This version always returns "" for both prefix and exec_prefix.
53+
* Two directories must be found, the platform independent directory
54+
* (prefix), containing the common .py and .pyc files, and the platform
55+
* dependent directory (exec_prefix), containing the shared library
56+
* modules. Note that prefix and exec_prefix can be the same directory,
57+
* but for some installations, they are different.
5458
*
5559
* Py_GetPath() tries to return a sensible Python module search path.
5660
*
@@ -75,6 +79,7 @@ extern BOOL PyWin_IsWin32s();
7579
#endif
7680

7781
static char prefix[MAXPATHLEN+1];
82+
static char exec_prefix[MAXPATHLEN+1];
7883
static char progpath[MAXPATHLEN+1];
7984
static char *module_search_path = NULL;
8085

@@ -345,9 +350,21 @@ calculate_path()
345350
else
346351
pythonhome = NULL;
347352
}
348-
else
353+
else {
354+
char *delim;
355+
349356
strcpy(prefix, pythonhome);
350357

358+
/* Extract Any Optional Trailing EXEC_PREFIX */
359+
/* e.g. PYTHONHOME=<prefix>:<exec_prefix> */
360+
delim = strchr(prefix, DELIM);
361+
if (delim) {
362+
*delim = '\0';
363+
strcpy(exec_prefix, delim+1);
364+
} else
365+
strcpy(exec_prefix, EXEC_PREFIX);
366+
}
367+
351368
if (envpath && *envpath == '\0')
352369
envpath = NULL;
353370

@@ -475,7 +492,10 @@ Py_GetPrefix()
475492
char *
476493
Py_GetExecPrefix()
477494
{
478-
return Py_GetPrefix();
495+
if (!module_search_path)
496+
calculate_path();
497+
498+
return exec_prefix;
479499
}
480500

481501
char *

PC/os2vacpp/makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ MODULES = \
165165
$(PATHOBJ)\MD5Module.obj \
166166
$(PATHOBJ)\NewModule.obj \
167167
$(PATHOBJ)\Operator.obj \
168+
$(PATHOBJ)\PCREModule.obj \
169+
$(PATHOBJ)\PyPCRE.obj \
170+
$(PATHOBJ)\RotorModule.obj \
168171
$(PATHOBJ)\PosixModule.obj \
169172
$(PATHOBJ)\RegexModule.obj \
170173
$(PATHOBJ)\RegExpr.obj \
@@ -197,7 +200,7 @@ _BASE = /Q /W2 /I$(PROJINCLUDE)
197200
# /Q = Omit IBM Copyright
198201
# /W2 = Show Warnings/Errors Only
199202

200-
_GEN = /G4 /Gm /Gd
203+
_GEN = /G4 /Gm /Gd-
201204
# /G4 = Generate Code for 486 (Use 386 for Debugger)
202205
# /Gm = Use Multithread Runtime
203206
# /Gd = Dynamically Load Runtime
@@ -208,7 +211,8 @@ _OPT = /O /Gl
208211
# /Gu = Advise Linker All Ext Data is ID'd
209212
# /Gl = Have Linker Remove Unused Fns
210213

211-
_DBG = /DHAVE_CONFIG_H /DUSE_SOCKET
214+
_DBG = /Wpro- /Ti- /DHAVE_CONFIG_H /DUSE_SOCKET
215+
# /Wpro= Generate Compiler Warnings re Missing Prototypes
212216
# /Ti = Embed Debugger/Analyzer Recs
213217
# /Tm = Enable Debug Memory Fns
214218
# /Tx = Request Full Dump Upon Exception

PC/os2vacpp/readme.txt

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
IBM VisualAge C/C++ for OS/2
2+
============================
3+
4+
To build Python for OS/2, change into ./os2vacpp and issue an 'NMAKE'
5+
command. This will build a PYTHON15.DLL containing the set of Python
6+
modules listed in config.c and a small PYTHON.EXE to start the
7+
interpreter.
8+
9+
By changing the C compiler flag /Gd- in the makefile to /Gd+, you can
10+
reduce the size of these by causing Python to dynamically link to the
11+
C runtime DLLs instead of including their bulk in your binaries.
12+
However, this means that any system on which you run Python must have
13+
the VAC++ compiler installed in order to have those DLLs available.
14+
15+
During the build process you may see a couple of harmless warnings:
16+
17+
From the C Compiler, "No function prototype given for XXX", which
18+
comes from the use of K&R parameters within Python for portability.
19+
20+
From the ILIB librarian, "Module Not Found (XXX)", which comes
21+
from its attempt to perform the (-+) operation, which removes and
22+
then adds a .OBJ to the library. The first time a build is done,
23+
it obviously cannot remove what is not yet built.
24+
25+
This build includes support for most Python functionality as well as
26+
TCP/IP sockets. It omits the Posix ability to 'fork' a process but
27+
supports threads using OS/2 native capabilities. I have tried to
28+
support everything possible but here are a few usage notes.
29+
30+
31+
-- os.popen() Usage Warnings
32+
33+
With respect to my implementation of popen() under OS/2:
34+
35+
import os
36+
37+
fd = os.popen("pkzip.exe -@ junk.zip", 'wb')
38+
fd.write("file1.txt\n")
39+
fd.write("file2.txt\n")
40+
fd.write("file3.txt\n")
41+
fd.write("\x1a") # Should Not Be Necessary But Is
42+
fd.close()
43+
44+
There is a bug, either in the VAC++ compiler or OS/2 itself, where the
45+
simple closure of the write-side of a pipe -to- a process does not
46+
send an EOF to that process. I find I must explicitly write a
47+
control-Z (EOF) before closing the pipe. This is not a problem when
48+
using popen() in read mode.
49+
50+
One other slight difference with my popen() is that I return None
51+
from the close(), instead of the Unix convention of the return code
52+
of the spawned program. I could find no easy way to do this under
53+
OS/2.
54+
55+
56+
-- BEGINLIBPATH/ENDLIBPATH
57+
58+
With respect to environment variables, this OS/2 port supports the
59+
special-to-OS/2 magic names of 'BEGINLIBPATH' and 'ENDLIBPATH' to
60+
control where to load conventional DLLs from. Those names are
61+
intercepted and converted to calls on the OS/2 kernel APIs and
62+
are inherited by child processes, whether Python-based or not.
63+
64+
A few new attributes have been added to the os module:
65+
66+
os.meminstalled # Count of Bytes of RAM Installed on Machine
67+
os.memkernel # Count of Bytes of RAM Reserved (Non-Swappable)
68+
os.memvirtual # Count of Bytes of Virtual RAM Possible
69+
os.timeslice # Duration of Scheduler Timeslice, in Milliseconds
70+
os.maxpathlen # Maximum Length of a Path Specification, in chars
71+
os.maxnamelen # Maximum Length of a Single Dir/File Name, in chars
72+
os.version # Version of OS/2 Being Run e.g. "4.00"
73+
os.revision # Revision of OS/2 Being Run (usually zero)
74+
os.bootdrive # Drive that System Booted From e.g. "C:"
75+
# (useful to find the CONFIG.SYS used to boot with)
76+
77+
78+
-- Using Python as the Default OS/2 Batch Language
79+
80+
Note that OS/2 supports the Unix technique of putting the special
81+
comment line at the time of scripts e.g. "#!/usr/bin/python" in
82+
a different syntactic form. To do this, put your script into a file
83+
with a .CMD extension and added 'extproc' to the top as follows:
84+
85+
extproc C:\Python\Python.exe -x
86+
import os
87+
print "Hello from Python"
88+
89+
The '-x' option tells Python to skip the first line of the file
90+
while processing the rest as normal Python source.
91+
92+
93+
-- Suggested Environment Variable Setup
94+
95+
With respect to the environment variables for Python, I use the
96+
following setup:
97+
98+
Set PYTHONHOME=E:\Tau\Projects\Python;D:\DLLs
99+
Set PYTHONPATH=.;E:\Tau\Projects\Python\Lib; \
100+
E:\Tau\Projects\Python\Lib\plat-win
101+
102+
The EXEC_PREFIX (optional second pathspec on PYTHONHOME) is where
103+
you put any Python extension DLLs you may create/obtain. There
104+
are none provided with this release.
105+
106+
107+
-- Contact Info
108+
109+
If you have questions, suggestions or problems specifically with
110+
the OS/2 VAC++ port of Python, please contact me at:
111+
112+
Jeff Rush <[email protected]>.
113+
114+
I support no other platform but OS/2 (and eventually AmigaDOS).

0 commit comments

Comments
 (0)