使用github+travis将Python包部署到Pypi
我在 github 托管 Python 代码,然后将包发布到 Pypi,通常的操作步骤是,更新完代码将提交到 github ,然后手动将包更新到 pypi,这样比较繁琐,就想到了使用github+travis-ci 构建一个自动部署环境。 注册 pypi 访问https://pypi.org 点击Register注册账号,记住自己的用户名密码。 创建 setup.py 文件 setup.py 文件放置于包的根目录,示例内容如下: #!/usr/bin/env python from setuptools import setup, find_packages with open("README.md", "r") as fh: long_description = fh.read() with open('requirements.txt') as f: requirements = [l for l in f.read().splitlines() if l] setup(name="python-weixin", # 项目名 version="0.3.2", # 版本号 description="Python Weixin API client support wechat-app", #简介 long_description=long_description, # 长简介 这里使用的 readme 内容 long_description_content_type="text/markdown", license="BSD", # 授权 install_requires=requirements, # 依赖 author="gusibi", # 作者 author_email="[email protected]", # 邮箱 url="https://github.com/gusibi/python-weixin", # 地址 download_url="https://github.com/gusibi/python-weixin/archive/master.zip", packages=find_packages(), keywords=["python-weixin", "weixin", "wechat", "sdk", "weapp", "wxapp"], zip_safe=True) 以上特别需要注意的是 packages参数,用来申明你的包里面要包含的目录,这里使用setuptools自动决定要包含哪些包。 ...