blob: 60ce9a8241ddc4e7cb993b9839a130fceb13758f [file] [log] [blame]
Guido van Rossum6ca3def1998-08-10 16:36:48 +00001Q. I want to port Python to a new platform. How do I begin?
2
3A. I guess the two things to start with is to familiarize yourself
4with are the development system for your target platform and the
5generic build process for Python. Make sure you can compile and run a
6simple hello-world program on your target platform. Make sure you can
7compile and run the Python interpreter on a platform to which it has
8already been ported (preferably Unix, but Mac or Windows will do,
9too).
10
11I also would never start something like this without at least
12medium-level understanding of your target platform (i.e. how it is
13generally used, how to write platform specific apps etc.) and Python
14(or else you'll never know how to test the results).
15
16The build process for Python, in particular the Makefiles in the
17source distribution, will give you a hint on which files to compile
18for Python. Not all source files are relevant -- some are platform
19specific, others are only used in emergencies (e.g. getopt.c). The
20Makefiles tell the story.
21
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000022You'll also need a pyconfig.h file tailored for your platform. You can
23start with pyconfig.h.in, read the comments and turn on definitions that
Guido van Rossum6ca3def1998-08-10 16:36:48 +000024apply to your platform.
25
26And you'll need a config.c file, which lists the built-in modules you
27support. Start with Modules/config.c.in.
28
29Finally, you'll run into some things that aren't supported on your
30target platform. Forget about the posix module for now -- simply take
31it out of the config.c file.
32
33Bang on it until you get a >>> prompt. (You may have to disable the
34importing of "site.py" and "exceptions.py" by passing -X and -S
35options.
36
37Then bang on it until it executes very simple Python statements.
38
39Now bang on it some more. At some point you'll want to use the os
40module; this is the time to start thinking about what to to with the
41posix module. It's okay to simply #ifdef out those functions that
42cause problems; the remaining ones will be quite useful.