blob: bd010ec407d2be756cd52de3945a2b13904eb7a9 [file] [log] [blame]
Andrew MacIntyre41d97d62002-02-17 05:23:30 +00001This is a port of Python 2.3 to OS/2 using the EMX development tools
2=========================================================================
3
4What's new since the previous release
5-------------------------------------
6
7This release of the port incorporates the following changes from the
8December 24, 2001 release of the Python 2.2 port:
9
10- based on the Python v2.3 final release source.
11
12
13Licenses and info about Python and EMX
14--------------------------------------
15
16Please read the file README.Python-2.3 included in this package for
17information about Python 2.3. This file is the README file from the
18Python 2.3 source distribution available via http://www.python.org/
19and its mirrors. The file LICENCE.Python-2.3 is the text of the Licence
20from the Python 2.3 source distribution.
21
22Note that the EMX package that this package depends on is released under
23the GNU General Public Licence. Please refer to the documentation
24accompanying the EMX Runtime libraries for more information about the
25implications of this. A copy of version 2 of the GPL is included as the
26file COPYING.gpl2.
27
28Readline and GDBM are covered by the GNU General Public Licence. I think
29Eberhard Mattes' porting changes to BSD DB v1.85 are also GPL'ed (BSD DB
30itself is BSD Licenced). ncurses and expat appear to be covered by MIT
31style licences - please refer to the source distributions for more detail.
32zlib is distributable under a very free license. GNU MP and GNU UFC are
33under the GNU LGPL (see file COPYING.lib).
34
35My patches to the Python-2.x source distributions, and any other packages
36used in this port, are placed in the public domain.
37
38This software is provided 'as-is', without any express or implied warranty.
39In no event will the author be held liable for any damages arising from the
40use of the software.
41
42I do hope however that it proves useful to someone.
43
44
45Other ports
46-----------
47
48There have been ports of previous versions of Python to OS/2.
49
50The best known would be that by Jeff Rush, most recently of version
511.5.2. Jeff used IBM's Visual Age C++ (v3) for his ports, and his
52patches have been included in the Python 2.3 source distribution.
53
54Andrew Zabolotny implemented a port of Python v1.5.2 using the EMX
55development tools. His patches against the Python v1.5.2 source
56distribution have become the core of this port, and without his efforts
57this port wouldn't exist. Andrew's port also appears to have been
58compiled with his port of gcc 2.95.2 to EMX, which I have but have
59chosen not to use for the binary distribution of this port (see item 21
60of the "YOU HAVE BEEN WARNED" section below).
61
62Previous Python port releases by me:-
63 - v2.0 on March 31, 2001;
64 - v2.0 on April 25, 2001 (cleanup release + Stackless variant);
65 - v2.1 on June 17, 2001;
66 - v2.0 (Stackless re-release) on June 18, 2001.
67 - v2.1.1 on August 5, 2001;
68 - v2.1.1 on August 12, 2001 (cleanup release);
69 - v2.1.1 (updated DLL) on August 14, 2001.
70 - v2.2b2 on December 8, 2001 (not uploaded to archive sites)
71 - v2.2c1 on December 16, 2001 (not uploaded to archive sites)
72 - v2.2 on December 24, 2001
73
74It is possible to have these earlier ports still usable after installing
75this port - see the README.os2emx.multiple_versions file, contributed by
76Dr David Mertz, for a suggested approach to achieving this.
77
78
79Software requirements
80---------------------
81
82This package requires the EMX Runtime package, available from the
83Hobbes (http://hobbes.nmsu.edu/) and LEO (http://archiv.leo.org/)
84archives of OS/2 software. I have used EMX version 0.9d fix04 in
85developing this port.
86
87My development system is running OS/2 v4 with fixpack 12.
88
893rd party software which has been linked into dynamically loaded modules:
90- ncurses (see http://dickey.his.com/ for more info, v5.2)
91- GNU Readline (Kai Uwe Rommel's port available from Hobbes or LEO, v2.1)
92- GNU GDBM (Kai Uwe Rommel's port available from Hobbes or LEO, v1.7.3)
93- zlib (Hung-Chi Chu's port available from Hobbes or LEO, v1.1.3)
94- expat (from ftp://ftp.jclark.com/pub/xml/, v1.2)
95- GNU MP (Peter Meerwald's port available from LEO, v2.0.2)
96- GNU UFC (Kai Uwe Rommel's port available from LEO, v2.0.4)
97
98The zlib module requires the Z.DLL to be installed - see the Installation
99section and item 12 of the "YOU HAVE BEEN WARNED" section for more
100information.
101
102About this port
103---------------
104
105I have attempted to make this port as complete and functional as I can,
106notwithstanding the issues in the "YOU HAVE BEEN WARNED" section below.
107
108Core components:
109
110Python.exe is linked as an a.out executable, ie using EMX method E1
111to compile & link the executable. This is so that fork() works (see
112"YOU HAVE BEEN WARNED" item 2).
113
114Python23.dll is created as a normal OMF DLL, with an OMF import
115library and module definition file. There is also an a.out (.a) import
116library to support linking the DLL to a.out executables.
117
118This port has been built with complete support for multithreading.
119
120Modules:
121
122As far as possible, extension modules have been made dynamically loadable
123when the module is intended to be built this way. I haven't yet changed
124the building of Python's standard modules over to using the DistUtils.
125
126See "YOU HAVE BEEN WARNED" item 5 for notes about the fcntl module, and
127"YOU HAVE BEEN WARNED" item 14 for notes about the pwd and grp modules.
128
129Support for case sensitive module import semantics has been added to match
130the Windows release. This can be deactivated by setting the PYTHONCASEOK
131environment variable (the value doesn't matter) - see "YOU HAVE BEEN WARNED"
132item 16.
133
134Optional modules:
135
136Where I've been able to locate the required 3rd party packages already
137ported to OS/2, I've built and included them.
138
139These include ncurses (_curses, _curses_panel), BSD DB (bsddb),
140GNU GDBM (gdbm, dbm), zlib (zlib), GNU Readline (readline), expat
141(pyexpat), GNU MP (mpz) and GNU UFC (crypt).
142
143I have built these modules statically linked against the 3rd party
144libraries, with the exception of zlib. Unfortunately my attempts to use
145the dll version of GNU readline have been a dismal failure, in that when
146the dynamically linked readline module is active other modules
147immediately provoke a core dump when imported.
148
149Only the BSD DB package (part of the BSD package distributed with EMX)
150needed source modifications to be used for this port, pertaining to use
151of errno with multithreading.
152
153The other packages, except for ncurses and zlib, needed Makefile changes
154for multithreading support but no source changes.
155
156The _curses_panel module is a potential problem - see "YOU HAVE BEEN
157WARNED" item 17.
158
159Upstream source patches:
160
161No updates to the Python 2.3 release have become available.
162
163Eberhard Mattes' EMXFIX04 update to his EMX 0.9d tools suite includes
164bug fixes for the BSD DB library. The bsddb module included in this
165port incorporates these fixes.
166
167Library and other distributed Python code:
168
169The Python standard library lives in the Lib directory. All the standard
170library code included with the Python 2.3 source distribution is included
171in the binary archive, with the exception of the dos-8x3 and tkinter
172subdirectories which have been omitted to reduce the size of the binary
173archive - the dos-8x3 components are unnecessary duplicates and Tkinter
174is not supported by this port (yet). All the plat-* subdirectories in the
175source distribution have also been omitted, and a plat-os2emx directory
176included.
177
178The Tools and Demo directories contain a collection of Python scripts.
179To reduce the size of the binary archive, the Demo/sgi, Demo/Tix,
180Demo/tkinter, Tools/audiopy and Tools/IDLE subdirectories have been
181omitted as not being supported by this port. The Misc directory has
182also been omitted.
183
184All subdirectories omitted from the binary archive can be reconstituted
185from the Python 2.3 source distribution, if desired.
186
187Support for building Python extensions:
188
189The Config subdirectory contains the files describing the configuration
190of the interpreter and the Makefile, import libraries for the Python DLL,
191and the module definition file used to create the Python DLL. The
192Include subdirectory contains all the standard Python header files
193needed for building extensions.
194
195As I don't have the Visual Age C++ compiler, I've made no attempt to
196have this port support extensions built with that compiler.
197
198
199Packaging
200---------
201
202This port is packaged into several archives:
203- python-2.3-os2emx-bin-02????.zip (binaries, library modules)
204- python-2.3-os2emx-src-03????.zip (source patches and makefiles)
205
206Documentation for the Python language, as well as the Python 2.3
207source distibution, can be obtained from the Python website
208(http://www.python.org/) or the Python project pages at Sourceforge
209(http://sf.net/projects/python/).
210
211
212Installation
213------------
214
215Obtain and install, as per the included instructions, the EMX runtime
216package.
217
218If you wish to use the zlib module, you will need to obtain and install
219the Z.DLL from Hung-Chi Chu's port of zlib v1.1.3 (zlib113.zip). See also
220"YOU HAVE BEEN WARNED" item 12 below.
221
222Unpack this archive, preserving the subdirectories, in the root directory
223of the drive where you want Python to live.
224
225Add the Python directory (eg C:\Python23) to the PATH and LIBPATH
226variables in CONFIG.SYS.
227
228You should then set the PYTHONHOME and PYTHONPATH environment variables
229in CONFIG.SYS.
230
231PYTHONHOME should be set to Python's top level directory. PYTHONPATH
232should be set to the semicolon separated list of principal Python library
233directories.
234I use:
235 SET PYTHONHOME=F:/Python23
236 SET PYTHONPATH=F:/Python23/Lib;F:/Python23/Lib/plat-os2emx;
237 F:/Python23/Lib/lib-dynload;F:/Python23/Lib/site-packages
238
239NOTE!: the PYTHONPATH setting above is linewrapped for this document - it
240should all be on one line in CONFIG.SYS!
241
242If you wish to use the curses module, you should set the TERM and TERMINFO
243environment variables appropriately.
244
245If you don't already have ncurses installed, I have included a copy of the
246EMX subset of the Terminfo database included with the ncurses-5.2 source
247distribution. This can be used by setting the TERMINFO environment variable
248to the path of the Terminfo subdirectory below the Python home directory.
249On my system this looks like:
250 SET TERMINFO=F:/Python23/Terminfo
251
252For the TERM environment variable, I would try one of the following:
253 SET TERM=ansi
254 SET TERM=os2
255 SET TERM=window
256
257You will have to reboot your system for these changes to CONFIG.SYS to take
258effect.
259
260If you wish to compile all the included Python library modules to bytecode,
261you can change into the Python home directory and run the COMPILEALL.CMD
262batch file.
263
264You can execute the regression tests included with the Python 2.3 source
265distribution by changing to the Python 2.3 home directory and executing the
266REGRTEST.CMD batch file. The following tests are known to fail at this
267time:
268- test_longexp (see "YOU HAVE BEEN WARNED" item 1);
269- test_mhlib (I don't know of any port of MH to OS/2);
270- test_pwd (see "YOU HAVE BEEN WARNED" item 14, probably a bug in my code);
271- test_grp (as per test_pwd);
272- test_strftime (see "YOU HAVE BEEN WARNED" item 20);
273- test_socketserver (fork() related, see "YOU HAVE BEEN WARNED" item 2).
274
275
276YOU HAVE BEEN WARNED!!
277----------------------
278
279I know about a number of nasties in this port.
280
2811. EMX's malloc() and/or the underlying OS/2 VM system aren't particularly
282comfortable with Python's use of heap memory. The test_longexp regression
283test exhausts the available swap space on a machine with 64MB of RAM with
284150MB of available swap space.
285
286Using a crudely instrumented wrapper around malloc()/realloc()/free(), the
287heap memory usage of the expression at the core of the test
288(eval('[' + '2,' * NUMREPS + ']')) is as follows (approximately):
289 NUMREPS = 1 => 300k
290 NUMREPS = 10000 => 22MB
291 NUMREPS = 20500 => 59MB
292
293I don't even have enough memory to try for NUMREPS = 25000 :-(, let alone
294the NUMREPS = 65580 in test_longexp! I do have a report that the test
295succeeds in the presence of sufficient memory (~200MB RAM).
296
297During the course of running the test routine, the Python parser
298allocates lots of 21 byte memory chunks, each of which is actually
299a 64 byte allocation. There are a smaller number of 3 byte allocations
300which consume 12 bytes each. Consequently, more than 3 times as much
301memory is allocated than is actually used.
302
303The Python Object Allocator code (PyMalloc) was introduced in Python 2.1
304for Python's core to be able to wrap the malloc() system to deal with
305problems with "unfriendly" malloc() behaviour, such as this. Unfortunately
306for the OS/2 port, it is only supported for the allocation of memory for
307objects, whereas my research into this problem indicates it is the parser
308which is source of this particular malloc() frenzy.
309
310I have attempted using PyMalloc to manage all of Python's memory
311allocation. While this works fine (modulo the socket regression test
312failing in the absence of a socket.pyc), it is a significant performance
313hit - the time to run the regression test blows out from ~3.5 minutes to
314~5.75 minutes on my system.
315
316I therefore don't plan to pursue this any further for the time being.
317
318Be aware that certain types of expressions could well bring your system
319to its knees as a result of this issue. I have modified the longexp test
320to report failure to highlight this.
321
3222. Eberhard Mattes, author of EMX, writes in his documentation that fork()
323is very inefficient in the OS/2 environment. It also requires that the
324executable be linked in a.out format rather than OMF. Use the os.exec
325and/or the os.spawn family of functions where possible.
326
327{3. Issue resolved...}
328
3294. In the absence of GNU Readline, terminating the interpreter requires a
330control-Z (^Z) followed by a carriage return. Jeff Rush documented this
331problem in his Python 1.5.2 port. With Readline, a control-D (^D) works
332as per the standard Unix environment.
333
3345. EMX only has a partial implementation of fcntl(). The fcntl module
335in this port supports what EMX supports. If fcntl is important to you,
336please review the EMX C Library Reference (included in .INF format in the
337EMXVIEW.ZIP archive as part of the complete EMX development tools suite).
338Because of other side-effects I have modified the test_fcntl.py test
339script to deactivate the exercising of the missing functionality.
340
3416. The BSD DB module is linked against DB v1.85. This version is widely
342known to have bugs, although some patches have become available (and are
343incorporated into the included bsddb module). Unless you have problems
344with software licenses which would rule out GDBM (and the dbm module
345because it is linked against the GDBM library) or need it for file format
346compatibility, you may be better off deleting it and relying on GDBM. I
347haven't looked at porting the version of the module supporting the later
348SleepyCat releases of BSD DB, which would also require a port of the
349SleepyCat DB package.
350
3517. The readline module has been linked against ncurses rather than the
352termcap library supplied with EMX.
353
354{8. Workaround implemented}
355
3569. I have configured this port to use "/" as the preferred path separator
357character, rather than "\" ('\\'), in line with the convention supported
358by EMX. Backslashes are still supported of course, and still appear in
359unexpected places due to outside sources that don't get normalised.
360
36110. While the DistUtils components are now functional, other
362packaging/binary handling tools and utilities such as those included in
363the Demo and Tools directories - freeze in particular - are unlikely to
364work. If you do get them going, I'd like to know about your success.
365
36611. I haven't set out to support the [BEGIN|END]LIBPATH functionality
367supported by one of the earlier ports (Rush's??). If it works let me know.
368
36912. There appear to be several versions of Z.DLL floating around - the one
370I have is 45061 bytes and dated January 22, 1999. I have a report that
371another version causes SYS3175s when the zlib module is imported.
372
37314. As a result of the limitations imposed by EMX's library routines, the
374standard extension module pwd only synthesises a simple passwd database,
375and the grp module cannot be supported at all.
376
377I have written substitutes, in Python naturally, which can process real
378passwd and group files for those applications (such as MailMan) that
379require more than EMX emulates. I have placed pwd.py and grp.py in
380Lib/plat-os2emx, which is usually before Lib/lib-dynload (which contains
381pwd.pyd) in the PYTHONPATH. If you have become attached to what pwd.pyd
382supports, you can put Lib/lib-dynload before Lib/plat-os2emx in PYTHONPATH
383or delete/rename pwd.py & grp.py.
384
385pwd.py & grp.py support locating their data files by looking in the
386environment for them in the following sequence:
387pwd.py: $ETC_PASSWD (%ETC_PASSWD%)
388 $ETC/passwd (%ETC%/passwd)
389 $PYTHONHOME/Etc/passwd (%PYTHONHOME%/Etc/passwd)
390grp.py: $ETC_GROUP (%ETC_GROUP%)
391 $ETC/group (%ETC%/group)
392 $PYTHONHOME/Etc/group (%PYTHONHOME%/Etc/group)
393
394Both modules support using either the ":" character (Unix standard) or
395";" (OS/2, DOS, Windows standard) field separator character, and pwd.py
396implements the following drive letter conversions for the home_directory and
397shell fields (for the ":" separator only):
398 $x -> x:
399 x; -> x:
400
401Example versions of passwd and group are in the Etc subdirectory. Note
402that as of this release, this code fails the regression test. I'm looking
403into why, and hope to have this fixed.
404
40515. As of Python 2.1, termios support has mutated. There is no longer a
406platform specific TERMIOS.py containing the symbolic constants - these
407now live in the termios module. EMX's termios routines don't support all
408of the functionality now exposed by the termios module - refer to the EMX
409documentation to find out what is supported.
410
41116. The case sensitive import semantics introduced in Python 2.1 for other
412case insensitive but case preserving file/operating systems (Windows etc),
413have been incorporated into this port, and are active by default. Setting
414the PYTHONCASEOK environment variable (to any value) reverts to the
415previous (case insensitive) semantics.
416
41717. Because I am statically linking ncurses, the _curses_panel
418module has potential problems arising from separate library data areas.
419To avoid this, I have configured the _curses_.pyd (imported as
420"_curses_panel") to import the ncurses symbols it needs from _curses.pyd.
421As a result the _curses module must be imported before the _curses_panel
422module. As far as I can tell, the modules in the curses package do this.
423If you have problems attempting to use the _curses_panel support please
424let me know, and I'll look into an alternative solution.
425
42618. I tried enabling the Python Object Allocator (PYMALLOC) code. While
427the port built this way passes the regression test, the Numpy extension
428(I tested v19.0.0) as built with with the port's DistUtils code doesn't
429work. Specifically, attempting to "import Numeric" provokes a core dump.
430Supposedly Numpy v20.1.0 contains a fix for this, but for reason outlined
431in item 1 above, PYMALLOC is not enabled in this release.
432
43319. sys.platform now reports "os2emx" instead of "os2". os.name still
434reports "os2". This change was to make it easier to distinguish between
435the VAC++ build (being maintained by Michael Muller) and the EMX build
436(this port), principally for DistUtils.
437
43820. it appears that the %W substitution in the EMX strftime() routine has
439an off-by-one bug. strftime was listed as passing the regression tests
440in previous releases, but this fact appears to have been an oversight in
441the regression test suite. To fix this really requires a portable
442strftime routine - I'm looking into using one from FreeBSD, but its not
443ready yet.
444
44521. previous releases of my Python ports have used the GCC optimisations
446"-O2 -fomit-frame-pointer". After experimenting with various optimisation
447settings, including deactivating assert()ions, I have concluded that "-O2"
448appears the best compromise for GCC 2.8.1 on my hardware. Curiously,
449deactivating assert() (via defining NDEBUG) _negatively_ impacts
450performance, allbeit only slightly, so I've chosen to leave the assert()s
451active.
452
453I did try using Andrew Zabolotny's (p)gcc 2.95.2 compiler, and in
454general concluded that it produced larger objects that ran slower
455than Mattes' gcc 2.8.1 compiler.
456
457Pystone ratings varied from just over 2000/s (no optimisation at all)
458to just under 3300/s (gcc 2.8.1, -O2) on my K6/2-300 system, for
459100,000 iterations per run (rather than the default 10000).
460
461As a result of the optimisation change, the Python DLL is about 10%
462smaller than in the 2.1 release, and many of the dynamically loadable
463modules are smaller too.
464
465[2001/08/12]
466
46722. As of this release, os.spawnv() and os.spawnve() now expose EMX's
468library routines rather than use the emulation in os.py.
469
470In order to make use of some of the features this makes available in
471the OS/2 environment, you should peruse the relevant EMX documentation
472(EMXLIB.INF in the EMXVIEW.ZIP archive accompanying the EMX archives
473on Hobbes or LEO). Be aware that I have exposed all the "mode" options
474supported by EMX, but there are combinations that either cannot be
475practically used by/in Python or have the potential to compromise your
476system's stability.
477
47823. pythonpm.exe in previous releases was just python.exe with the
479WINDOWAPI linker option set in the pythonpm.def file. In practice,
480this turns out to do nothing useful.
481
482I have written a replacement which wraps the Python DLL in a genuine
483Presentation Manager application. This version actually runs the
484Python interpreter in a separate thread from the PM shell, in order
485that PythonPM has a functioning message queue as good PM apps should.
486In its current state, PythonPM's window is hidden. It can be displayed,
487although it will have no content as nothing is ever written to the
488window. Only the "hide" button is available. Although the code
489has support for shutting PythonPM down when the Python interpreter is
490still busy (via the "control" menu), this is not well tested and given
491comments I've come across in EMX documentation suggesting that the
492thread killing operation has problems I would suggest caution in
493relying on this capability.
494
495PythonPM processes commandline parameters normally. The standard input,
496output and error streams are only useful if redirected, as PythonPM's
497window is not a console in any form and so cannot accept or display
498anything. This means that the -i option is ineffective.
499
500Because the Python thread doesn't create its own message queue, creating
501PM Windows and performing most PM operations is not possible from within
502this thread. How this will affect supporting PM extensions (such as
503Tkinter using a PM port of Tcl/Tk, or wxPython using the PM port of
504WxWindows) is still being researched.
505
506Note that os.fork() _DOES_NOT_WORK_ in PythonPM - SYS3175s are the result
507of trying. os.spawnv() _does_ work. PythonPM passes all regression tests
508that the standard Python interpreter (python.exe) passes, with the exception
509of test_fork1 and test_socket which both attempt to use os.fork().
510
511I very much want feedback on the performance, behaviour and utility of
512PythonPM. I would like to add a PM console capability to it, but that
513will be a non-trivial effort. I may be able to leverage the code in
514Illya Vaes' Tcl/Tk port, which would make it easier.
515
516[2001/08/14]
517
51824. os.chdir() now uses EMX's _chdir2(), which supports changing
519both drive and directory at once. Similarly, os.getcwd() now uses
520EMX's _getcwd() which returns drive as well as path.
521
522[2001/12/08] - 2.2 Beta 2
523
52425. pyconfig.h (previously known as config.h) is now located in the
525Include subdirectory with all other include files.
526
527[2001/12/16] - 2.2 Release Candidate 1
528
529[2001/12/08] - 2.2 Final
530
531... probably other issues that I've not encountered, or don't remember :-(
532
533If you encounter other difficulties with this port, which can be
534characterised as peculiar to this port rather than to the Python release,
535I would like to hear about them. However I cannot promise to be able to do
536anything to resolve such problems. See the Contact section below...
537
538
539To do...
540--------
541
542In no particular order of apparent importance or likelihood...
543
544- support Tkinter and/or alternative GUI (wxWindows??)
545
546
547Credits
548-------
549
550In addition to people identified above, I'd like to thank:
551- the BDFL, Guido van Rossum, and crew for Python;
552- Dr David Mertz, for trying out a pre-release of this port;
553- the Python-list/comp.lang.python community;
554- John Poltorak, for input about pwd/grp.
555
556Contact
557-------
558
559Constructive feedback, negative or positive, about this port is welcome
560and should be addressed to me at the e-mail addresses below.
561
562I intend creating a private mailing list for announcements of fixes &
563updates to this port. If you wish to receive such e-mail announcments,
564please send me an e-mail requesting that you be added to this list.
565
566Andrew MacIntyre
567E-mail: andymac@bullseye.apana.org.au, or andymac@pcug.org.au
568Web: http://www.andymac.org/
569
57024 December, 2001.