Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new codebase structure #13022

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

GreatV
Copy link
Collaborator

@GreatV GreatV commented Jun 11, 2024

the new codebase structure looks like this:

tree -L 3        
.
├── LICENSE
├── MANIFEST.in
├── README.md
├── README_en.md
├── VERSION_NUMBER
├── applications
├── benchmark
├── configs
├── deploy
├── doc
├── paddleocr.egg-info
├── pyproject.toml
├── requirements.txt
├── setup.py
├── src
│   └── paddleocr
│       ├── __init__.py
│       ├── __pycache__
│       ├── cli
│       ├── paddleocr.py
│       ├── ppocr
│       ├── ppstructure
│       └── tools
├── test_tipc
├── tests
├── tools
└── train.sh

@GreatV GreatV changed the title new codebse structure new codebase structure Jun 11, 2024
@SWHL
Copy link
Collaborator

SWHL commented Jun 11, 2024

What is the reason for creating a separate src directory?

@GreatV GreatV marked this pull request as draft June 11, 2024 08:14
@GreatV
Copy link
Collaborator Author

GreatV commented Jun 11, 2024

hi @SWHL,
Creating a src directory in a Python project has several benefits:

  1. Clear Project Structure:

    • Separates source code from other files like configuration, documentation, tests, and data, making the project easier to read and maintain.
  2. Avoiding Namespace Clashes:

    • Prevents conflicts with built-in Python modules or other dependencies by keeping the main project directory out of the PYTHONPATH.
  3. Easier Testing and Development:

    • Clarifies import paths and ensures tests run against the correct version of the code, avoiding issues with global installations.
  4. Encouraging Proper Package Installation:

    • Promotes using pip install -e . for development, ensuring correct imports and testing in an environment similar to production.
  5. Facilitating Automation and CI/CD:

    • Simplifies continuous integration and deployment by providing clear separation of concerns.
  6. Promoting Best Practices:

    • Aligns with recommendations from Python community standards and guides.

Example Project Structure

my_project/
├── .git/
├── .gitignore
├── README.md
├── pyproject.toml
├── requirements.txt
├── src/
│   └── my_package/
│       ├── __init__.py
│       ├── module1.py
│       └── module2.py
├── tests/
│   ├── __init__.py
│   └── test_module1.py
└── docs/
    └── index.md

In this structure:

  • src/my_package/ contains the source code.
  • tests/ contains test files.
  • docs/ contains documentation.
  • Configuration files are at the root for easy access.

This setup ensures a clean separation, making the project more manageable.

@SWHL
Copy link
Collaborator

SWHL commented Jun 11, 2024

At present, I don't think it is suitable for this big structural change. Even though it has so many benefits.
This will make the issues and discussions that rely on the old structure invalid.
I think it would be better to gradually adjust this structure after all the existing bugs are resolved.

Just personal thoughts.

@GreatV
Copy link
Collaborator Author

GreatV commented Jun 11, 2024

Hi @SWHL, You're right, this PR is still a work in progress and will continue when conditions are suitable.

@jzhang533
Copy link
Collaborator

Current codebase layout is neither a flat layout, nor a src layout.
It's a single-module distribution, the __init__.py and paddleocr.py are placed directly under the project root. I think this is a compromise for combing ppocr module and ppstructure module into one package.

As a middle size project, we'll need to modernize the codebase layout to src layout to clearly separate source codes and usage codes, to improve the maintainability.

ref: https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants