Pypi practice
When you normally distribute Python package, you have to use PyPi(Python Package Index).
I mean when you install python package, you used to use pip install package name.
From now on, I will explain how to upload to pypi.org to manage python package.
Normally, before uploading PyPi, You have to sign up PyPi.
In my case, I used setuptools.
1
2
3
4
5
6
7
from setuptools import setup, find_package
setup(
name="your package name",
version="your package version number",
...
)
So you have to pass arguements to setup to Python package index.
If the arguements is set up, Let’s see Requirements for packageing and distributing
-
First, Make sure you have already fulfilled the requirements for installing packages.
-
Install “twine”:
pip install twine
You will need this to upload your project distribution to PyPI.
Then you have to select whether you want to distribute Source or just built package as wheel.
- Source Distributions
python setup.py sdist
- Wheels
python setup.py bdist_wheel
After making the distribuing files. enter the following:
twine upload dist/*
BUT, after you release your python package, you cannot fix it.
You have to be careful of uploading your package, check your package.
So before releasing on main PyPI repo, I recommend you to use PyPi test site
- Upload as follows:
twine upload –repository-url https://test.pypi.org/legacy/ dist/*
- install it
pip install –index-url https://test.pypi.org/simple/ your-package
But Ther are comfortable way to upload with $HOME/.pypirc
Create or modify $HOME/.pypirc with the following
When you are with $HOME/.pypirc and twine, type in like this:
twine upload –repository testpypi dist/*
OR
type in like this :
The following is in Makefile
If you want to see my sample code, visit my git repository