python software directory specification

Software Directory Structure Specification

Software development specification

First, why should design a good directory structure?

1. High readability: not familiar with the code for this project people, one can understand the directory structure, which is known startup script, where the test directory, where the configuration file, and so on. So very fast about this project.

2. High maintainability: The definition of a good organizational rules, defenders will be able to very clearly know which new files and code should be placed under any directory. The advantage is that, over time, the code / configuration size increases, the structure of the project will not be confused, still able to organize well.

Second, the catalog organization

On how to organize a good Python project directory structure, there are already some consensus has been the directory structure.

Assuming your project called my_project

my_project/
| - bin / executable file to store some items, of course, you can named script / like also, but bin / more intuitive. Understandability
|   |-- __init__
| | - start.py write Launcher
|
| - core / storage project all the source code (core code). (1) all the source code modules, packages should be placed in this directory. Do not put the top-level directory. (2) its sub tests / test code storing means; inlet (3) is preferably a program named main.py.
|   |-- tests/   
|   |   |-- __init__.py
|   |   |-- test.main.py  
|   |
|   |-- __init__.py
| | - test_main.py | storage core logic  
|
| - conf / Profiles
|   |-- __init__.py
| | - setting.py write configuration
|
| --- db / database files
| | --Db.json write database file
|   
| - docs / store some documents
|   
| - lib / library files, put the custom modules and packages
|   |-- __init__.py
| | - common.py put commonly used functions
|
| - log / log file
| | - access.log write log
|
|-- __init__.py
| - README project documentation 
| - requirements.txt

 注:运行程序时,在bin目录下执行start.py代码,不可以直接执行core下的模块。

Project Directory

  • bin       # program entry file
  • Core     # main program directory (core code)
  • conf    # configuration files, mainly for leaving the interface, while others to use, easy to configure
  • db        # database
  • lib        # public library catalog to facilitate other classes (correlation is not universal module, and the current project (low coupling)) module called
  • log       # log file

project files

  • requirements.txt:  storage bag Python list of external software dependencies
  • README.md:  project documentation.
 

About contents of README

I think this is that each 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. The method of running code: installation environment, start commands.
  3. A brief description of the use.
  4. Code directory structure, a more detailed description can point the basic principles of software.
  5. Frequently asked questions.

Guess you like

Origin www.cnblogs.com/pathping/p/11880140.html