Detailed steps for installing modules and packages in Python learning notes

Source: Internet
Author: User

This article mainly introduces how to use distutils to package practical application solutions in Python learning notes. If you are interested in the practical operation steps of Python learning notes, if you have any questions, you can browse our articles.

You can use distutils to install the compiled python module or package to the python directory. Step: Prepare the modules and packages to be installed, and write setup. py, for example:

 
 
  1. #!/usr/bin/env python  
  2. from distutils.core import setup  
  3. setup (# Distribution meta-data  
  4. name = "testpackage",  
  5. version = "1.0",  
  6. description = "Distutils sample distribution testpackage",  
  7. #py_modules = [''],  
  8. packages = ['TestPackage'], 

You can add more parameters. If you want to add data files or documents, you can modify the parameters as follows:

 
 
  1. packages = ['TestPackage', 'TestPackage.doc'],   
  2. package_data = {  
  3. 'TestPackage.doc': ['doc*.txt', '*.ico']  
  4. }, 

It indicates the txt files starting with all doc FILES added to the doc directory, and all ico files. Note: When generating the source code installation package, create a MANIFEST. in file in the directory where setup. py is located. The content is the included path, for example:

 
 
  1. include TestPackage\doc\doc*.txt  
  2. include TestPackage\doc\*.ico 

The preceding section describes how to use distutils to package Python learning notes.

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.