日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python打包上传至pypi —— 具有多个目录的项目工程快速打包上传

發(fā)布時間:2024/1/18 python 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python打包上传至pypi —— 具有多个目录的项目工程快速打包上传 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

項目目錄



項目目錄說明:

  • cqrcode:項目包(我的里面有多個目錄)
  • LINCENSE:許可證
  • MANIFEST.in:需要打包的項目文件說明
  • README.md:項目說明文檔
  • requirements.txt:填寫需要額外安裝的第三方庫文件
  • setup.py:打包上傳所需的必要文件

  • 1. 項目包

    由于項目需要調(diào)用 app、view 目錄下的腳本,故相當于將 app、view 視作了模塊,這兩個目錄中均存在 __init __.py 文件。
    而項目 —— cqrcode 中所含有的 __init __.py 腳本不能省略(原因是需要作為模塊標示),如下圖所示:

    2. LINCENSE

    拷貝復(fù)制即可?

    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.3

    6. 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', # 與之前你選用的許可證類型有關(guān)系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配置文件

    該目錄下:

    新建該腳本:

    內(nèi)容為:

    [distutils] index-servers=pypi[pypi] repository = https://upload.pypi.org/legacy/ username: pypi 賬戶名 password: pypi 賬戶密碼

    至此,準備完畢。


    準備上傳

    三條命令:

    python setup.py check python setup.py sdist bdist_wheel twine upload dist/*

    具體演示

  • 先卸載已安裝的 cqrcode
  • C:\Users\83735>pip uninstall cqrcode Found existing installation: cqrcode 0.13 Uninstalling cqrcode-0.13:Would remove:d:\python35\lib\site-packages\cqrcode-0.13.dist-info\*d:\python35\lib\site-packages\cqrcode\*Would not remove (might be manually added):d:\python35\lib\site-packages\cqrcode\static\0二維碼填充效果.pngd:\python35\lib\site-packages\cqrcode\static\0二維碼識別掩碼.pngd:\python35\lib\site-packages\cqrcode\static\0二維碼識別模板.pngd:\python35\lib\site-packages\cqrcode\static\0填充結(jié)果.pngd:\python35\lib\site-packages\cqrcode\static\0擴展圖片.pngd:\python35\lib\site-packages\cqrcode\static\_input.txtd:\python35\lib\site-packages\cqrcode\static\_白板.pngd:\python35\lib\site-packages\cqrcode\static\overall_.pngd:\python35\lib\site-packages\cqrcode\static\傳統(tǒng)二維碼.png Proceed (y/n)? ySuccessfully uninstalled cqrcode-0.13
  • 準備打包,在該目錄下,shift+右鍵 打開 Powershell。

  • 運行命令 python setup.py check ,檢查 setup.py 運行結(jié)果為 running check 則正確。

  • 運行命令 python setup.py sdist bdist_wheel

    生成一堆文件:

  • 檢查 dist 目錄,會產(chǎn)生兩個文件

  • 運行命令 twine upload dist/* 上傳。

    上傳成功。

  • 下載安裝演示

  • 總結(jié)

    以上是生活随笔為你收集整理的python打包上传至pypi —— 具有多个目录的项目工程快速打包上传的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。