How to organize a Python Project?

后端 未结 8 1922
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-22 16:35

I\'m new to Python and I\'m starting a mini Project, but I have some doubts on how to organize the folders in the \"Python Way\".

I\'m using PyDev in my

相关标签:
8条回答
  • 2020-12-22 16:59

    You might want to check out the modern-package-template libary. It provides a way to setup a really nice basic layout for a project that walks you through a few questions and tries to help you get something that's able to be distributed fairly easily.

    http://pypi.python.org/pypi/modern-package-template

    0 讨论(0)
  • 2020-12-22 17:03

    See python-package-template

    Directory structure

        .
        |-- bin
        |   `-- my_program
        |-- docs
        |   `-- doc.txt
        |-- my_program
        |   |-- data
        |   |   `-- some_data.html
        |   |-- __init__.py
        |   |-- submodule
        |   |   `-- __init__.py
        |   |-- helpers.py
        |-- tests
        |   |-- __init__.py
        |   |-- test_helpers.py
        |-- Makefile
        |-- CHANGES.txt
        |-- LICENSE.txt
        |-- README.md
        |-- requirements-dev.txt
        |-- requirements.txt
        `-- setup.py
    

    cat Makefile

        PYTHON=`which python`
        NAME=`python setup.py --name`
    
    
        all: check test source deb
    
        init:
            pip install -r requirements.txt --use-mirrors
    
        dist: source deb
    
        source:
            $(PYTHON) setup.py sdist
    
        deb:
            $(PYTHON) setup.py --command-packages=stdeb.command bdist_deb
    
        rpm:
            $(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall
    
        test:
            unit2 discover -s tests -t .
            python -mpytest weasyprint
    
        check:
            find . -name \*.py | grep -v "^test_" | xargs pylint --errors-only --reports=n
            # pep8
            # pyntch
            # pyflakes
            # pychecker
            # pymetrics
    
        clean:
            $(PYTHON) setup.py clean
            rm -rf build/ MANIFEST dist build my_program.egg-info deb_dist
            find . -name '*.pyc' -delete
    
    0 讨论(0)
提交回复
热议问题