pip is a software package management system written in the Python computer programming language. It can install and manage software packages, with a simple command “pip”, you can get access to more then one hundred thousand of cool libraries, here I am going to show you how to upload your own code to PyPi and able to download with pip.

There are few step for you to develop your own package.
- Prepare your code.
- Create a PyPi account.
- Prepare the files PyPi needs.
- upload it to PyPi
- pip install your package.
- Upload it to github
Code
In here, I want to upload the class I wrote for research in the institute, If you are interested, It is a code for calculate the limit of TASEH(Taiwan Axion Search Experiment Haloscope).
https://github.com/OuYangMinOa/ou_Axion_limit
This code have two class in two different File

- class Glimit in GLimit.py
- class analyse in Analy.py
PyPi account
Create a PyPi account for us to upload our package,
https://pypi.org/account/register/
Prepare the files PyPi needs.
Now, I wish my classes are all in a same package call ou_Axion_limit
# my expectation
from ou_Axion_limit import Glimit
from ou_Axion_limit import analyse
so first create a folder (Glimit), this folder will content every thing PyPi needs, and next create a floder name with your package name (ou_Axion_limit ), inside the folder you just created, and throw you python code inside.

__init__.py
Creata a file __init__.py inside the ou_Axion_limit
This file allows you to determine the classes that users can directly call and use, so in my cases, I can just import my class with following way.
# my expectation
from ou_Axion_limit import Glimit
from ou_Axion_limit import analyse
setup.py
The setup.py file contains the information that PyPi needed , such as its name, description, current version, etc. Copy and paste the following code and replace the string with the matching content:
CHANGELOG.txt
The changelog of you package
LICENSE.txt
Use this file to define all license details, you can use your own license, however, I will use MIT license
MANIFEST.in
Just a file use to include everything
README.md
A markdown file can make people understand your package better.
Upload it to PyPi
Everything is prepared, we can now upload it to PyPi.
First, goto you folder open cmd and tpye:
python setup.py sdist

If you see UserWarning: Unknown distribution option: ‘install_requires’, just ignore it.
It should create a file in dist folder

Next, we need twine for upload the package
pip install twine
Then, run the following command:
twine upload dist/{Generated_file}
You will be asked to provide your username and password. Provide your credentials you used to register with PyPi.

Congratulations, you successfully upload your packge to the PyPi, goto the website it gives you to see your package online.
Install your package
pip install YOURPACKAGENAME

Upload to github
For the fist time using git, we need to create a ssh-key to connect to github
ssh-keygen

It did exist.

Show the content
type filename

Copy everything and add in to your account.
Create your repository


Then upload your project.
git init
git add .
git commit -n "first upload"
git remote add origin git@github:{name/project}
git push -u origin master
If you want to upload new code later, you only need to type the following commands.
git add .
git commit -m "v1.0.0"
git push
