[Django]-How do I package a python application to make it pip-installable?

90đź‘Ť

âś…

Yes, MANIFEST.in and setup.py should be sufficient.

This blog post really has some good information on this topic:
Packaging a Django reusable app

And here’s another good, detailed overview that helped me a lot:
Python Packaging User Guide

Especially the tips to get your static files (templates) included are important as this might not be obvious at first.

And yes, you can specify required packages in your setup.py which are automatically fetched when installing your app.

For example:

    install_requires = [
        'django-profiles',
        'django-uni-forms',
    ],

Obviously now we have two places where dependencies are defined, but that doesn’t necessarily mean that these information are duplicated: setup.py vs requirements.txt

With this setup your package should be installable via pip.


As Pierre noted in the comments, there’s now also a relevant section in Django’s official documentation: Packaging your app

And then there is this “completely incomplete” guide, which really gives a great overview over packaging and uploading a package to PyPI: Sharing Your Labor of Love: PyPI Quick And Dirty

👤arie

Leave a comment