Beginner Python releases its own modulesPython is an open source tool, so we can post our own written module on a problem to PyPI for download and use. This article is about how to publish your own module on the PyPI.
Step 1: First create a folder for the module you want to publish and copy the module file you want to publish into your new folder. For example, if you want to publish one of your files named mydist.py, then you can copy the file into the folder (the folder name is the same as your module name)
Step 2:: Create the setup.py file in the new folder creates a new Notepad, names it as setup, and modifies the suffix name to the py file. Open the file with idle and enter information about the module you want to publish in the file.
The names of these parameters are at a glance. After you set these parameters, you can save them.
Step 3: Build the publishing file under Windows operating system, enter CMD above your publishing folder, so you can go directly to the folder's terminal window without having to enter the terminal. Enter a publish file by entering the following code in the console. setup.py Sdist can be
Step 4: Install the release to your local copy normally, our modules are what we might need in the future, so we can save these useful modules to a local copy of Python to facilitate import later. setup.py install you'll find a few more folders and files in your new release file.
Step 5: Release your module on PyPI the same is the terminal to enter your folder, in the terminal input setup.py register recommends that you register your account on PyPI before you proceed with this procedure. Next, enter your account number and password according to the terminal's English prompts, and save your login information. Then continue to enter the setup.py sdist upload on the terminal can be released. The final terminal will prompt for a successful release.
Step 6: How to update your code assuming that you have fixed some bugs on your module or added some new features, you can update your module version directly. Open the setup.py file, set the version parameter to the modified edition, and then upload your new code block back to the terminal. setup.py sdist upload.
So you can share your own modules with the world's Python programmers.
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