1) 制作
$ tree
$ eds
$ ├── edssdk
$ │ ├── help.py
$ │ └── __init__.py
$ └── setup.py
$ mkdir -p eds/edssdk
$ cd eds/edssdk
1.1) __init__.py
$ touch __init__.py
1.2) help.py 模块
$ cat help.py
#!/usr/bin/env python
def sum(*values):
s = 0
for v in values:
i = int(v)
s = s + i
print s
def output():
print 'http://jasonmun.blogspot.my'
1.3) setup.py
$ cat setup.py
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name = "edssdk",
version = "0.0.1",
keywords = ("pip", "datacanvas", "eds", "jason"),
description = "eds sdk",
long_description = "eds sdk for python",
license = "MIT Licence",
url = "http://jasonmun.blogspot.my",
author = "Jason Mun",
author_email = "jason@yahoo.com",
packages = find_packages(),
include_package_data = True,
platforms = "any",
install_requires = []
)
2) 打包
$ python setup.py bdist_egg # 生成类似 edssdk-0.0.1-py2.7.egg,支持 easy_install
$ python setup.py sdist # 生成类似 edssdk-0.0.1.tar.gz,支持 pip
3) 注册 PyPI 包 (注册户口, 以上传到 PyPI)
$ python setup.py register
$ python setup.py sdist upload
4) 测试
# easy_install 来自 setuptools (pip list | grep setuptools)
$ sudo easy_install edssdk-0.0.1-py2.7.egg
$ pip list | grep edssdk
$ python -c "from edssdk import help; help.sum(3,5);help.output();"
$ sudo easy_install -m edssdk
$ sudo pip install edssdk
$ pip list | grep edssdk
$ python -c "from edssdk import help; help.sum(3,5);help.output();"
$ sudo pip uninstall edssdk
没有评论:
发表评论