{"id":69135,"date":"2026-01-31T05:57:54","date_gmt":"2026-01-30T21:57:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/69135.html"},"modified":"2026-01-31T05:57:54","modified_gmt":"2026-01-30T21:57:54","slug":"pyproject-toml-%e5%8f%91%e5%b8%83-python-%e8%bd%af%e4%bb%b6%e5%8c%85","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/69135.html","title":{"rendered":"pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305"},"content":{"rendered":"<h3>1. \u5178\u578b\u7684\u9879\u76ee\u7ed3\u6784<\/h3>\n<p>\u5728\u5f00\u59cb\u914d\u7f6e\u4e4b\u524d&#xff0c;\u8bf7\u786e\u4fdd\u4f60\u7684\u6587\u4ef6\u7ec4\u7ec7\u7ed3\u6784\u6e05\u6670\u3002\u4e00\u4e2a\u6807\u51c6\u7684\u5305\u7ed3\u6784\u5982\u4e0b&#xff1a;<\/p>\n<p>my_package_project\/<br \/>\n\u251c\u2500\u2500 src\/<br \/>\n\u2502   \u2514\u2500\u2500 my_package\/          # \u4f60\u7684\u6e90\u4ee3\u7801\u76ee\u5f55<br \/>\n\u2502       \u251c\u2500\u2500 __init__.py<br \/>\n\u2502       \u2514\u2500\u2500 core.py<br \/>\n\u251c\u2500\u2500 tests\/                   # \u6d4b\u8bd5\u4ee3\u7801<br \/>\n\u251c\u2500\u2500 pyproject.toml           # \u6838\u5fc3\u914d\u7f6e\u6587\u4ef6<br \/>\n\u251c\u2500\u2500 README.md                # \u9879\u76ee\u8bf4\u660e<br \/>\n\u251c\u2500\u2500 LICENSE                  # \u8bb8\u53ef\u8bc1<br \/>\n\u2514\u2500\u2500 .gitignore               # \u5ffd\u7565\u6784\u5efa\u4ea7\u7269<\/p>\n<hr \/>\n<h3>2. \u7f16\u5199 pyproject.toml<\/h3>\n<p>\u8fd9\u662f\u6574\u4e2a\u6d41\u7a0b\u7684\u5fc3\u810f\u3002\u5b83\u4e3b\u8981\u7531\u4e09\u4e2a\u90e8\u5206\u7ec4\u6210&#xff1a;\u6784\u5efa\u7cfb\u7edf\u3001\u9879\u76ee\u5143\u6570\u636e\u548c\u5de5\u5177\u914d\u7f6e\u3002<\/p>\n<h4>A. \u6784\u5efa\u7cfb\u7edf ([build-system])<\/h4>\n<p>\u8fd9\u544a\u8bc9\u5b89\u88c5\u7a0b\u5e8f&#xff08;\u5982 pip&#xff09;\u4f7f\u7528\u54ea\u4e2a\u540e\u7aef\u6765\u6784\u5efa\u4f60\u7684\u5305\u3002\u76ee\u524d\u6700\u5e38\u7528\u7684\u662f setuptools&#xff0c;\u4f46\u4f60\u4e5f\u53ef\u4ee5\u9009\u62e9 hatchling\u3001flit \u6216 poetry-core\u3002<\/p>\n<p>[build-system]<br \/>\nrequires &#061; [&#034;setuptools&gt;&#061;61.0&#034;]<br \/>\nbuild-backend &#061; &#034;setuptools.build_meta&#034;<\/p>\n<h4>B. \u9879\u76ee\u5143\u6570\u636e ([project])<\/h4>\n<p>\u8fd9\u91cc\u5b9a\u4e49\u4e86\u5305\u7684\u540d\u79f0\u3001\u7248\u672c\u3001\u4f5c\u8005\u4ee5\u53ca\u5b83\u5728 PyPI \u4e0a\u7684\u5c55\u793a\u4fe1\u606f\u3002<\/p>\n<p>[project]<br \/>\nname &#061; &#034;my_package_fancy_name&#034;<br \/>\nversion &#061; &#034;0.1.0&#034;<br \/>\ndescription &#061; &#034;\u4e00\u4e2a\u975e\u5e38\u9177\u7684\u793a\u4f8b\u5305&#034;<br \/>\nreadme &#061; &#034;README.md&#034;<br \/>\nrequires-python &#061; &#034;&gt;&#061;3.8&#034;<br \/>\nlicense &#061; {text &#061; &#034;MIT&#034;}<br \/>\nauthors &#061; [<br \/>\n    {name &#061; &#034;\u4f60\u7684\u540d\u5b57&#034;, email &#061; &#034;yourname&#064;example.com&#034;},<br \/>\n]<br \/>\nkeywords &#061; [&#034;sample&#034;, &#034;package&#034;, &#034;guide&#034;]<br \/>\n# \u9879\u76ee\u4f9d\u8d56<br \/>\ndependencies &#061; [<br \/>\n    &#034;requests &gt;&#061; 2.28.0&#034;,<br \/>\n    &#034;numpy&#034;,<br \/>\n]<\/p>\n<p>[project.urls]<br \/>\n&#034;Homepage&#034; &#061; &#034;https:\/\/github.com\/yourusername\/my_package&#034;<br \/>\n&#034;Bug Tracker&#034; &#061; &#034;https:\/\/github.com\/yourusername\/my_package\/issues&#034;<\/p>\n<hr \/>\n<h3>3. \u6784\u5efa\u8f6f\u4ef6\u5305<\/h3>\n<p>\u5728\u53d1\u5e03\u4e4b\u524d&#xff0c;\u4f60\u9700\u8981\u5c06\u4ee3\u7801\u201c\u6253\u5305\u201d\u6210\u4e24\u79cd\u683c\u5f0f&#xff1a;sdist&#xff08;\u6e90\u7801\u5206\u53d1\u7248&#xff09;\u548c wheel&#xff08;\u4e8c\u8fdb\u5236\u5206\u53d1\u7248&#xff09;\u3002<\/p>\n<li>\u5b89\u88c5\u6784\u5efa\u5de5\u5177&#xff1a;<\/li>\n<p>pip install &#8211;upgrade build<\/p>\n<li>\u6267\u884c\u6784\u5efa&#xff1a; \u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c&#xff1a;<\/li>\n<p>python -m build<\/p>\n<p>\u6ce8\u610f&#xff1a;\u8fd0\u884c\u5b8c\u6210\u540e&#xff0c;\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u65b0\u7684 dist\/ \u6587\u4ef6\u5939\u3002\u91cc\u9762\u5305\u542b\u4e86\u4e00\u4e2a .tar.gz \u6587\u4ef6\u548c\u4e00\u4e2a .whl \u6587\u4ef6\u3002\u8fd9\u5c31\u662f\u4f60\u8981\u4e0a\u4f20\u5230 PyPI \u7684\u201c\u6210\u54c1\u201d\u3002<\/p>\n<hr \/>\n<h3>4. \u53d1\u5e03\u5230 PyPI<\/h3>\n<p>\u6211\u4eec\u5c06\u4f7f\u7528 twine \u5de5\u5177\u5c06\u5305\u5b89\u5168\u5730\u4e0a\u4f20\u5230 Python Package Index (PyPI)\u3002<\/p>\n<h4>\u7b2c\u4e00\u6b65&#xff1a;\u6ce8\u518c\u5e76\u83b7\u53d6 Token<\/h4>\n<li>\u5728 PyPI \u5b98\u7f51 \u6ce8\u518c\u8d26\u53f7\u3002<\/li>\n<li>\u524d\u5f80 Account Settings&#xff0c;\u751f\u6210\u4e00\u4e2a API Token&#xff08;\u5efa\u8bae\u6743\u9650\u8303\u56f4\u8bbe\u4e3a \u201cEntire account\u201d \u6216\u5982\u679c\u662f\u66f4\u65b0\u5305\u5219\u8bbe\u4e3a\u7279\u5b9a\u9879\u76ee&#xff09;\u3002<\/li>\n<li>\u8bb0\u4f4f\u8fd9\u4e2a Token&#xff0c;\u5b83\u53ea\u4f1a\u51fa\u73b0\u4e00\u6b21\u3002<\/li>\n<h4>\u7b2c\u4e8c\u6b65&#xff1a;\u4e0a\u4f20<\/h4>\n<li>\u5b89\u88c5 Twine&#xff1a;<\/li>\n<p>pip install &#8211;upgrade twine<\/p>\n<li>\u4e0a\u4f20\u5230 TestPyPI (\u5f3a\u70c8\u5efa\u8bae)&#xff1a; \u5148\u5728\u6d4b\u8bd5\u670d\u52a1\u5668\u4e0a\u8bd5\u8fd0\u884c&#xff0c;\u786e\u4fdd\u5305\u770b\u8d77\u6765\u6ca1\u95ee\u9898\u3002<\/li>\n<p>python -m twine upload &#8211;repository testpypi dist\/*<\/p>\n<li>\u6b63\u5f0f\u53d1\u5e03&#xff1a; \u4e00\u5207\u5c31\u7eea\u540e&#xff0c;\u63a8\u9001\u5230\u6b63\u5f0f\u73af\u5883&#xff1a;<\/li>\n<p>python -m twine upload dist\/*<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5178\u578b\u7684\u9879\u76ee\u7ed3\u6784<br \/>\n\u5728\u5f00\u59cb\u914d\u7f6e\u4e4b\u524d&#xff0c;\u8bf7\u786e\u4fdd\u4f60\u7684\u6587\u4ef6\u7ec4\u7ec7\u7ed3\u6784\u6e05\u6670\u3002\u4e00\u4e2a\u6807\u51c6\u7684\u5305\u7ed3\u6784\u5982\u4e0b&#xff1a;<br \/>\nmy_package_project\/<br \/>\n\u251c\u2500\u2500 src\/<br \/>\n\u2502   \u2514\u2500\u2500 my_package\/          # \u4f60\u7684\u6e90\u4ee3\u7801\u76ee\u5f55<br \/>\n\u2502       \u251c\u2500\u2500 __init__.py<br \/>\n\u2502       \u2514\u2500\u2500 core.py<br \/>\n\u251c\u2500\u2500 tests\/                   # \u6d4b\u8bd5\u4ee3\u7801<br \/>\n\u251c\u2500\u2500 pyproject.toml           # <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,190],"topic":[],"class_list":["post-69135","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/69135.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1. \u5178\u578b\u7684\u9879\u76ee\u7ed3\u6784 \u5728\u5f00\u59cb\u914d\u7f6e\u4e4b\u524d&#xff0c;\u8bf7\u786e\u4fdd\u4f60\u7684\u6587\u4ef6\u7ec4\u7ec7\u7ed3\u6784\u6e05\u6670\u3002\u4e00\u4e2a\u6807\u51c6\u7684\u5305\u7ed3\u6784\u5982\u4e0b&#xff1a; my_package_project\/ \u251c\u2500\u2500 src\/ \u2502  \u2514\u2500\u2500 my_package\/     # \u4f60\u7684\u6e90\u4ee3\u7801\u76ee\u5f55 \u2502    \u251c\u2500\u2500 __init__.py \u2502    \u2514\u2500\u2500 core.py \u251c\u2500\u2500 tests\/          # \u6d4b\u8bd5\u4ee3\u7801 \u251c\u2500\u2500 pyproject.toml      #\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/69135.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-30T21:57:54+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/69135.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/69135.html\",\"name\":\"pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-30T21:57:54+00:00\",\"dateModified\":\"2026-01-30T21:57:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/69135.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/69135.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/69135.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/69135.html","og_locale":"zh_CN","og_type":"article","og_title":"pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1. \u5178\u578b\u7684\u9879\u76ee\u7ed3\u6784 \u5728\u5f00\u59cb\u914d\u7f6e\u4e4b\u524d&#xff0c;\u8bf7\u786e\u4fdd\u4f60\u7684\u6587\u4ef6\u7ec4\u7ec7\u7ed3\u6784\u6e05\u6670\u3002\u4e00\u4e2a\u6807\u51c6\u7684\u5305\u7ed3\u6784\u5982\u4e0b&#xff1a; my_package_project\/ \u251c\u2500\u2500 src\/ \u2502  \u2514\u2500\u2500 my_package\/     # \u4f60\u7684\u6e90\u4ee3\u7801\u76ee\u5f55 \u2502    \u251c\u2500\u2500 __init__.py \u2502    \u2514\u2500\u2500 core.py \u251c\u2500\u2500 tests\/          # \u6d4b\u8bd5\u4ee3\u7801 \u251c\u2500\u2500 pyproject.toml      #","og_url":"https:\/\/www.wsisp.com\/helps\/69135.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-30T21:57:54+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/69135.html","url":"https:\/\/www.wsisp.com\/helps\/69135.html","name":"pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-30T21:57:54+00:00","dateModified":"2026-01-30T21:57:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/69135.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/69135.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/69135.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"pyproject.toml \u53d1\u5e03 Python \u8f6f\u4ef6\u5305"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/69135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=69135"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/69135\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=69135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=69135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=69135"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=69135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}