The approximate directory structure of the project, where bword/bword.py is your code file, __init__.py file declares that this directory is a module, you can write nothing in it, you can write some code. If you don't understand, you can refer to: Https://github.com/ZhangHang-z/bword directory structure
The root of the project is to have a setup.py file, which can also be used to install your module using the Python setup.py install, very familiar with it. Configuration details in the directory:
From Setuptools Import setup, find_packages
setup (
name= ' Bword ', #名称
version= ' 0.10 ', #版本
description= "a console translation dictionary used dict.baidu.com Api", #描述
keywords= ' python 中文版 translation Dictionary terminal ',
author= ' Zhanghang ', #作者
author_email= ' stevezhang@gmail.com ', #作者邮箱
url= ' Https://github.com/zhanghang-z ', #作者链接
packages=find_packages (exclude=[' ez_setup ', ' examples ', ' tests ']),
include_package_data=true,
zip_safe=false,
install_requires=[ #需求的第三方模块
' requests ',
],
entry_points={
' console_scripts ': [ #如果你想要以Linux命令的形式使用
' bword = Bword.bword:main '
]
},
)
Go to PyPI to sign up for an account https://pypi.python.org/pypi?%3Aaction=register_form to create a hidden file named. Pypirc under your user's home directory, and fill in your account password:
[Server-login]
Username =
Password =
$ python setup.py check # check setup.py syntax is incorrect
Correct will output running check
$ python setup.py sdist
Some files, including. tar.gz files, are exported
$ python setup.py Register sdist upload
Upload to PyPI
If you modify the code later to update the PyPI, you need to modify the version number in the setup.py.