打包Python项目并发布到Pypi上

项目结构

├── MANIFEST.in
├── README.rst
├── check
│   ├── __init__.py
│   └── check.py
└── setup.py

__init__.py

from check import sec
__all__ = [sec, ]

MANIFEST.in

include *.py
include README.rst

打包列出的所有文件

setup.py

pip3 install setuptools 安装相关工具。

from setuptools import find_packages,setup

setup(name = 'check',
  version = '0.0.1',
  description = 'check sec',
  long_description = 'Sec check ..',
  platforms = ["linux"],
  author = "admin",
  author_email = [email protected]',
  url = 'https://ysicing.blog',
  license = 'MIT',
  packages = find_packages()
  )

使用

python3 setup.py sdist 执行完会生成一个压缩包。 python3 setup.py install 安装。

上传

testpypi 和 pypi 账号不互通 Pypi

*****
Written by ysicing on 16 July 2017