开发者学堂课程【Python 脚本进阶:发布CLI】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/797
发布CLI
目录:
·发布到Pypi
一、为什么要将命令行工具发布至Pypi
●更容易被分发:使用时通过Pypi 安装即呵●无需关注执行环境:如果可以通过Pip安装。则说明相应环境已经齐备,无需在代码中检测
import . click
@click . command () def·hello(): ·click. echo("hello· world") if · _ name_·=·` __main` : ····hello() |
Import·setuptools setuptools.setup( ····name="pypicli" , ····version="0.0.1" ····author="bestony", ····description="pypi·cli . example", ····long_ description=" #pypicli"
····long_ description_ content_ _type= "text/markdown" ····packages=setuptools. find_ packages() , ····py_ modules= ["pypicli"], ····package_ dir=("":"src"], ····install_ requires= [ ········"Click” ·····] , ·····entry_ points={
’console_ scripts’:[ ‘pypix·=·cli:’ ] } } |
发布CLI之前去python注册账号