/python_project_template

Primary LanguagePythonMIT No AttributionMIT-0

Template

tests-badge coverage-badge pyright-badge bandit-badge pycodestyle-badge pydocstyle-badge

Customization

  • Customize pyproject.toml (don't forget [tool.pytest.ini_options] addpots = <...> --cov=[NAME] <...>)
  • Custom LICENSE (Third line must match Copyright <YEAR> <NAME> (or further changes are needed in docs/source/conf.py))
  • Customize README.md (change badge sources)
  • Run git branch -b dev
  • Customize requirements.txt

User installation

Via pip and PyPI:

pip install 

Or build from source:

git clone <URL>
python -m pip install --upgrade build
python -m build
python -m pip install .

To build the documentation:

(cd ./docs; make html)

Development setup

  1. [OPTIONAL] For the greatest comfort install Visual Studio Code and these plugins:

    • Python/Pylance/isort/Jupyter (Microsoft) combined in the python extension pack
    • Coverage Gutters (ryanluker)
    • autoDocstring - Python Docstring Generator (Nils Werner)
    • Todo Tree (Gruntfuggly)

  2. Clone repository

    git clone <URL>
    cd <FOLDER>
    
  3. Create virtual environment

    python -m venv ./.venv
    . ./.venv/bin/activate
    
  4. Setup

    git checkout dev
    python -m pip install --upgrade pip
    python -m pip install --upgrade build
    python -m build
    python -m pip install --editable .[dev]
    
  5. Develop

    1. New branch

      git merge master
      git checkout -b [feature|bugfix]/***
      

      or

      git checkout master
      git checkout -b hotfix/***
      
    2. Format+Lint

      python -m black src tests
      python -m pycodestyle src tests
      python -m pydocstyle src
      python -m bandit -r -c pyproject.toml src
      python -m pyright src
      
    3. Test

      python -m pytest
      
    4. Commit

      git commit -m "..." 
      git push
      
    5. When done: Merge

      git pull
      git merge [dev|master]
      git checkout [dev|master]
      git merge <branch>
      git branch -d <branch>
      git push
      
  6. Document

    nano CHANGELOG.md
    python badges.py
    
  7. Publish

    git commit -m "..."
    git push
    git tag -a vX.Y.Z -m "Version X.Y.Z"
    git push origin vX.Y.Z
    python -m build
    python -m twine upload --repository hello_world dist/* --username <USER> --password *****
    
  8. Deactivate environment

    . deactivate
    

TODO

  • Rework badges.py
  • Dockerfile