10000 devguide/porting.rst at 04edcf341b801ff42d2db6c7927e99747aa06bc6 · python/devguide · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"images","path":"images","contentType":"directory"},{"name":"tools","path":"tools","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".hgignore","path":".hgignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"Makefile","path":"Makefile","contentType":"file"},{"name":"README.rst","path":"README.rst","contentType":"file"},{"name":"appendix.rst","path":"appendix.rst","contentType":"file"},{"name":"buildbots.rst","path":"buildbots.rst","contentType":"file"},{"name":"buildworker.rst","path":"buildworker.rst","contentType":"file"},{"name":"clang.rst","path":"clang.rst","contentType":"file"},{"name":"committing.rst","path":"committing.rst","contentType":"file"},{"name":"communication.rst","path":"communication.rst","contentType":"file"},{"name":"compiler.rst","path":"compiler.rst","contentType":"file"},{"name":"conf.py","path":"conf.py","contentType":"file"},{"name":"coredev.rst","path":"coredev.rst","contentType":"file"},{"name":"coverage.rst","path":"coverage.rst","contentType":"file"},{"name":"coverity.rst","path":"coverity.rst","contentType":"file"},{"name":"devcycle.rst","path":"devcycle.rst","contentType":"file"},{"name":"developers.csv","path":"developers.csv","contentType":"file"},{"name":"developers.rst","path":"developers.rst","contentType":"file"},{"name":"docquality.rst","path":"docquality.rst","contentType":"file"},{"name":"documenting.rst","path":"documenting.rst","contentType":"file"},{"name":"experts.rst","path":"experts.rst","contentType":"file"},{"name":"exploring.rst","path":"exploring.rst","contentType":"file"},{"name":"extensions.rst","path":"extensions.rst","contentType":"file"},{"name":"fixingissues.rst","path":"fixingissues.rst","contentType":"file"},{"name":"garbage_collector.rst","path":"garbage_collector.rst","contentType":"file"},{"name":"gdb.rst","path":"gdb.rst","contentType":"file"},{"name":"gitbootcamp.rst","path":"gitbootcamp.rst","contentType":"file"},{"name":"grammar.rst","path":"grammar.rst","contentType":"file"},{"name":"help.rst","path":"help.rst","contentType":"file"},{"name":"index.rst","path":"index.rst","contentType":"file"},{"name":"langchanges.rst","path":"langchanges.rst","contentType":"file"},{"name":"make.bat","path":"make.bat","contentType":"file"},{"name":"motivations.rst","path":"motivations.rst","contentType":"file"},{"name":"porting.rst","path":"porting.rst","contentType":"file"},{"name":"pullrequest.rst","path":"pullrequest.rst","contentType":"file"},{"name":"requirements.txt","path":"requirements.txt","contentType":"file"},{"name":"runtests.rst","path":"runtests.rst","contentType":"file"},{"name":"setup.rst","path":"setup.rst","contentType":"file"},{"name":"silencewarnings.rst","path":"silencewarnings.rst","contentType":"file"},{"name":"stdlibchanges.rst","path":"stdlibchanges.rst","contentType":"file"},{"name":"tracker.rst","path":"tracker.rst","contentType":"file"},{"name":"triaging.rst","path":"triaging.rst","contentType":"file"}],"totalCount":47}},"fileTreeProcessingTime":2.6287849999999997,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":63972479,"defaultBranch":"main","name":"devguide","ownerLogin":"python","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2016-07-22T17:48:56.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/1525981?v=4","public":true,"private":false,"isOrgOwned":true},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"04edcf341b801ff42d2db6c7927e99747aa06bc6","listCacheKey":"v0:1743482989.0","canEdit":false,"refType":"tree","currentOid":"04edcf341b801ff42d2db6c7927e99747aa06bc6"},"path":"porting.rst","currentUser":null,"blob":{"rawLines":null,"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/python/devguide/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"porting.rst","displayUrl":"https://github.com/python/devguide/blob/04edcf341b801ff42d2db6c7927e99747aa06bc6/porting.rst?raw=true","headerInfo":{"blobSize":"2.09 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":null,"isGitLfs":false,"onBranch":false,"shortPath":"fdf01ee","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fdevguide%2Fblob%2F04edcf341b801ff42d2db6c7927e99747aa06bc6%2Fporting.rst","isCSV":false,"isRichtext":true,"toc":[{"level":1,"text":"Porting Python to a new platform","anchor":"porting-python-to-a-new-platform","htmlText":"Porting Python to a new platform"}],"lineInfo":{"truncatedLoc":"42","truncatedSloc":"33"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"reStructuredText","languageID":419,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/python/devguide/blob/04edcf341b801ff42d2db6c7927e99747aa06bc6/porting.rst","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/python/devguide/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/python/devguide/raw/04edcf341b801ff42d2db6c7927e99747aa06bc6/porting.rst","renderImageOrRaw":false,"richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch1 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003ePorting Python to a new platform\u003c/h1\u003e\u003ca id=\"user-content-porting-python-to-a-new-platform\" class=\"anchor\" aria-label=\"Permalink: Porting Python to a new platform\" href=\"#porting-python-to-a-new-platform\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThe first step is to familiarize yourself with the development toolchain on\nthe platform in question, notably the C compiler. Make sure you can compile and\nrun a hello-world program using the target compiler.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eNext, learn how to compile and run the Python interpreter on a platform to\nwhich it has already been ported; preferably Unix, but Windows will\ndo, too. The build process for Python, in particular the \u003ccode\u003eMakefile\u003c/code\u003e in the\nsource distribution, will give you a hint on which files to compile\nfor Python. Not all source files are relevant: some are platform\nspecific, others are only used in emergencies (e.g. \u003ccode\u003egetopt.c\u003c/code\u003e).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIt is not recommended to start porting Python without at least medium-level\nunderstanding of your target platform; i.e. how it is generally used, how to\nwrite platform specific apps, etc. Also, some Python knowledge is required, or\nyou will be unable to verify that your port is working correctly.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eYou will need a \u003ccode\u003epyconfig.h\u003c/code\u003e file tailored for your platform. You can\nstart with \u003ccode\u003epyconfig.h.in\u003c/code\u003e, read the comments, and turn on definitions that\napply to your platform. Also, you will need a \u003ccode\u003econfig.c\u003c/code\u003e file, which lists\nthe built-in modules you support. Again, starting with\n\u003ccode\u003eModules/config.c.in\u003c/code\u003e is recommended.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eFinally, you will run into some things that are not supported on your\ntarget platform. Forget about the \u003ccode\u003eposix\u003c/code\u003e module in the beginning. You can\nsimply comment it out of the \u003ccode\u003econfig.c\u003c/code\u003e file.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eKeep working on it until you get a \u003ccode\u003e\u0026gt;\u0026gt;\u0026gt;\u003c/code\u003e prompt. You may have to disable the\nimporting of \u003ccode\u003esite.py\u003c/code\u003e by passing the \u003ccode\u003e-S\u003c/code\u003e option. When you have a prompt,\nbang on it until it executes very simple Python statements.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAt some point you will want to use the \u003ccode\u003eos\u003c/code\u003e module; this is the time to start\nthinking about what to do with the \u003ccode\u003eposix\u003c/code\u003e module. It is okay to simply\ncomment out functions in the \u003ccode\u003eposix\u003c/code\u003e module that cause problems; the\nremaining ones will be quite useful.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eBefore you are done, it is highly recommended to run the Python regression test\nsuite, as described in \u003ca href=\"#id1\"\u003e\u003cspan id=\"user-content-id2\"\u003e:ref:`runtests`\u003c/span\u003e\u003c/a\u003e.\u003c/p\u003e\n\n\u003c/article\u003e","renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":"/python/.github/blob/5a0a7cb55767fb3667fe2391bcb66bda638edcb4/FUNDING.yml","showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":true,"symbols":[]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/python/devguide/branches":{"post":"Z49P01NkrZc2oq3TYscbLrF0tRZx5Uq4PLHzgKgCEHRzjTL4gXcz5RDAgU9hwCVdWuJTMDm6CMY5Vh9Bv0K7WA"},"/repos/preferences":{"post":"DL3NlRFFFDMm4GQhvlZH7jgC-oBu-WncOEX9hCG6cwlMgWDkvOtKccx5wVQLIz3fRrhgfwQsYEZvMnzHzRP6Pg"}}},"title":"devguide/porting.rst at 04edcf341b801ff42d2db6c7927e99747aa06bc6 · python/devguide","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1ae9fa256942.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}
0