Release a Python Package

Release a Python Package

Prepare the distribution

1. Setting up the package directory

  • Make a new directory with any name you like
  • Copy your Python source into a subfolder
  • Add four empty files
    • README
    • LICENSE.txt

2. Writing

from distutils.core import setup 

with open('README') as file: 
	readme = 
	name = 'some_unique_name', 
	version = '2.0.0', 
	packages = ['sourcefoldername'],
	license = 'LICENSE.txt', 
	description = 'my fantasy package', 
	author_email='my_email' )

3. Updating the README and LICENSE.txt files

Note that the new lines before each heading and the one after the keyword .. code:: python are important

Attack of the Orcs

This is a command line fantasy war game!

Documentation can be found at...

Example Usage
Here is an example to import the modules from this package.

.. code:: python
from wargame.attackoftheorcs import AttackOfTheOrcs
game = AttackOfTheOrcs()

See LICENSE.txt file.


Step 4 – Updating the files

include *.txt


Step 5- Build a deployment-ready distribution

$ cd <project_folder>
$ python sdist

The sdist command creates a distribution with the source files included. Running the second command creates a new dist directory containing an archive file. For example, in, if the name field is testgamepkg and the version is 2.0.0, the archive will be testgamepkg-2.0.0.tar.gz on Linux and on Windows OS



Uploading the distribution

1. Creating an account on PyPl test website

2. Creating a .pypirc file


repository =
username=<add username>
password=<add password>

3. Register your project

$ cd /path/to/testgamepkg
$ python register -r pypitest

Use other profile in .pypirc

$ python register -r

4. Uploading the package

$ python sdist upload -r pypitest


Installing your own distribution

$ pip install -i testgamepkg

Packaging and uploading the new version

$ python sdist upload -r pypitest