(i) preparatory work
- 1. Create a new module (name customization) that holds the module code to be published.
- 2. Create a new setup.py module (storing the metadata of the module, describing the relevant information).
- 3. Create a new folder (the name matches the name of the module you want to publish), and then put the above 2 modules in a folder.
For example, I create a module disposelist.py that processes list data, and the code is as follows:
# Create a function to process the list
def Print_li (the_list):
for UE in The_list:
# determine if the data type is a list
if isinstance (UE, list):
PRINT_LI (UE)
Else:
PRINT (UE)
Create a setup.py module with the following code:
Setup
# Import the Setup function from the Python publishing tool
Setup
' Disposelist ',
' 1.0.0 ',
# Correlation Module
Py_modules =[' disposelist '],
' Lqh ',
author_email=' [email protected] ',
Url=' 1 ',
' Process List Data '
)
Create a folder Disposelist, copy the above 2 modules to the folder, OK, the pre-work is complete.
(ii) CMD Input in python setup.py sdist Publish the module (instead of opening the command window directly under the folder, add setup.py 's path). After the publication is successful, you can share your modules with others.
(iii) CMD input sudo python setup.py install Install the module to Python in the local copy ( .. \python36\lib\site-packages, add to this directory).
can be used after successful installation Import Import
Cannot import, as shown, replace the Python.exe with your own installation directory.
Python notes (iii): Building a publishing module