Create your accounts
PyPI Live
PyPI Test
Create a .pypirc
configuration file
[distutils] # this tells distutils what package indexes you can push toindex-servers =PyPI # the live PyPIPyPI-test # test PyPI[PyPI] # authentication details for live PyPIrepository: https://PyPI.python.org/PyPIusername: {{your_username}}password: {{your_password}}[PyPI-test] # authentication details for test PyPIrepository: https://testPyPI.python.org/PyPIusername: {{your_username}}
Prepare your package
root-dir/ # arbitrary working directory namesetup.pysetup.cfgLICENSE.txtREADME.mdmypackage/__init__.pyfoo.pybar.pybaz.py
setup.py
from distutils.core import setupsetup(name = 'mypackage',packages = ['mypackage'], # this must be the same as the name aboveversion = '0.1',description = 'A random test lib',author = 'Ajay',author_email = 'aj@gmail.com',url = 'https://github.com/ajkumar25/mypackage', # use the URL to the github repodownload_url = 'https://github.com/ajkumar25/mypackage/tarball/0.1', # I'll explain this in a secondkeywords = ['testing', 'logging', 'example'], # arbitrary keywordsclassifiers = [],)
setup.cfg
[metadata]description-file = README.md
Register your package
$ python setup.py register -r PyPI-test
Upload your package
Upload to PyPI Test
$ python setup.py sdist upload -r PyPI-test
Upload to PyPI Live
$ python setup.py register -r PyPI
$ python setup.py sdist upload -r PyPI
References :
How to Create a Python Library | Pypix
沒有留言:
張貼留言