Skip to content

Commit 6ca3def

Browse files
committed
mini-faq on porting python
1 parent 71c3adb commit 6ca3def

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ can now use it to run arbitrary Python scripts in restricted mode).
167167
long ago.
168168

169169
- Major upgrade to ConfigParser.py; converted to using 're', added new
170-
exceptions, support underscore in section header and option name, no
171-
longer add 'name' option to every section.
170+
exceptions, support underscore in section header and option name. No
171+
longer add 'name' option to every section; instead, add '__name__'.
172172

173173
- The ihooks.py module now understands package imports.
174174

Misc/Porting

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

0 commit comments

Comments
 (0)