python打包上传至pypi —— 具有多个目录的项目工程快速打包上传
生活随笔
收集整理的這篇文章主要介紹了
python打包上传至pypi —— 具有多个目录的项目工程快速打包上传
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
項目目錄
項目目錄說明:
1. 項目包
由于項目需要調用 app、view 目錄下的腳本,故相當于將 app、view 視作了模塊,這兩個目錄中均存在 __init __.py 文件。
而項目 —— cqrcode 中所含有的 __init __.py 腳本不能省略(原因是需要作為模塊標示),如下圖所示:
2. LINCENSE
拷貝復制即可?
Copyright (c) 2018 The Python Packaging Authority Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.3. MANIFEST.in
說明需要額外打包的目錄。
include README.md include LICENSE include requirements.txt recursive-include cqrcode/app * recursive-include cqrcode/static * recursive-include cqrcode/view *4. README.md
5. requirements.txt
Pillow>=6.1.0 pyzbar>=0.1.8 qrcode>=6.1 PySnooper>=0.2.8 pretty-errors>=1.2.7 matplotlib>=3.0.36. setup.py
import setuptoolssetuptools.setup(name='cqrcode',version='0.14',description='Generate a QR code that can adapt to the cylinder',long_description=open('README.md', 'r', encoding='utf-8').read(),author='xxx',author_email='xxx@qq.com',url = 'https://pypi.org/project/cqrcode/',license='MIT', # 與之前你選用的許可證類型有關系packages=setuptools.find_packages(),zip_safe=False,include_package_data=True,install_requires = ['Pillow>=6.1.0','pyzbar>=0.1.8','qrcode>=6.1','PySnooper>=0.2.8','pretty-errors>=1.2.7','matplotlib>=3.0.3',],keywords='cylinder qrcode',classifiers=["Natural Language :: Chinese (Simplified)","Development Status :: 3 - Alpha","Operating System :: OS Independent","Programming Language :: Python","Programming Language :: Python :: 3.4","Programming Language :: Python :: 3.5","Programming Language :: Python :: 3.6","Programming Language :: Python :: 3.7","License :: OSI Approved :: MIT License","Topic :: Utilities"], )7. 準備twine配置文件
該目錄下:
新建該腳本:
內容為:
至此,準備完畢。
準備上傳
三條命令:
python setup.py check python setup.py sdist bdist_wheel twine upload dist/*具體演示
準備打包,在該目錄下,shift+右鍵 打開 Powershell。
運行命令 python setup.py check ,檢查 setup.py 運行結果為 running check 則正確。
運行命令 python setup.py sdist bdist_wheel
生成一堆文件:
檢查 dist 目錄,會產生兩個文件
運行命令 twine upload dist/* 上傳。
上傳成功。
下載安裝演示
總結
以上是生活随笔為你收集整理的python打包上传至pypi —— 具有多个目录的项目工程快速打包上传的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html 实现 平方展示
- 下一篇: Kubectl基本操作命令