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