Publish Python code to PyPI so others can be installed with PIP __python

Source: Internet
Author: User


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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.