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:
- #!/usr/bin/env python
- from distutils.core import setup
- setup (# Distribution meta-data
- name = "testpackage",
- version = "1.0",
- description = "Distutils sample distribution testpackage",
- #py_modules = [''],
- packages = ['TestPackage'],
You can add more parameters. If you want to add data files or documents, you can modify the parameters as follows:
- packages = ['TestPackage', 'TestPackage.doc'],
- package_data = {
- 'TestPackage.doc': ['doc*.txt', '*.ico']
- },
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:
- include TestPackage\doc\doc*.txt
- include TestPackage\doc\*.ico
The preceding section describes how to use distutils to package Python learning notes.