From 31d6e8a673a5e71a0c73236c03a048d35b378bc2 Mon Sep 17 00:00:00 2001 From: Mozillazg Date: Sat, 11 May 2013 08:35:52 +0800 Subject: [PATCH 1/2] Update program info. --- pyshanb/__init__.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/pyshanb/__init__.py b/pyshanb/__init__.py index e9a37b5..0d49706 100644 --- a/pyshanb/__init__.py +++ b/pyshanb/__init__.py @@ -5,5 +5,41 @@ PyShanb - 命令行下的扇贝词典 """ -__version_info__ = (0, 5, 1) -__version__ = filter(lambda n: isinstance(n, int), __version_info__) + +__title__ = 'pyshanb' +__version_info__ = (0, 5, 1, 'final', 0) +__author__ = 'mozillazg' +__license__ = 'MIT' +__copyright__ = 'Copyright 2013 mozillazg' + + +# modified from django(https://github.com/django/django/) +def get_version(version=None): + "Returns a PEP 386-compliant version number from VERSION." + if version is None: + version = __version_info__ + else: + assert len(version) == 5 + assert version[3] in ('alpha', 'beta', 'rc', 'final') + + # Now build the two parts of the version number: + # main = X.Y[.Z] + # sub = .devN - for pre-alpha releases + # | {a|b|c}N - for alpha, beta and rc releases + + parts = 2 if version[2] == 0 else 3 + main = '.'.join(str(x) for x in version[:parts]) + + sub = '' + if version[3] == 'alpha' and version[4] == 0: + git_changeset = get_git_changeset() + if git_changeset: + sub = '.dev%s' % git_changeset + + elif version[3] != 'final': + mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'} + sub = mapping[version[3]] + str(version[4]) + + return str(main + sub) + +__version__ = get_version(__version_info__) \ No newline at end of file From 6a01e35e58de31a9a07da3bdf29c08cd461e3a6e Mon Sep 17 00:00:00 2001 From: Mozillazg Date: Tue, 21 May 2013 13:59:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=88=B0=20PyPI.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ ChangeLog.md | 4 +++ MANIFEST.in | 1 + README.md | 10 +++++--- pyshanb/__init__.py | 2 +- pyshanb/__main__.py | 10 ++++++++ pyshanb/conf.py | 3 ++- setup.py | 62 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 MANIFEST.in create mode 100644 pyshanb/__main__.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 8f3df48..1bfe8ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.un~ *.swp *.pyc +dist +pyshanb.egg-info diff --git a/ChangeLog.md b/ChangeLog.md index 7fd7afa..a52e333 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # PyShanb changelog +## 2013-05-21 0.5.2 + +* 发布到 PyPI + ## 2013-03-16 0.5.1 * 新增加几个命令行参数([-i | -I] [-a | -A]) diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..1e58d68 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include README.md LICENSE.txt ChangeLog.md requirements.txt pyshanb/pyshanb.conf diff --git a/README.md b/README.md index f2f65af..898fb41 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # PyShanb:命令行下的扇贝词典 -基于 [扇贝网 API v0.8](http://www.shanbay.com/support/dev/api.html "扇贝网 API v0.8") 开发的一个命令行下的查词工具。支持将生词添加到扇贝网的个人词库中。 +基于 [扇贝网 API v0.8](http://www.shanbay.com/support/dev/api.html "扇贝网 API v0.8") 开发的一个命令行下的查词工具。 +支持将生词添加到扇贝网的个人词库中。 ## 功能 @@ -25,14 +26,15 @@ ## 安装使用 -1. 安装依赖模块:`pip install -r requirements.txt`; +1. `pip install pyshanb` 或 `git clone https://github.com/mozillazg/PyShanb` ; 2. 配置用户名及密码(通过配置文件(pyshanb.conf)或命令行参数(-u -p)); 3. 命令行下执行:`python pyshanb.py`(Tips:使用过程中输入 `q` 即可退出程序)。 +4. 或 `shanbay -u username -p password` ### 命令行参数 - >python pyshanb.py --help - Usage: pyshanb.py [-s SETTINGS] [-u USERNAME] [-p PASSWORD] + >shanbay --hlep + Usage: shanbay-script.py [-s SETTINGS] [-u USERNAME] [-p PASSWORD] [-e | -E] [-i | -I] [-a | -A] [--version] Options: diff --git a/pyshanb/__init__.py b/pyshanb/__init__.py index 0d49706..bd20e94 100644 --- a/pyshanb/__init__.py +++ b/pyshanb/__init__.py @@ -7,7 +7,7 @@ __title__ = 'pyshanb' -__version_info__ = (0, 5, 1, 'final', 0) +__version_info__ = (0, 5, 2, 'final', 0) __author__ = 'mozillazg' __license__ = 'MIT' __copyright__ = 'Copyright 2013 mozillazg' diff --git a/pyshanb/__main__.py b/pyshanb/__main__.py new file mode 100644 index 0000000..7415345 --- /dev/null +++ b/pyshanb/__main__.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +"""The main entry point. Invoke as `shanbay' or `python -m pyshanb'. + +""" +import sys +from .pyshanb import main + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/pyshanb/conf.py b/pyshanb/conf.py index ed26fef..93570a0 100644 --- a/pyshanb/conf.py +++ b/pyshanb/conf.py @@ -74,7 +74,8 @@ def get_settings(self, has_username=False, has_password=False): and (self.password or has_password)): a = u'Please configure your username and/or password,\n' b = 'or command line option, like below:\n' - b += ' pyshanb.py -u root -p abc' + b += ' shanbay -u username -p password\n' + b += ' python pyshanb.py -u username -p password\n' sys.exit(u'%sby editor config file:\n %s\n%s' % (a, os.path.realpath(CONFIGFILE), b)) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..2b49cce --- /dev/null +++ b/setup.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys + +import pyshanb + +try: + from setuptools import setup +except ImportError: + from distutils.core import setup + +if sys.argv[-1] == 'publish': + os.system('python setup.py sdist upload') + sys.exit() + +requirements = [ + 'requests>=1.1.0' +] + +packages = [ + 'pyshanb', +] + +def long_description(): + md =open('README.md').read() + '\n\n' + open('ChangeLog.md').read() + return md + +setup( + name='pyshanb', + version=pyshanb.__version__, + description=pyshanb.__doc__.strip(), + long_description=long_description(), + url='https://github.com/mozillazg/PyShanb', + download_url='https://github.com/mozillazg/PyShanb', + author=pyshanb.__author__, + author_email='mozillazg101@gmail.com', + license=pyshanb.__license__, + packages=packages, + package_data={'': ['LICENSE.txt'], 'pyshanb': ['*.conf']}, + package_dir={'pyshanb': 'pyshanb'}, + include_package_data=True, + install_requires=requirements, + # setup_requires=['sphinx'], + zip_safe=False, + entry_points={ + 'console_scripts': [ + 'shanbay = pyshanb.__main__:main', + ], + }, + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'Intended Audience :: Education', + 'License :: OSI Approved :: MIT License', + ], +)