Coder Social home page Coder Social logo

python-application-boilerplate's Introduction

Python Application Boilerplate

Getting Started

This boilerplate uses Pipenv to manage dependencies and its virtual environment. You will need to install it if you do not already have it.

1. Install Project Dependencies

Use Pipenv to create a virtual environment and install the dependencies set in the Pipfile. Setting the --dev flag will include the (optional) development dependencies.

pipenv install --dev

2. Run Stuff, Do Stuff...

Understanding Pipenv Scripts

Scripts set within the Pipefile provide a convinient way to run shell commands. They allow you to define shortcuts for commonly-used commands, regardless of whether they need to be executed within a virtual environment or not. To run a script, you simply prefix it with pipenv run.

If this in your Pipefile (Look, it is!)

[scripts]
start = "pipenv run python -m my_app --text '1. Check it out!'"
clean = "rm -rf docs && rm -rf reports"

Then

  • pipenv run start executes the command python -m my_app --text '1. Check it out!' within the virtual environment

  • pipenv run clean executes the simple shell command rm -rf docs && rm -rf reports which doesn't require any virtual environment

Tooling

Installation and Package Management with Pipenv

Pipenv – A production-ready tool that aims to bring the best of all packaging worlds to the Python world. It harnesses Pipfile, pip, and virtualenv into one single command.

Install pipenv:

pip install --user pipenv

Linting with PyLint and Black

Pylint – Analyses your code without actually running it. It checks for errors, enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored.

Install pylint:

pipenv install -d pylint

Black – Cedes control over minutiae of hand-formatting.

Installblack:

pipenv install -d black

Testing and Coverage with Pytest and Pytest-cov

Pytest – Framework that makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries.

Install pytest:

pipenv install -d pytest

Pytest-cov – Pytest plugin for measuring coverage.

Install pytest-cov:

pipenv install -d pytest-cov

Documentation with Pdoc3

Pdoc3 – Auto-generate API documentation for Python projects.

Install pdoc3:

pipenv install -d pdoc3

Command-Line Argument Parsing with Argparse

Argparse – Parser for command-line options, arguments and sub-commands.

Install argparse:

pipenv install argparse

python-application-boilerplate's People

Contributors

sidisinsane avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.