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

后端 未结 1 1930
轻奢々
轻奢々 2020-12-04 06:49

I\'m writing a django application in my spare time for a footy-tipping competition we\'re running at work. I figured I\'d use this time wisely, and get up to speed on virtua

相关标签:
1条回答
  • 2020-12-04 07:32

    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

    0 讨论(0)
提交回复
热议问题