In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to release Python code to pip install", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to release Python code to pip install.
First of all, to put a Python package on pypi, you need a certain directory structure. first, we can create a directory. As a demonstration, I create a package here:
Mkdir shuaib_package
And then we go into this bag:
Cd shuaib_package/
Then we create a directory under this directory to store your code, and here we will call it xiaoshuaib:
Mkdir xiaoshuaib
Let's go to this directory:
Cd xiaoshuaib/
To create your code, for demonstration purposes, I'll create a xiaoshuaib.py:
Touch xiaoshuaib.py
Simply write an output method in this py:
Insert a word: those who want Python information can follow the editor, and in the background private message editor: "01" can be obtained.
In this xiaoshuaib directory, you must also create a _ _ init__.py to tell others what your module is:
Touch _ _ init__.py
Write down your name and import your code module in this _ _ init__.py:
Ok, at this point, your file directory looks like this:
Only these files are not enough. We have to create several more necessary files, namely setup.py, LICENSE and READEME.md. As for the use of creating these files, we will tell you in detail, don't talk so much nonsense, create them first and then say:
Cd shuaib_package/ touch setup.py touch LICENSE touch README.md
So by now, your file directory should look like this:
Next, I'll tell you what these documents are for.
1 、 setup.py
The main purpose of this file is to tell setuptools some information in our package, such as name, version number, author, mailbox and so on.
Let's edit some of this file:
There should be no need for me to say more about the corresponding meaning, just some of your module information, just fill in your own as I do.
2 、 README.md
Here you can further blow on your module. This file is also referenced in the setup file we wrote just now, mainly for fear that you will blow too much, so just use markdown to let you blow enough. Let's open this README file and blow it:
All right, that's all I need for a demonstration here.
3 、 LICENSE
In the open source world, LICENSE is essential, we can declare here: you want to free my code, right? Yes, but you have to sign it. You have to let people know that I did this. I don't want money, but you can't say you did it yourself, okay?
LICENSE has several different statements. I'll talk to you again when I have a chance. This time I'll use MIT's LICENSE. Let's edit the LICENSE we just created:
Well, now that the files we need are ready, we can send our stuff to generate distributable files, and before that we need to install and update the setuptools and wheel modules:
Python3-m pip install-user-upgrade setuptools wheel
After the installation is complete, you can generate it by executing the following command in the directory you just created:
Python3 setup.py sdist bdist_wheel
At this point, you will find that there will be an extra dist directory in your directory, which is exactly what pypi needs.
Everything is ready, all you need is the upload of tm, so you need to have a pypi account now, you can sign up for an account at the following link:
Https://pypi.org/account/register/
If you just want to try to make a fuss on your own, you can register a beta version here:
Https://test.pypi.org/account/register/
Anyway, you'll sign up for an account sooner or later, right? It is worth noting that you need to verify your email, which means that you are not a robot registered account:
So at this moment, you also have the files you need and the account number. All you really need to do this time is to upload. We need the twine module to upload. Install it first:
Python3-m pip install-user-upgrade twine
Once installed, trust me, it's not complicated at all. You can upload it with one command, enter your directory, and then execute the following command to upload the dist you just generated:
Twine upload dist/*
In this way, we will upload our module!
Search xiaoshuaib on the official website first:
Ha, ha. let's install a wave:
Pip install xiaoshuaib
Successfully installed, to use a wave of:
At this point, I believe you have a deeper understanding of "how to release Python code to pip install". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.