Here is my port of python 1.3

Please read this entire file before reporting problems :-)
Read README for the license and more info...

UPDATE 10/06/96
  This is the dr7 version, brand new compiled with my brand new unlimited linker !! I've
taken again the original distribution, in order to add as few patches as possible, and
yes there are fewer patches than in the dr6 version. And a few new ones, also, but they go
along newly supported posix functions, so indeed it's fine :-)
  The socket module still lacks some functions : use with care !

THIS DISTRIBUTION
  As you all want it asap I have packed my python dir (which is big, due partly to all the
object files, the compiled libraries and the executables. To cut down on the size, i don't
include the objects modules in the distrib, but leave the libs and executables as you may
not have the unlimited linker). I give you what's needed to try it out immediately !
  Also note that my python dir is the original python 1.3 archive from which i have removed
the mac/nt/dos specific code, useless for us, so basically you need what's here and nothing
more, except the postscript docs :-)
  Note also that i've tar.gz'ed the tex files inside my Doc dir.
  I may or may not provide a cleaner distribution...
If you want to start the interpreter right now, please at least go to the KNOWN BUGS
section.

DON'T USE (or know what you do, because you're on your own !):
configure
the toplevel makefile
Modules/makesetup
---------------------
	these files either work bad or will try to modified files i had to change
	manually. If you want to use them, look at what they modify, and at least
	backup everything !
	configure crashes sh, and it and makesetup rely on sed, but I don't trust sed :-)
	Actually now i've done the work you should no longer need to run configure.
	If i have the time i'll do makesetup in python !

DON'T CHANGE
the makefiles
config.h
-------------
	If you do so be aware of what you do ! especially with the #define's related with
	include files. If you change something some files may want to include say
	sys/time.h again...

SAFELY CHANGE
Modules/config.c
	and
Modules/Makefile
----------------
	the MODOBJS list.
	You are welcome to add new modules but DON'T run makesetup, I don't trust it at all,
	rather please add what's needed by hand. Ie in the makefile you change the MODOBJS
	affectation (say add a 'mymodmodule.o'), and in config.c you add an extern void
	initmymod(); and a {"mymod",initmymod}, (with the comma) in the inittab array. See
	below, too.

MODIFIED FILES :
	For the source files I modified, i put the changes between #ifdef BEBOX/#else/#endif
	so you can easily figure out what had to be changed. This is what is assumed when
	I write changed, removed or added.
	Posix things : we currently have the following includes: Unix.h and unistd.h (which
	includes the previous one) so everywhere posix things are referenced the #inclusions
	must be replaced with unistd.h - this will be refered as the unistd.h problem.
	We have the same issue with sys/time.h, which i replaced with time.h, though it
	doesn't have some structures (timeval among others) - this will refered as the
	sys/time.h problem.
	sys/types.h is also missing, but Unix.h most of the time will do the job - refered
	as the sys/types.h problem.
config.h
Objects/Makefile
Parser/Makefile
Parser/intrcheck.c
Python/Makefile
------------------
	Because the configure script crashes sh, and anyway the AR or CFLAGS definitions
	are up to us beboxens. Also note that I have added a #define USE_SIGNAL_MODULE to tell
	Parser/intrcheck.c and Python/sigcheck.c not to define some functions that are more
	completely implemanted in Modules/signalmodule.c. That way we avoid some linking
	warnings, and the risk to link the libs in the bad order, which could lead to the
	inclusion of the bad implementations of these functions

Include/myselect.h
------------------
	Added #include <socket.h> for the FD_??? macros.
Include/thread.h
----------------
	See Python/thread_bebox.h.

Python/pythonrun.c
------------------
	Removed a reference to SIOUX.h and a SIOUX... function appearing when __MWERKS__
	is defined, but it's for the mac only.
Python/sigcheck.c
-----------------
	See Parser/intrcheck.c.
Python/thread.c
---------------
	Added the #include thread_bebox.h if BEBOX is defined.
