Packaging Stand-Alone Django Apps
Directory structure
The app goes in a directory outside of any Django web project. If the app is addresses, structure it littled-addresses/addresses/.[1]
Try to avoid naming conflicts, of course. (Check resources like PyPI.)
- Create
README.rst- In the package root, e.g.
littled-addresses/README.rst. - Sample contents at How to Write Reusable Apps—Packaging your app
- In the package root, e.g.
- Create
LICENSEfile in the package root.- Django itself uses the BSD license.
- Create
setup.pyin the project root.- Sample at How to Write Reusable Apps—Packaging your app
- More complete documentation at setuptools docs.
- Create
MANIFEST.inin the project root.- This includes files other than Python modules and packages.
- Create a
docsdirectory- Include it in
MANIFEST.inwithrecursive-include docs *
- Include it in
Building the package
$ python setup.py sdist
- Run from the package root directory.
- Creates a
distdirectory which contains the (zipped) package.
Using the package
$ pip install --user django-addresses/dist/django-addresses-0.1.tar.gz
This installs the package on a system as a user library.
It can now be referenced in other Django projects.
Uninstalling the package
$ pip uninstall django-addresses
Notes
- ↑ How to Write Reusable Apps (Django documentation)