Python project package and release, python project package

Source: Internet
Author: User

Python project package and release, python project package
1. setuptools

-Official Document: Building and Distributing Packages with Setuptools
-Chinese document: Python package management tool setuptools

 

1. Use Process

Edit: Edit setup in the main directory of the project. py, package: python setup. install py sdist: sudo python setup. py install (-- record files.txt) uninstall: sudo cat files.txt | sudo xargs rm-rf

 

2. setuptools setup. py Template

from setuptools import setup, find_packagessetup(    name="HelloWorld",    version="0.1",    packages=find_packages(),    scripts=['say_hello.py'],    # Project uses reStructuredText, so ensure that the docutils get    # installed or upgraded on the target machine    install_requires=['docutils>=0.3'],    package_data={        # If any package contains *.txt or *.rst files, include them:        '': ['*.txt', '*.rst'],        # And include any *.msg files found in the 'hello' package, too:        'hello': ['*.msg'],    },    # metadata for upload to PyPI    author="Me",    author_email="me@example.com",    description="This is an Example Package",    license="PSF",    keywords="hello world example examples",    url="http://example.com/HelloWorld/",   # project home page, if any    # could also include long_description, download_url, classifiers, etc.)

 

Ii. Comparison of common methods for packaging, publishing, and deploying Python Projects

1. distutils-the basic Installation tool that comes with python. It is suitable for very simple application scenarios. It does not support dependency package installation through distutils, generating installation packages, installing python packages, and so on, you need to write the name setup. py python script file. 2. setuptools-extensive extensions for distutils, especially the package dependency mechanism. Python3 is not supported. After setuptools is installed, easy_install3. distribute-similar to setuptools, python3 is supported, and easy_install is installed after distribute is installed. 4. easy_install-setuptools and the installation script that comes with distribute, that is, once setuptools or distribute is installed, easy_install is available. 5. pip-the target is to replace easy_install. Easy_install has many disadvantages: Installation transactions are non-atomic operations, only svn is supported, and uninstallation commands are not provided. scripts are required to install a series of packages. pip solves the above problems, virtualenv has become a good partner with it. 6. the birth of distutils2-setuptools and distrils is due to the defect of distutils, which leads to current differentiation. It will become the standard library packaging of Python 3.3 and appear as distutils2 in other versions; in other words, it and pip will join hands to end the current chaos. 7. virtualenv: used to create an isolated python environment and process multiple versions of the python environment and module dependencies.

 

Common sense
1. The sudo apt-get install package is stored in the/usr/lib/python2.7/dist-packages directory.
2. pip or easy_install packages are stored in the/usr/local/lib/python2.7/dist-packages directory.
3. Manually store the package installed from the source code in the site-packages directory.

 

Refer:

Python project package release Summary

 

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.