How do you distribute python apps

Follow by Email

Having created an exemplary application structure of a web site that uses flask, we can continue with taking the first step into preparing the distribution.

Altering the Folder Structure

In order to package our application well, we need to make some additions to our folder structure.

    |__ /app
         |-- /module_one
         |__ /templates
             |-- module_one
                 |-- hello.html
         |__ /static
         |__ ..
         |__ .
    |--    # Distribution setup file
    |-- README.txt  # Read-me file
    |-- # Distribution manifest file
    |-- CHANGES.txt # Changes log

Alter the folder structure to create necessary files:

touch ~/MyApplication/
touch ~/MyApplication/
touch ~/MyApplication/
touch ~/MyApplication/
mv    ~/MyApplication/ ~/MyApplication/bin/run

Create the

nano ~/MyApplication/

Place the below self explanatory contents:

from distutils.core import setup

    # Application name:

    # Version number (initial):

    # Application author details:
    author="name surname",
    author_email="[email protected]",

    # Packages

    # Include additional files into the package

    # Details

    # license="LICENSE.txt",
    description="Useful towel-related stuff.",

    # long_description=open("README.txt").read(),

    # Dependent packages (distributions)

Save and exit using CTRL+X and confirm with with Y.

Create the

If you need to ship extra directories (e.g. static or templates), you need to explicitly state them in the manifest to be packaged. We will do this inside the

nano ~/MyApplication/

Place the below self explanatory contents:

recursive-include app/templates *
recursive-include app/static *

Save and exit using CTRL+X and confirm with with Y.

And that’s it! Your Python distribution package is ready to be installed and shipped.

Additional Files

Please remember that in order to have a complete distribution, your file/directory must contain (and linked):

  • README.txt
  • LICENSE.txt

Working With the Distribution Ready Application

As we have finalized creation of our application followed by making necessary amendments to the file structure to prepare it for a flawless distribution build, we can begin with going through the packaging operations.

How to Create The Distribution File

In order to generate a distribution file copy, run the following:

cd     ~/MyApplication
python sdist

This command will go through your setup, print out the operations being performed and generate a tar archive inside the newly created dist directory, similar to:

# [email protected]:~/MyApplication# ls dist
# MyApplication-0.1.0.tar.gz

Note: Since we did not populate all the sub-folders (i.e. static) and worked with additional files (e.g. README.txt), you might see some warnings during the creation process.


Take your time to comment on this article.

Follow by Email


  1. Chubutin 2017-05-25 Reply
  2. MilTechCode 2017-07-10 Reply
  3. sandun 2017-09-01 Reply
  4. rayjay 2017-10-16 Reply
  5. Ra op 2017-12-13 Reply
  6. gmail login 2018-03-24 Reply
  7. Roll the ball 2018-05-08 Reply
  8. Chloe 2018-05-21 Reply
  9. Isla 2018-05-21 Reply
  10. Grace 2018-05-21 Reply
  11. Cara 2018-05-21 Reply

Add a Comment

Your email address will not be published. Required fields are marked *

Like the article? please consider sharing it. Thank you

Advertisment ad adsense adlogger