forked from python/python-docs-zh-tw
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
370 lines (332 loc) · 22.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>發布 Python 模組 — Python 3.11.1 說明文件</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?2022.1" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<script src="../_static/translations.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="在 Python 3.11.1 說明文件 中搜尋"
href="../_static/opensearch.xml"/>
<link rel="author" title="關於這些文件" href="../about.html" />
<link rel="index" title="索引" href="../genindex.html" />
<link rel="search" title="搜尋" href="../search.html" />
<link rel="copyright" title="版權" href="../copyright.html" />
<link rel="next" title="安裝 Python 模組" href="../installing/index.html" />
<link rel="prev" title="API 和 ABI 版本管理" href="../c-api/apiabiversion.html" />
<link rel="canonical" href="https://docs.python.org/3/distributing/index.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<nav class="nav-content" role="navigation">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Logo"/>
</a>
<div class="version_switcher_placeholder"></div>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<path fill-rule="nonzero"
d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
</svg>
<input type="text" name="q" aria-label="快速搜尋"/>
<input type="submit" value="前往"/>
</form>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<div>
<h3><a href="../contents.html">目錄</a></h3>
<ul>
<li><a class="reference internal" href="#">發布 Python 模組</a><ul>
<li><a class="reference internal" href="#key-terms">關鍵術語</a></li>
<li><a class="reference internal" href="#open-source-licensing-and-collaboration">開源授權與協同合作</a></li>
<li><a class="reference internal" href="#installing-the-tools">安裝工具</a></li>
<li><a class="reference internal" href="#reading-the-python-packaging-user-guide">閱讀 Python 封裝使用者指南</a></li>
<li><a class="reference internal" href="#how-do-i">我該如何...?</a><ul>
<li><a class="reference internal" href="#choose-a-name-for-my-project">...為我的專案選擇一個名稱?</a></li>
<li><a class="reference internal" href="#create-and-distribute-binary-extensions">...建立和發布二進制擴充?</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>上個主題</h4>
<p class="topless"><a href="../c-api/apiabiversion.html"
title="上一章">API 和 ABI 版本管理</a></p>
</div>
<div>
<h4>下個主題</h4>
<p class="topless"><a href="../installing/index.html"
title="下一章">安裝 Python 模組</a></p>
</div>
<div role="note" aria-label="source link">
<h3>此頁面</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">回報錯誤</a></li>
<li>
<a href="https://github.com/python/cpython/blob/3.11/Doc/distributing/index.rst"
rel="nofollow">顯示原始碼
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>瀏覽</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="總索引"
accesskey="I">索引</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python 模組索引"
>模組</a> |</li>
<li class="right" >
<a href="../installing/index.html" title="安裝 Python 模組"
accesskey="N">下一頁</a> |</li>
<li class="right" >
<a href="../c-api/apiabiversion.html" title="API 和 ABI 版本管理"
accesskey="P">上一頁</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.11.1 Documentation</a> »
</li>
<li class="nav-item nav-item-this"><a href="">發布 Python 模組</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="快速搜尋" aria-label="快速搜尋" type="text" name="q" />
<input type="submit" value="前往" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
|
</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="distributing-python-modules">
<span id="distributing-index"></span><h1>發布 Python 模組<a class="headerlink" href="#distributing-python-modules" title="本標頭的永久連結">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">電子郵件<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference external" href="mailto:distutils-sig%40python.org">distutils-sig<span>@</span>python<span>.</span>org</a></p>
</dd>
</dl>
<p>作為一個普及的開源開發專案,Python 有一個活躍的支持社群,由其貢獻者及使用者組成,而他們也讓他們的軟體可被其他 Python 開發者在開源授權條款下使用。</p>
<p>這樣可以讓 Python 使用者們有效地共享和合作,並受益於其他人對常見(有時甚至是罕見)的問題已經建立的解決方案,更可以在公開社群中潛在地貢獻他們自己的解決方案。</p>
<p>這份指南涵蓋了上述過程中的發布部分。如果是要安裝其他的 Python 專案,請參考<a class="reference internal" href="#distributing-index"><span class="std std-ref">安裝 Python 模組</span></a>指南。</p>
<div class="admonition note">
<p class="admonition-title">備註</p>
<p>對於企業和其他機構的使用者,要注意到,許多組織對於使用和貢獻開源軟體都有自己的政策。在開始使用配備 Python 的發布及安裝工具時,請將那些政策納入考量。</p>
</div>
<section id="key-terms">
<h2>關鍵術語<a class="headerlink" href="#key-terms" title="本標頭的永久連結">¶</a></h2>
<ul class="simple">
<li><p><a class="reference external" href="https://pypi.org">Python 套件索引 (Python Package Index)</a> 是開源授權套件的一個公共儲存庫,其中的套件皆可被其他 Python 使用者所使用。</p></li>
<li><p><a class="reference external" href="https://www.pypa.io/">Python 封裝管理站 (Python Packaging Authority)</a> 是一個由開發者和說明文件作者組成的團隊,負責維護及改進標準封裝工具,以及相關的元資料 (metadata) 和檔案格式標準。他們在 <a class="reference external" href="https://github.com/pypa">GitHub</a> 和 <a class="reference external" href="https://bitbucket.org/pypa/">Bitbucket</a> 這兩個平台上維護各種工具、說明文件及問題追蹤系統。</p></li>
<li><p><a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> 是最早的建置和發布系統,於 1998 年首次被加入 Python 標準函式庫。雖然直接使用 <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> 的方式已經被逐步淘汰,它仍然是現今封裝和發布的基礎結構根基,而且它不僅仍然是標準函式庫的一部分,它的名稱也以其他的方式存活著(例如:用於協調 Python 封裝標準開發的郵寄清單就是以它命名)。</p></li>
<li><p><a class="reference external" href="https://setuptools.readthedocs.io/en/latest/">setuptools</a> 是 <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> 的一個(主要的)偶然出現的替代品,它於 2004 年首次被發布。相較於未修改的 <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> 工具,它最值得注意的新功能,是能夠宣告對其他套件的依賴性 (dependency)。它目前被推薦為 <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> 的一個替代方案,因其更新較為頻繁,且能在各個廣泛的 Python 版本之間,為較新的封裝標準提供一致性的支援。</p></li>
<li><p><a class="reference external" href="https://wheel.readthedocs.io/">wheel</a>(在此文中)是一個將 <code class="docutils literal notranslate"><span class="pre">bdist_wheel</span></code> 指令附加到 <a class="reference internal" href="../library/distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a>/<a class="reference external" href="https://setuptools.readthedocs.io/en/latest/">setuptools</a> 的專案。這會產生一個跨平台的二進制封裝格式(稱為「wheels」或「wheel 檔案」,並於 <span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-0427/"><strong>PEP 427</strong></a> 中被定義),它可讓 Python 函式庫,甚至那些包含二進制擴充的函式庫,可以在系統中被安裝,但不需要在本機進行建置。</p></li>
</ul>
</section>
<section id="open-source-licensing-and-collaboration">
<h2>開源授權與協同合作<a class="headerlink" href="#open-source-licensing-and-collaboration" title="本標頭的永久連結">¶</a></h2>
<p>在世界上多數地方,軟體會自動受版權所保護。這代表著其他開發人員需要明確的許可,才能複製、使用、修改和重新發布軟體。</p>
<p>開源授權是一種以相對一致的方式,明確地授予此類許可的方法,它允許開發人員透過為各種問題提供免費可用的共通解決方案,來達到高效率的共享和協作。這使得許多開發人員可以自由地將更多時間專注於處理他們在特定情況中遇到的相對獨特的問題。</p>
<p>Python 所提供的發布工具,被設計為讓開發人員能夠以合理的直觀方式,對該公用軟體庫回饋他們自己的貢獻,前提是他們願意這樣做。</p>
<p>同一個發布工具也可用於在組織內發布軟體,不論該軟體是否有作為開源軟體被發布。</p>
</section>
<section id="installing-the-tools">
<h2>安裝工具<a class="headerlink" href="#installing-the-tools" title="本標頭的永久連結">¶</a></h2>
<p>標準函式庫並不包含那些支援現代 Python 封裝標準的建置工具,因為核心開發團隊發現,提供始終可運作的標準工具是很重要的,即使它們是在舊版的 Python 上運作。</p>
<p>當今被推薦的建置及發布工具,可以透過在命令列中呼叫 <code class="docutils literal notranslate"><span class="pre">pip</span></code> 模組來安裝它們:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">setuptools</span> <span class="n">wheel</span> <span class="n">twine</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">備註</p>
<p>對於 POSIX 使用者(包括 Mac OS X 和 Linux 使用者),這些教學皆假設有使用 <a class="reference internal" href="../glossary.html#term-virtual-environment"><span class="xref std std-term">virtual environment</span></a>。</p>
<p>對於 Windows 使用者,這些教學皆假設在安裝 Python 時,「可調整系統 PATH 環境變數」的選項已被選取。</p>
</div>
<p>Python 封裝使用者指南包含了關於<a class="reference external" href="https://packaging.python.org/guides/tool-recommendations/#packaging-tool-recommendations">當今推薦工具</a>的更多細節。</p>
</section>
<section id="reading-the-python-packaging-user-guide">
<span id="publishing-python-packages"></span><span id="index-1"></span><h2>閱讀 Python 封裝使用者指南<a class="headerlink" href="#reading-the-python-packaging-user-guide" title="本標頭的永久連結">¶</a></h2>
<p>Python 封裝使用者指南涵蓋了關於建立和發布一個專案的各項關鍵步驟和元素:</p>
<ul class="simple">
<li><p><a class="reference external" href=" https://packaging.python.org/tutorials/packaging-projects/#packaging-python-projects">專案結構</a></p></li>
<li><p><a class="reference external" href=" https://packaging.python.org/tutorials/packaging-projects/#creating-the-package-files">專案建置與封裝</a></p></li>
<li><p><a class="reference external" href=" https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives">上傳專案至 Python 套件索引 (Python Package Index)</a></p></li>
<li><p><a class="reference external" href=" https://packaging.python.org/specifications/pypirc/">.pypirc 檔案</a></p></li>
</ul>
</section>
<section id="how-do-i">
<h2>我該如何...?<a class="headerlink" href="#how-do-i" title="本標頭的永久連結">¶</a></h2>
<p>接下來是關於一些常見任務的快速解答或連結。</p>
<section id="choose-a-name-for-my-project">
<h3>...為我的專案選擇一個名稱?<a class="headerlink" href="#choose-a-name-for-my-project" title="本標頭的永久連結">¶</a></h3>
<p>這不是一個簡單的題目,但這裡有一些提示:</p>
<ul class="simple">
<li><p>檢查 Python 套件索引,看看該名稱是否已被使用</p></li>
<li><p>檢查常用的代管網站,像是 GitHub、Bitbucket 等,看看是否已經有一個使用該名稱的專案</p></li>
<li><p>檢查您正在考慮的名稱在網路搜尋中會出現的內容</p></li>
<li><p>避免使用特別常見的單字,尤其是那些有多重含義的單字,因為它們會讓使用者在搜尋你的軟體時時很難找到它</p></li>
</ul>
</section>
<section id="create-and-distribute-binary-extensions">
<h3>...建立和發布二進制擴充?<a class="headerlink" href="#create-and-distribute-binary-extensions" title="本標頭的永久連結">¶</a></h3>
<p>實際上這是一個非常複雜的題目,因為有各式各樣的替代方案可使用,取決於您確實想要達成的目標。更多的資訊和建議,請參閱 Python 封裝使用者指南。</p>
<div class="admonition seealso">
<p class="admonition-title">也參考</p>
<p><a class="reference external" href="https://packaging.python.org/guides/packaging-binary-extensions/">Python 封裝使用者指南:二進制擴充</a></p>
</div>
</section>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="../contents.html">目錄</a></h3>
<ul>
<li><a class="reference internal" href="#">發布 Python 模組</a><ul>
<li><a class="reference internal" href="#key-terms">關鍵術語</a></li>
<li><a class="reference internal" href="#open-source-licensing-and-collaboration">開源授權與協同合作</a></li>
<li><a class="reference internal" href="#installing-the-tools">安裝工具</a></li>
<li><a class="reference internal" href="#reading-the-python-packaging-user-guide">閱讀 Python 封裝使用者指南</a></li>
<li><a class="reference internal" href="#how-do-i">我該如何...?</a><ul>
<li><a class="reference internal" href="#choose-a-name-for-my-project">...為我的專案選擇一個名稱?</a></li>
<li><a class="reference internal" href="#create-and-distribute-binary-extensions">...建立和發布二進制擴充?</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>上個主題</h4>
<p class="topless"><a href="../c-api/apiabiversion.html"
title="上一章">API 和 ABI 版本管理</a></p>
</div>
<div>
<h4>下個主題</h4>
<p class="topless"><a href="../installing/index.html"
title="下一章">安裝 Python 模組</a></p>
</div>
<div role="note" aria-label="source link">
<h3>此頁面</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">回報錯誤</a></li>
<li>
<a href="https://github.com/python/cpython/blob/3.11/Doc/distributing/index.rst"
rel="nofollow">顯示原始碼
</a>
</li>
</ul>
</div>
</div>
<div id="sidebarbutton" title="收合側邊欄">
<span>«</span>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>瀏覽</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="總索引"
>索引</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python 模組索引"
>模組</a> |</li>
<li class="right" >
<a href="../installing/index.html" title="安裝 Python 模組"
>下一頁</a> |</li>
<li class="right" >
<a href="../c-api/apiabiversion.html" title="API 和 ABI 版本管理"
>上一頁</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.11.1 Documentation</a> »
</li>
<li class="nav-item nav-item-this"><a href="">發布 Python 模組</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="快速搜尋" aria-label="快速搜尋" type="text" name="q" />
<input type="submit" value="前往" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
|
</li>
</ul>
</div>
<div class="footer">
© <a href="../copyright.html">版權</a> 2001-2023, Python Software Foundation.
<br />
This page is licensed under the Python Software Foundation License Version 2.
<br />
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
<br />
See <a href="/license.html">History and License</a> for more information.<br />
<br />
The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
<br />
最後更新於 1月 23, 2023。
<a href="/bugs.html">Found a bug</a>?
<br />
使用 <a href="https://www.sphinx-doc.org/">Sphinx</a> 6.1.3 建立。
</div>
</body>
</html>