[Django] project packaging and Construction

Source: Internet
Author: User

[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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.