annotate Misc/Porting @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents cf58b73322f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8912
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 Q. I want to port Python to a new platform. How do I begin?
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 A. I guess the two things to start with is to familiarize yourself
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 with are the development system for your target platform and the
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 generic build process for Python. Make sure you can compile and run a
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 simple hello-world program on your target platform. Make sure you can
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 compile and run the Python interpreter on a platform to which it has
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 already been ported (preferably Unix, but Mac or Windows will do,
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 too).
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 I also would never start something like this without at least
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 medium-level understanding of your target platform (i.e. how it is
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 generally used, how to write platform specific apps etc.) and Python
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 (or else you'll never know how to test the results).
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 The build process for Python, in particular the Makefiles in the
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 source distribution, will give you a hint on which files to compile
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 for Python. Not all source files are relevant -- some are platform
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 specific, others are only used in emergencies (e.g. getopt.c). The
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 Makefiles tell the story.
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
18835
2dea40e40d9d Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents: 8912
diff changeset
22 You'll also need a pyconfig.h file tailored for your platform. You can
2dea40e40d9d Patch #411138: Rename config.h to pyconfig.h. Closes bug #231774.
Martin v. Löwis <martin@v.loewis.de>
parents: 8912
diff changeset
23 start with pyconfig.h.in, read the comments and turn on definitions that
8912
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 apply to your platform.
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 And you'll need a config.c file, which lists the built-in modules you
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 support. Start with Modules/config.c.in.
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 Finally, you'll run into some things that aren't supported on your
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 target platform. Forget about the posix module for now -- simply take
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 it out of the config.c file.
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
32
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 Bang on it until you get a >>> prompt. (You may have to disable the
59830
cf58b73322f8 Fix plural.
Georg Brandl <georg@python.org>
parents: 59829
diff changeset
34 importing of "site.py" by passing the -S option.)
8912
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 Then bang on it until it executes very simple Python statements.
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 Now bang on it some more. At some point you'll want to use the os
56814
127d623396ab Merged revisions 73286,73294,73296,73459,73462-73463,73544,73576-73577,73595-73596,73693-73694,73704-73705,73707,73713,73937-73940,73945,73951,73979 via svnmerge from
Georg Brandl <georg@python.org>
parents: 18835
diff changeset
39 module; this is the time to start thinking about what to do with the
8912
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 posix module. It's okay to simply #ifdef out those functions that
459bda940daa mini-faq on porting python
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 cause problems; the remaining ones will be quite useful.