Python/thread_bebox.h
---------------------
	This is a new file, the implementation of the threads, locks and semaphores functions
	used by python when compiled with threads. It is based on thread_foobar.h and inspired
	by the implementation for other architecture (I looked at what did exactly the nt and
	aix version, as thread_foobar.h is not clear about what must be done exactly).
	Also, unfortunately the exit_thread() name clashes with the new exit_thread kernel call
	so I have renamed the Python function to _Py_exit_thread in thread_bebox,
	Include/thread.h and Modules/threadmodule.c.

Modules/threadmodule.c
----------------------
	See Python/thread_bebox.h.
Modules/signalmodule.c
----------------------
	Added #define _SIGMAX __signal_max (don't ask me why, ask Be !).
	alarm is missing because as does its counterpart in libpos.so.
	See also Parser/intrcheck.c.
Modules/socketmodule.c
----------------------
	Added various #defines for missing constants, but probably the related features won't
	work. I also added the gethostbyaddr prototype by hand, it isn't in the headers but is
	in the libraries ! The functions getsockopt is currently removed because of missing
	getsockopt().
	The accept() on the BeBox always returns an address with sa_family==0 (should be 1 as
	only AF_INET is supported). I hope the address is correct anyway... Patched the support
	function makesockaddr() so that it handles 0 and 1 as AF_INET. It works, that way, with
	the sample examples in the python library manual, with both the server and the client.
	*** will have to check if that bug is still present !!!!
Modules/Setup
-------------
	I updated this file according to the available modules, though it's quite useless,
	as i didn't used makesetup to update the makefile and config.c
Modules/config.c
----------------
	The job of makesetup is done by hand, ie if you want to add or remove a module, before
	recompiling you add or remove an extern void initMyModule(); statement and a a line
	{"MyMod",initMyMod}, in the inittab array (look at it, it's simple !).
Modules/Makefile
----------------
	This is the big piece : first it has the definitions for CC, CFLAGS and the like, as
	the other makefiles, then the list of the modules object files to add to libModule.a
	(ie that will be available in the interpreter) is maintained by hand. This list is
	in the variable MODOBJS. This is the only thing you may change safely, unless you
	experiment a complete rebuild.
	Also we use the provided getopt.c, because the Be libraries don't export getopt().
	There are some definitions here and there. If you don't understand something, ask me.
	And now this makefile will build a static, monolythic binary, pythonstatic and a
	shared libs version, more on this hereafter.
Modules/libPyCore.exp
---------------------
	Contains the exported symbols (well some ! Add any symbol causing a linker error if you
	add new modules).

CURRENTLY AVAILABLE MODULES :
array, math, regex, strop, struct, time, fcntl, audioop, imageop, rgbimg, md5, rotor,
parser, binascii, environment, timing, select, posixmodule, signal
-------------------------------------------------------------------------------------
	They compiled (more or less...) fine because they are system independant or the BeOS
	is unix compatible enough for them. Note that posix module is now in this list as it
	compiles fine, as well as signal.
thread
------
	I wrote it :-) No big deal, but it is there and it works.
	Notice that it only exports the threads and locks functions, and not full semaphores.
	I've tested the threads and lock with scripts, but not the semaphores of course.
	Some of the threads implementation for other architectures leave the semaphore functions
	empty, ie python currently doesn't use them, but anyway if somebody wants them they
	can be added.
socket
------
	Compiles, thanks to some constants taken from Linux :-) Of course I guess that if they
	aren't in the includes it's probably that the associated features are not implemented,
	but anyway the source is ready for a more complete implementation.
	Now that fdopen is there, i hope we can use read() and write() on sockets. I'll have to
	check that too.

MODULES THAT COULD BE AVAILABLES :
stdwin
------
	Could be nice. But on the other hand I would rather implement modules for the Be API
	first.
one of the dynamic loading modules
----------------------------------
	To be able to load modules on the fly, couple scripts with apps more tightly than
	through inter process communication...
	This could be done with the BeOS images, I'll have to look at it later. Once again
	if anybody is interested...
