Python learning software development directory specification

In order to improve the readability and maintainability of the program, we should be well-designed software directory structure, coding style as important as this and norms. Directory specification is no hard and fast standard software, as long as you can clearly readable, assuming your software named foo, I recommend the following directory structure

Foo/
|-- core/
|   |-- core.py
|
|-- api/
|   |-- api.py
|
|-- db/
|   |-- db_handle.py
|
|-- lib/
|   |-- common.py
|
|-- conf/
|   |-- settings.py
|
|-- run.py
|-- setup.py
|-- requirements.txt
|-- README

Explain briefly:

• core /: storing business logic relevant code

• api /: file storage interfaces, interface is mainly used to provide data for the operation of the business logic.

• db /: database-related files store operations, mainly for interacting with databases

• lib /: stored procedures commonly used in custom modules

• conf /: store configuration files

• run.py: program startup files, usually placed in the root directory of the project, because at runtime by default will run the file folder where sys.path as the first path, thus eliminating processing environment step variable

• setup.py: installation, deployment, packaged script.

• requirements.txt: Python package store a list of external software dependencies.

• README: project documentation.

In addition, there are a number of programs are given more and more content, such as LICENSE.txt, ChangeLog.txt documents, primarily will be used in the open source project needs, the reader look yourself.

About the README, and this should be every project should have a file, the purpose is to be able to brief information of the project description, allowing readers to quickly understand the project. It should be noted that the following matters:

1 , the basic functions of the software localization, software;

 2 , method of operating code: installation environment, start commands;

 3 , brief instructions;

 4 , the code directory structure, and more points can illustrate the basic principles of software;

 5, Frequently asked questions.

About setup.py and requirements.txt:

In general, use setup.py to manage the package code, installation and deployment issues. The industry standard is written in Python setuptools popular packaging tools to manage these things, this approach is widely used in open source projects. But here's the core idea of ​​not using standardized tools to solve these problems, but said that a project must have a deployment tool to install, can be quickly and easily installed on a new machine on the environment, the code will be deployed and running stand up.

Requirements.txt file exists for the convenience of developers to maintain software dependencies. We need to rely on the information in the database development process added to the file, to avoid missing package when setup.py install dependencies, but also convenient for users clear reference to the project which Python package.

The file format is described in each row contains a packet-dependent, usually flask> = 0.10 this format, the requirement is PIP format can be identified, so that simply by pip install -r requirements.txt to all Python dependent libraries are installed, with reference to the specific format https://pip.readthedocs.io/en/1.1/requirements.html

Guess you like

Origin www.cnblogs.com/imark7/p/12592258.html