Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use distutils to package and install in Python

Shulou Source: shulou.com Published: 2022-06-02 23:33:27 10月31日 Update

This article will explain in detail how to use distutils packaging and installation in Python, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Using distutils, you can install written python modules or packages into the python directory. Step: prepare the modules and packages to install, and write setup.py, such as:

#! / 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 some data files or documents, you can modify the parameters as follows:

Packages = ['TestPackage',' TestPackage.doc'], package_data = {'TestPackage.doc': [' doc*.txt','* .ico']}

Represents all txt files at the beginning of doc and all ico files added to the doc directory. Note: when generating the source code installation package, create a MANIFEST.in file in the directory where setup.py is located, and the content is the included path, such as:

Include TestPackage\ doc\ doc*.txt include TestPackage\ doc\ * .ico on how to use distutils packaging installation in Python to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Files content more directories parameters articles modules knowledge articles good beginning location data documents steps source code quality path preparation reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MySQL Shulou Technology Shulou Information Shulou Tech Info