Creating your first pypi


To create your first pip installable package, create a folder and add the following files in there (alternative you can download from here)


.pypirc

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
repository=https://pypi.python.org/pypi
username=
password=

[pypitest]
repository=https://testpypi.python.org/pypi
username=
password=



Next create a file call setup.py which contains some basic information about your package


from distutils.core import setup
setup(
name = 'kepungmath',
packages = ['kepungmath'], # this must be the same as the name above
version = '0.1',
description = 'A random test lib',
author = 'Jeremy Woo',
author_email = 'kepung@gmail.com',
url = 'https://github.com/appcoreopc/kepungmath', # use the URL to the github repo
download_url = 'https://github.com/appcoreopc/kepungmath/archive/0.1.tar.gz', # I'll explain this in a second
keywords = ['testing', 'logging', 'example'], # arbitrary keywords
classifiers = [],
)


Create another file call setup.cfg 

[metadata]
description-file = README.md


Please ensure you have create a file called .pypirc in your HOME directory. Yes, not package directory but come directory. 

You are ready to push to the Test repository with the following command 


python setup.py register -r pypitest

python setup.py sdist upload -r pypitest


You are ready to push to the Production repository with the following command 


python setup.py register -r pypi

python setup.py sdist upload -r pypi


Try to download it by issuing 


pip install kepungmath

Comments

Popular posts from this blog

ionic2 cordova build android - Unable resolve gradle 2.2.3

OpenCover code coverage for .Net Core

Using Custom DLL with IronPython / Scripts