Python

How do you distribute python apps2 min read

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.




Alter the folder structure to create necessary files:

Create the setup.py

Place the below self explanatory contents:

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

Create the MANIFEST.in

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 MANIFEST.in.

Place the below self explanatory contents:

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
  • MANIFEST.in
  • 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:

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:

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.

Leave a Comment