[Django] project packaging and Construction
The structure of the django project is basically similar. The main function of packaging is to remove unnecessary files and compress and package the files to be deployed. Here, you also want to integrate a configuration file template to generate a configuration file, or write a tool for generating the configuration file, so you do not need to copy and modify it every time, which is prone to errors. The following is a small experiment by orangleliu Jun for your reference and communication.
This is the file structure of the project.
Official Document tutorial setuptools Module
Setuptools should encapsulate the setup module in the standard library, which looks better.
Packaging Process
If you install the setuptools module, it is generally installed because of pip.
Create a new setup. py file under the project directory.
# Coding: UTF-8 # package projectfrom setuptools import setup, find_packagessetup (name = "apmonitor", version = "1.0.0", author = "orangleliu", author_email = "orangleliu@gmail.com ", # automatic search with _ init __. py folder packages = find_packages (exclude = ["logs"]), install_requires = ['django = 1.6 '], description = "ap monitor system ", # Some separate py scripts, not in some modules scripts = ["dbrouters. py "," index. py "," manage. py "," settings. py "," uwsgi. py "," _ ini __. py "], # static files, etc., with MANIFEST. in (package_data parameter is not very good) include_package_data = True, # if it is a formal project, there will be more information (such as open source Certificate written below) url = "http://wifi21.com ",)
The file contains only python scripts and packaging information.
Adding static resources (htm style js image configuration, etc.) requires another configuration file MANIFEST. in
recursive-include conf *recursive-include staticfiles *recursive-include templates *recursive-include */templates *
Then use the command to package
python setup.py sdist
A dist folder is generated under the directory of the same level as setup. py, which contains the packaged file and a xxx. egg-info file.
Summary
This process is the simplest. Only some pyhton modules and static resources can be packaged. setup can also generate many packages in the medium format. More customization options can be found in the document. Some customized things are needed, some are generated, and some are automatically added.