How python creates custom packages and distributes them

To create your own Python package and distribute it via PyPI, you can do so by following these steps:

  1. Create a project directory structure
    Create a new folder in any directory as the project folder. Create the following subfolders and files under this folder:
my_package/
    my_package/
        __init__.py
    setup.py
    README.md
    LICENSE.txt

Among them, the my_package folder is the directory where the code of the Python package is located, setup.py is the packaging and installation script of the Python package, README.md is the documentation of the project, and LICENSE.txt is the license file of the project.

  1. Write code
    Write Python code under the my_package/my_package folder, for example:
def hello():
    print("Hello, world!")

and import the function in the init.py file: <

Guess you like

Origin blog.csdn.net/zhangzhechun/article/details/131900477