{"id":42,"date":"2023-12-18T15:20:56","date_gmt":"2023-12-18T07:20:56","guid":{"rendered":"http:\/\/blog.thirdbody.cn\/?p=42"},"modified":"2023-12-18T15:20:56","modified_gmt":"2023-12-18T07:20:56","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e8%87%aa%e5%b7%b1%e7%9a%84python%e5%8c%85%e4%b8%8a%e4%bc%a0%e5%88%b0pypi","status":"publish","type":"post","link":"http:\/\/blog.thirdbody.cn\/index.php\/2023\/12\/18\/%e5%a6%82%e4%bd%95%e5%b0%86%e8%87%aa%e5%b7%b1%e7%9a%84python%e5%8c%85%e4%b8%8a%e4%bc%a0%e5%88%b0pypi\/","title":{"rendered":"\u5982\u4f55\u5c06\u81ea\u5df1\u7684Python\u5305\u4e0a\u4f20\u5230pypi"},"content":{"rendered":"<h2>\u5c06\u81ea\u5df1\u5f00\u53d1\u7684Python\u5305\u4e0a\u4f20\u5230Pypi<\/h2>\n<p>\u5982\u4f55\u5c06\u81ea\u5df1\u5f00\u53d1\u7684Python\u5305\u4e0a\u4f20\u5230Pypi\uff0c\u53ef\u4f9b\u4ed6\u4ebapip install\u5b89\u88c5\u5462\uff1f\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u6253\u5305Python\u5305\uff0c\u5e76\u4e14\u5c06\u5176\u4e0a\u4f20\u5230pypi\u3002<\/p>\n<h3>1. \u6ce8\u518cPypi\u8d26\u53f7<\/h3>\n<p><a href=\"https:\/\/pypi.org\/account\/register\/\">\u6ce8\u518c\u5730\u5740<\/a><\/p>\n<h3>2. Python\u5305\u76ee\u5f55\u7ed3\u6784<\/h3>\n<p><img decoding=\"async\" src=\"http:\/\/cdn.thirdbody.cn\/Python%E5%8C%85%E7%9B%AE%E5%BD%95.png\" alt=\"\" \/><br \/>\n\u5982\u56fe\u6240\u793a\uff0cfunction_tool_derrick\u4e3a\u5305\u7684\u4ee3\u7801\uff0c\u5916\u5c42\u518d\u5957\u4e00\u5c42\u76ee\u5f55\uff0c\u4e00\u822c\u4f7f\u7528\u76f8\u540c\u7684\u540d\u79f0(\u6211\u8fd9\u91cc\u7528\u4e86\u4e0d\u540c\u540d\u79f0)<\/p>\n<p>\u53e6\u5916\uff0c\u8fd8\u6709\u51e0\u4e2a\u91cd\u8981\u6587\u4ef6\uff0c\u4ee5\u4e0b\u91cd\u70b9\u4ecb\u7ecd<\/p>\n<h4>2.1 LICENSE<\/h4>\n<p>\u8bb8\u53ef\u8bc1\u6587\u4ef6\uff0c\u6211\u8fd9\u91cc\u7528\u7684\u662fMIT\u7684\u8bb8\u53ef\u8bc1\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\u76f4\u63a5\u5c06\u6587\u4ef6\u5185\u5bb9\u590d\u5236\u7c98\u8d34\u5373\u53ef\uff1a<\/p>\n<pre><code class=\"language-text\">MIT License\n\nCopyright (c) 2023 The Python Packaging Authority\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the &quot;Software&quot;), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.<\/code><\/pre>\n<h4>2.2 README.md\u6587\u4ef6<\/h4>\n<p>\u7c7b\u4f3c\u4e8egit\u7684README.md<\/p>\n<h4>2.3 setup.py\u6587\u4ef6<\/h4>\n<p>\u8fd9\u662f\u6700\u91cd\u8981\u7684\u4e00\u4e2a\u6587\u4ef6\uff0c\u914d\u7f6e\u5305\u5982\u4f55\u5b89\u88c5\uff1a<\/p>\n<pre><code class=\"language-python\">from __future__ import print_function\nfrom setuptools import setup, find_packages\n\nwith open(&quot;README.md&quot;, &quot;r&quot;, encoding=&#039;utf-8&#039;) as fh:\n    long_description = fh.read()\n\nsetup(\n    name=&quot;function_tool&quot;,\n    version=&#039;0.0.2&#039;,\n    author=&quot;DerrickChiu&quot;,\n    author_email=&quot;chiull@foxmail.com&quot;,\n    description=&quot;some usual tool with class&quot;,\n    long_description=long_description,\n    long_description_content_type=&quot;text\/markdown&quot;,\n    license=&quot;MIT&quot;,\n    url=&quot;https:\/\/gitee.com\/DerrickChiu\/function_tool.git&quot;,\n    packages=find_packages(),\n    install_requires=[\n\n        ],\n    classifiers=[\n        &quot;Topic :: Scientific\/Engineering&quot;,\n        &#039;Topic :: Scientific\/Engineering :: GIS&#039;,\n        &quot;Programming Language :: Python&quot;,\n        &quot;Programming Language :: Python :: 3&quot;,\n        &quot;Programming Language :: Python :: 3.6&quot;,\n        &quot;Programming Language :: Python :: 3.7&quot;,\n        &quot;Programming Language :: Python :: 3.8&quot;,\n        &quot;Programming Language :: Python :: 3.9&quot;,\n        &quot;Programming Language :: Python :: 3.10&quot;,\n        &quot;Programming Language :: Python :: 3.11&quot;,\n        &quot;Programming Language :: Python :: 3.12&quot;,\n        &#039;Programming Language :: Python :: Implementation :: CPython&#039;,\n    ],\n)<\/code><\/pre>\n<ul>\n<li>install_requires\u914d\u7f6e\u5305\u7684\u4f9d\u8d56<\/li>\n<li>classifiers\u914d\u7f6e\u5305\u6240\u5c5e\u7c7b\u522b\uff0c\u7c7b\u522b\u89c1\uff1a<a href=\"https:\/\/pypi.org\/classifiers\/\">Pypi\u7c7b\u522b<\/a><\/li>\n<\/ul>\n<h3>3. \u6784\u5efa<\/h3>\n<ol>\n<li>\u68c0\u67e5setup.py\u6587\u4ef6\u662f\u5426\u6709\u8bef\uff1a\n<pre><code class=\"language-shell\">python setup.py check<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/cdn.thirdbody.cn\/check_setup.png\" alt=\"\" \/><\/p>\n<\/li>\n<li>\u6784\u5efa\n<pre><code class=\"language-shell\">python setup.py sdist bdist_wheel<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/cdn.thirdbody.cn\/setup_py.png\" alt=\"\" \/><br \/>\n\u6784\u5efa\u5b8c\u6210\u540e\u5305\u76ee\u5f55\u7ed3\u6784\uff1a<br \/>\n<img decoding=\"async\" src=\"http:\/\/cdn.thirdbody.cn\/%E6%9E%84%E5%BB%BA%E5%90%8E%E5%8C%85%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84.png\" alt=\"\" \/><br \/>\n\u591a\u51fa<code>build<\/code>\u3001<code>dist<\/code>\u4ee5\u53ca<code>function_tool.egg-info<\/code>\u4e09\u4e2a\u76ee\u5f55\uff0c\u5176\u4e2d\uff0c\u6784\u5efa\u7684\u53ef\u5b89\u88c5\u5305\u5728dist\u76ee\u5f55\u4e0b<\/p>\n<\/li>\n<\/ol>\n<h3>4. \u4e0a\u4f20<\/h3>\n<p>\u901a\u8fc7twine\u5c06dist\u76ee\u5f55\u4e0b\u7684\u5305\u4e0a\u4f20\u5230Pypi\uff0c\u82e5\u6ca1\u6709twine\u5305\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<pre><code class=\"language-shell\">   pip install twine<\/code><\/pre>\n<p>\u4e0a\u4f20\uff1a<\/p>\n<pre><code class=\"language-shell\">python3 -m twine upload dist\/*<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/cdn.thirdbody.cn\/%E4%B8%8A%E4%BC%A0Pypi.png\" alt=\"\" \/><\/p>\n<p>\u4e0a\u4f20\u8fc7\u7a0b\u4e2d\u4f1a\u8981\u6c42\u8f93\u5165Pypi\u7684\u8d26\u53f7\u548c\u5bc6\u7801\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5728\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6<code>.pypirc<\/code>\u6765\u4fdd\u5b58\u8d26\u6237Pypi\u4fe1\u606f: <\/p>\n<pre><code class=\"language-text\">[distutils]\nindex-servers=pypi\n\n[pypi]\nrepository = https:\/\/upload.pypi.org\/legacy\/\nusername= Pypi\u8d26\u53f7\npassword= \u5bc6\u7801<\/code><\/pre>\n<p>\u6ce8\u610f\uff1aPypi\u6709\u4e24\u4e2a\u5e93\uff0c\u4e0a\u8ff0\u7684\u662f\u6b63\u5f0f\u7684\u5e93\uff0c\u662f\u53ef\u4ee5\u901a\u8fc7pip\u76f4\u63a5\u5b89\u88c5\u7684\uff0c\u8fd8\u6709\u4e00\u4e2atest\u5e93\uff0c\u4e0a\u4f20\u65f6\u4f7f\u7528\u547d\u4ee4<code>python3 -m twine upload --repository testpypi dist\/*<\/code>\uff0c\u5728\u4f7f\u7528pip\u5b89\u88c5\u65f6\u9700\u8981\u5236\u5b9atest\u7684\u5730\u5740\uff1a<a href=\"https:\/\/test.pypi.org\/simple\/\">Pypi\u6d4b\u8bd5\u73af\u5883\u5305\u5730\u5740<\/a>\u3002\u6b64\u5916\uff0c\u5982\u679c\u4f7f\u7528\u7684\u56fd\u5185pip\u6e90\uff0c\u5219\u9700\u8981\u5f85\u5176\u66f4\u65b0\u540e\u624d\u80fd\u627e\u5230\u5305(\u6e05\u534e\u6e90\u662f\u6ca15\u5206\u949f\u4ecePypi\u5b98\u7f51\u4e0a\u66f4\u65b0\u4e00\u6b21)\u3002<\/p>\n<p>\u6700\u540e\uff0c\u53ef\u4ee5\u5728<a href=\"https:\/\/pypistats.org\/\">Pypi\u5305\u4e0b\u8f7d\u7edf\u8ba1\u7f51\u7ad9<\/a>\u4e0a\u67e5\u770b\u81ea\u5df1\u5305\u7684\u4e0b\u8f7d\u60c5\u51b5\u3002<\/p>\n<h3>5. \u53c2\u8003\u535a\u5ba2\uff1a<\/h3>\n<ul>\n<li><a href=\"https:\/\/blog.csdn.net\/yifengchaoran\/article\/details\/113447773\">\u535a\u5ba2<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/MemoryD\/article\/details\/84295855\">\u535a\u5ba2<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06\u81ea\u5df1\u5f00\u53d1\u7684Python\u5305\u4e0a\u4f20\u5230Pypi \u5982\u4f55\u5c06\u81ea\u5df1\u5f00\u53d1\u7684Python\u5305\u4e0a\u4f20\u5230Pypi\uff0c\u53ef\u4f9b\u4ed6\u4ebapip ins [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":43,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[18,16,17],"class_list":["post-42","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-pip","tag-pypi","tag-17"],"_links":{"self":[{"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":1,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":44,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/posts\/42\/revisions\/44"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/media\/43"}],"wp:attachment":[{"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}