What is PyPi?
PyPI — the Python Package Index The Python Package Index is a repository of software for the Python programming language.
IF you are written something cool or simple app , and want to share it with other such a way that it can be easily installed by them. Then put your code in PyPi and then they can install you package simply by
pip install your-package
Create Accounts :
- Register at PyPI Live and also PyPI Test.
- It will be easier if you use same credentials for both account.
- If you have registered via OpenId or Google , remember to set the password after registration from the profile.
Create .pypirc config File
- Create a
.pypircfile in you home folder.
- Put bellow content on it,
- Replace your_username and your_password with your pypi username and password.
Prepare Your Package
app-root setup.py setup.cfg LICENSE.txt README.md docs tests CONTRIBUTORS .gitignore your_pacakge/ __init__.py model.py lib.py ...
Now here is detail point of what you need,
- Your package source will be on your_package directory.
- docs folder will contain the documenation soruce for your package. You can make documentation with SPHINX and host it one READTHEDOCS
- tests will contain the tests for your application
- README.md will contain the repository description in MARKDOWN format.
setup.py will contain the following settings,
Add a .gitignore file with following contents
*.pyc .DS_Store *.egg *.egg-info dist /.idea _build
Create a git tag
git tag 0.1 -m "tags for first release" git push --tags origin master
This will give you the download_url in setup.py. Format is
setup.cfg will contain the location of README file,
[metadata] description-file = README.md
Upload Your Package/ Release an update
python setup.py register -r pypitest python setup.py sdist upload -r pypitest
python setup.py register -r pypi python setup.py sdist upload -r pypi
- After uploading to test verify the content before uploading to live. You have to increase the version number each time you upload your package to PyPI.