Python如何將模塊打包并發(fā)布
想要把自己開發(fā)的庫分享給別人使用, 使用 pip install 命令來安裝 , 需要學習如何制作一個python 安裝包
一、注冊pypi賬號
https://pypi.org/account/register/
二、創(chuàng)建setup.py和pypirc文件
setup.py模板(該文件放在項目根目錄下)
from os.path import abspath, dirname, join from setuptools import setup, find_packages # 獲取requirements.txt里的依賴信息 install_reqs = [req.strip() for req in open(abspath(join(dirname(__file__), ’requirements.txt’)))] with open('README.md', ’r’, encoding='utf-8') as f: long_description = f.read() setup( name=’模塊名’, version=’0.0.1’, packages=find_packages(), url=’網址’, license=’協議’, author=’作者姓名’, author_email=’作者郵箱’, description=’描述信息’, long_description=long_description, long_description_content_type='text/markdown', install_requires=install_reqs, )
pypirc模板 (該文件放在家目錄內)
這個文件用來存儲剛才注冊pypi賬號信息
[distutils] index-servers=pypi [pypi] repository = https://upload.pypi.org/legacy/ username = 剛才注冊的用戶名 password = 剛才注冊的密碼
三、安裝依賴
pip install --upgrade pip twine wheel setuptools
四、打包
python setup.py sdist bdist_wheel
打包之后 會在項目的dist目錄內生成whl文件
五、將whl文件上傳到pypi服務器
twine upload dist/*
以上就是Python如何將模塊打包并發(fā)布的詳細內容,更多關于python 模塊打包發(fā)布的資料請關注好吧啦網其它相關文章!
相關文章:
1. vue實現web在線聊天功能2. 完美解決vue 中多個echarts圖表自適應的問題3. JavaScript實現頁面動態(tài)驗證碼的實現示例4. 解決Android Studio 格式化 Format代碼快捷鍵問題5. JavaEE SpringMyBatis是什么? 它和Hibernate的區(qū)別及如何配置MyBatis6. Java使用Tesseract-Ocr識別數字7. Python使用urlretrieve實現直接遠程下載圖片的示例代碼8. 在Chrome DevTools中調試JavaScript的實現9. Springboot 全局日期格式化處理的實現10. SpringBoot+TestNG單元測試的實現
