42 lines · 1.9 KB · Text
RawDownload
Q. I want to port Python to a new platform.  How do I begin? A. I guess the two things to start with is to familiarize yourselfwith are the development system for your target platform and thegeneric build process for Python.  Make sure you can compile and run asimple hello-world program on your target platform.  Make sure you cancompile and run the Python interpreter on a platform to which it hasalready been ported (preferably Unix, but Mac or Windows will do,too). I also would never start something like this without at leastmedium-level understanding of your target platform (i.e. how it isgenerally used, how to write platform specific apps etc.) and Python(or else you'll never know how to test the results). The build process for Python, in particular the Makefiles in thesource distribution, will give you a hint on which files to compilefor Python.  Not all source files are relevant -- some are platformspecific, others are only used in emergencies (e.g. getopt.c).  TheMakefiles tell the story. You'll also need a pyconfig.h file tailored for your platform.  You canstart with pyconfig.h.in, read the comments and turn on definitions thatapply to your platform. And you'll need a config.c file, which lists the built-in modules yousupport.  Start with Modules/config.c.in. Finally, you'll run into some things that aren't supported on yourtarget platform.  Forget about the posix module for now -- simply take it out of the config.c file. Bang on it until you get a >>> prompt.  (You may have to disable theimporting of "site.py" and "exceptions.py" by passing -X and -Soptions. Then bang on it until it executes very simple Python statements. Now bang on it some more.  At some point you'll want to use the osmodule; this is the time to start thinking about what to to with theposix module.  It's okay to simply #ifdef out those functions thatcause problems; the remaining ones will be quite useful.