new
---
	If somebody really wants it, it compiles fine. But I find it useless :-)

MODULES THAT MAKE NO SENSE ON BeOS AND THAT YOU'LL NEVER HAVE :-)
objc
--------------------------------------------------------------------
	NeXT and objective c dependant.
pwd, grp, crypt, dbm, gbm, termios, nis, mpz, curses, syslog, sybase, gdbm, bsddb
---------------------------------------------------------------------------------
	Rely on Unix/multi user/commercial apps/libraries we don't have yet.
sundevaudio
-----------
	Guess what !
gl, fm, sgi, imgfile, al, cd, cl, sv, fl
----------------------------------------
	SGI dependant.
	Actually if somebody ports OpenGL it'll be possible to adapt gl i think.
 
ABOUT SHARED LIBS :
  The monolythic binary is 330 kB with the modules i included. It's quite big especially
if you want to run several of them, as the interpreter process can't handle several
scripts at the same time.
  I've found out how worked shared libs on the BeOS. It appears you can't have 2 libraries
that reference each other. Though that's what the four python libraries do !
  (Actually Jon tells me you have to make "stubs" versions (w/ empty declarations) of the
libs, but my tests under dr6 showed there was a bug in the relocation process. I'll have to
try again with dr7, stay tuned :-)
  So I've built ONE shared library which embeds the 4 libraries, getopt.o and config.o.
It is called libPyCore.so, is currently 325 kB and will be installed in your python/ dir
Then the python process is main.o only and is 4 kB. It is built under the name python in
your python/ dir.
  I still build the statically linked version, pythonstatic (330 kB).

REBUILDING PYTHON
  First if you want to change things in config.h you should rebuild ALL the object files.
Then the building order is :
- Objects/
- Parser/
- Python/
- Modules/
  Ie you go and type make in each of these dirs, in the given order. If you rebuild the
libObjects.a, libParser.a or libPython.a be sure to run make from Modules/ aswell, because
this is where the python executable is built.
  Any warning is suspect ! Find what's wrong or tell me.

TESTING YOUR BRAND NEW VERSION
  If you rebuild please do the testall test according to README. You can also run pystone
the dhrystone-like benchmark (type python Tools/scripts/pystone.py), and should get
something like 115 pystones/sec. Guido's 040 33 MHz Macintosh achieve 55 pystones/s :-)
testall SHOULD report an error with the float data type. Actually you can check with a
little c program that 36.0!=12.0+24.0 and -36.!=-12.0+(-24.0) :-)
  To do the remaining tests, comment the lines that test the floating point number in
Lib/test/test_types.py (lines 82 and 85) and rerun the test, it shouldn't report other
errors.

YOUR SCRIPTS
Putting #!/boot/mypythondir/python on the first line will enable you launching them from
the shell without further care.

KNOWN BUGS
There is still the float oddity, but it's the only bug i found in the interpreter itself.
All other bugs should be up to the modules (who said the posix module ?).
Note that the following (posixy) problems are solved : isatty, popen, execv, fdopen,
strdup, fileno. Thanks Be !

TO COME
- Modules to access the Be API from python.
- From the kernel kit all that could be useful is a dynamic loading module built on top of
the images.
- But first I think I'll do the App kit, a part of the Storage kit (what's needed to deal
with files, probably the database related classes will be for later), and the Interface
kit, because I'd like to use it to write interfaces.
  Yep, I know this part is the same than in february (so long ago !) but unfortunately my
days don't have 50-60 hours :-)
  Once again if somebody is willing to write something, tell it, so we don't do the same
things at the same time.

THE GREETINGS :-)
For the dr6 version, to 5bats who finally found out how to assemble the code for
__ptr_glue to something I could use on the bebox (this was an oddity that probably could
have been solved otherwise, but at that time we were missing some clues about libdll.a
and some CW operations).
For this release, to Chris Herborth, in advance of the modules he will certainly add very
soon ;-)

AND NOW ?
Go and read the docs, and have fun !

Benoit Triquet
triquet_ben@lsi.supelec.fr