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)

The better way to work with pypi package is to use pypi. You can install twine using

pip install twine

.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 register sdist upload -r https://www.python.org/pypitest


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

twine upload --repository-url https://test.pypi.org/legacy/ dist/*

To push to Production repository use the following command

twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

python setup.py register -r pypi

python setup.py register sdist upload -r https://www.python.org/pypi


Try to download it by issuing 


pip install kepungmath

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm