/Misc/Porting

http://unladen-swallow.googlecode.com/ · #! · 42 lines · 33 code · 9 blank · 0 comment · 0 complexity · 2388a8b28fc82ed58e592fa0320608b1 MD5 · raw file

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