Python-DX

What is Python-DX?

Long ago, in a galaxy far, far away... I compiled my own Python executable for MS-DOS. The result was called Python-DX and incorporated some features I missed in Python, but that were common in DOS compilers, like direct screen access, memory management, interrupt calls, etc. It was not very complete, and shortly after that I started using the Windows version, so it didn't get the chance to mature much.

Occasionally, I still get requests from people looking for Python-DX. Apparently it's still mentioned in some places on the Net (and some people still use DOS). Unfortunately, all I have is a few executables of pre-2.0 Pythons. I tinkered with Python-DX in 1997-99, so the Python 2.x series was not involved. Also, in 2001 I moved to the US, and I had to leave much behind. As a result, I have no documentation and no source code.

The executables

I uploaded a file dospythons.zip with three executables. See the download section.

python-152.exe is the "full" version of Python-DX (using Python 1.5.2, obviously by the name). A quick sample:

Python 1.5.2 (#21, Apr 14 1999, 22:19:01)  [GCC 2.7.2] on ms-dos7
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import _conio
>>> dir(_conio)
['__doc__', '__name__', 'blinkvideo', 'clreol', 'clrscr', 'delline', 'error', 'g
etch', 'gettextinfo', 'gotoxy', 'hidecursor', 'insline', 'intensevideo', 'printf
', 'showcursor', 'textbackground', 'textcolor', 'ungetch', 'wherex', 'wherey', '
window']
>>> _conio.getch()  # wait for keystroke
97
>>>

Python-DX has a number of custom modules. To see them, inspect sys.builtin_module_names:

>>> import sys
>>> sys.builtin_module_names
('__builtin__', '__main__', '_conio', '_dos', '_graph', '_locale', '_pc', '_sb',
 'array', 'avl', 'binascii', 'cPickle', 'cStringIO', 'cd', 'cmath', 'crypt', 'cu
rses', 'errno', 'fcntl', 'gdbm', 'grp', 'guibase', 'hirestimer', 'imp', 'kjbucke
ts', 'marshal', 'math', 'md5', 'memory', 'multiarray', 'mxDateTime', 'mxTextTool
s', 'mxTools', 'new', 'operator', 'parser', 'pcre', 'posix', 'pwd', 'rand', 'rea
dline', 'regex', 'reop', 'resource', 'rotor', 'saml1', 'select', 'sha', 'signal'
, 'socket', 'strop', 'struct', 'sys', 'termios', 'time', 'timing', 'xmap', 'zlib
')
>>>

The number of extra modules was cool for that time... emoticon:smile it included a number of Unix modules that the Windows version didn't have (readline, for example), and of course it had DOS-specific ones (_conio, guibase, hirestimer, memory, etc). On top of that, it had some third-party stuff like multiarray (from NumPy) and mxTools.

py152clean.exe is a "light" version, lacking all those modules. Useful on a memory-starving machine. What it does have is:

Python 1.5.2 (#4, Apr 14 1999, 21:03:54)  [GCC 2.7.2] on ms-dos7
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> sys.builtin_module_names
('__builtin__', '__main__', 'array', 'binascii', 'cPickle', 'cStringIO', 'cmath'
, 'errno', 'fcntl', 'grp', 'imp', 'marshal', 'math', 'md5', 'new', 'operator', '
parser', 'pcre', 'posix', 'pwd', 'regex', 'rotor', 'select', 'sha', 'signal', 's
ocket', 'strop', 'struct', 'sys', 'time')
>>>

Finally, python-numpy.exe includes a number of Numeric modules... as many as I could get to compile, IIRC. However, this is Python 1.5 rather than 1.5.2.

Python 1.5 (#59, Jan 30 1998, 15:00:00)  [GCC 2.7.2] on ms-dos7
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> sys.builtin_module_names
('__builtin__', '__main__', '_pc', 'array', 'avl', 'binascii', 'cPickle', 'cStri
ngIO', 'cmath', 'conio', 'curses', 'dos', 'errno', 'fast_umath', 'fcntl', 'fftpa
ck', 'gdbm', 'imp', 'kjbuckets', 'lapack_lite', 'marshal', 'math', 'md5', 'memor
y', 'multiarray', 'mxDateTime', 'mxTools', 'new', 'operator', 'parser', 'pcre',
'posix', 'rand', 'ranlib', 'readline', 'regex', 'reop', 'rotor', 'select', 'sign
al', 'strop', 'struct', 'sys', 'time', 'timing', 'umath', 'zlib')
>>>

How to use it

As said, I have no access to any documentation, if it still exists at all. So, you're basically on your own here. If you want to use the executables, you'll have to experiment. However, I do remember a few things to get you started:

  • If you're on a "pure" DOS system (DOS 6 or lower, not DOS 7 under Windows 95), you have to use the 8x3 filenames of the standard library. Also, setting the PYTHONCASEOK variable will be necessary (if I recall correctly), so 'import foo' will find file FOO.PY.

  • These are just the executables. Find a copy of the appropriate source (1.5 or 1.5.2) for the standard library.

  • Don't forget to set the PYTHONPATH environment variable and point it to wherever you put the standard library files.

  • You'll need a DOS extender. I used something called CWSDPMI, but others may work too. (DOS4GL?) You might have one already; just try the executable, if it doesn't work, maybe the lack of a DOS extender is the culprit.

  • You'll need at least a 386.

  • Maybe some old posts will be helpful as well.

Do-it-yourself

Writing an extension module is not extremely easy, but it's not extremely difficult either. If I can do it, everyone can. So if these executables are not sufficient for your purposes, you may want to consider to roll your own DOS Python. You'll need a C compiler; I used DJGPP, which has the nice feature of being able to compile most Unix-oid modules (or at least it did back in the day, don't know how things are now). It is possible that other C compilers work too, although I never could get them to compile Python.

Good luck... :-}

Links

  • For a more recent Python for DOS, see PythonD.