Skip to content

A [simple] [general-purpose] Python template πŸπŸš€πŸŽ‰πŸ¦•

License

Notifications You must be signed in to change notification settings

mohsenhariri/template-python

Repository files navigation

Python Template

A [simple] [general-purpose] Python template πŸπŸš€πŸŽ‰πŸ¦•

I used this template for fesenjoon and medviz.

How to use

Bootstrap

To use env in another directory:

    make env

There is no need to active virtual environment when the PY command is used from Makefile.

To use env here (local directory)

    make env-local
    source env_platform_ver/bin/activate

Set a name for the package:

    make init newName

Check Python and pip version

    make

Update pip and build tools

    make check

Install the requirements

    make pireq

Install a package

    make piu numpy matplotlib scipy

Features

  • Linter: Pylint
  • Formatter: Black
  • CI: GitHub Actions

ToDo

  • Formatter: Black + isort
  • Type checker: MyPy
  • Linter: Ruff
  • Linter: Pylint
  • GitHub Actions
  • Git Hooks
  • PyPI Publish
  • Flit
  • Poetry
  • Ruff

Git

Git hooks are available in ./scripts/.githooks

    chmod +x ./scripts/.githooks/script

    git config core.hooksPath ./scripts/.githooks

Publish to PyPI

  1. To build a package, run:
    make pkg-build
  1. To check the build, run:
    make pkg-check
  1. To install the package locally, run:
    make pkg-install
  1. Create .pypirc file in the root directory of the project. It should look like this:
    [distutils]
    index-servers =
        pypi
        testpypi

    [pypi]
    repository: https://upload.pypi.org/legacy/
    username: <your username>
    password: <your password>

    [testpypi]
    repository: https://test.pypi.org/legacy/
    username: <your username>
    password: <your password>
  1. To publish to PyPI, run:
    make pkg-publish