# python-lib-hello-world **Repository Path**: wangwuhao/python-lib-hello-world ## Basic Information - **Project Name**: python-lib-hello-world - **Description**: 创建并发布自己的python库到PyPI网站 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-12 - **Last Updated**: 2021-06-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Hello World This is an example project demostrating how to publish module to PyPI ## File TEMPLATE Ignore file suggest websiet: https://gitignore.io/ LICENSE file suggest websiet: https://choosealicense.com/ ## local env for install and debug Run the following to install: ```python cd project_diretory pip install -e . # create link to src code dir # or python setup.py develop # create link to src code dir pip list | grep helloworld ``` general install ```python python setup.py install # 直接复制本地为文件安装 ``` ## Check Mainfest ```python pip install check-manifest check-manifest --create # 创建清单文件 git add MIANGEST.in ``` ## Build source distribution ```python python setup.py sdist # or specify compress format python setup.py sdist --formats=gztar,zip # or specify owner python setup.py sdist --owner=root --group=root ``` binary distribution ```python python setup.py bdist_wheel # or for multi platform python setup.py bdist # for windows python setup.py bdist_wininst # for linux rpm # python setup.py bdist_rpm # for pip python setup.py bdist_egg ``` source and binary distribution ``` python setup.py bdist_wheel sdist ls dist/ helloworld-0.0.1.tar.gz helloworld-0.0.1-py3-none-any.whl ``` ## Push to PyPI register a account: https://pypi.org/ install `twine` for upload to test repository ``` pip install twine twine check dist/* # 检查 Checking dist/helloworld_kinghao-0.0.1-py3-none-any.whl: PASSED Checking dist/helloworld-kinghao-0.0.1.tar.gz: PASSED # markdown format error, upgrade libs # pip install -U twine wheel setuptools # rm -rf dist/ # python setup.py bdist_wheel sdist $ twine upload --repository testpypi dist/* Uploading distributions to https://test.pypi.org/legacy/ Enter your username: kinghao Enter your password: Uploading helloworld_kinghao-0.0.1-py3-none-any.whl 100%|█████████████████████████████████████████████████████████████████████████████| 5.84k/5.84k [00:02<00:00, 2.60kB/s] Uploading helloworld-kinghao-0.0.1.tar.gz 100%|█████████████████████████████████████████████████████████████████████████████| 5.60k/5.60k [00:02<00:00, 2.60kB/s] View at: https://test.pypi.org/project/helloworld-kinghao/0.0.1/ ``` another register and upload ``` python setup.py register # 注册 python setup.py upload # 上传 ``` 参考: https://zhuanlan.zhihu.com/p/276461821 `HTTPError: 400 Client Error: The description failed to render in the default format of reStructuredText` 原因分析: https://github.com/pypa/warehouse/issues/5890, 升级软件包 ## Installation from PYPI Run the following to install: ```python pip install helloworld-kinghao ```