Skip to content

jlandercy/newproject

Repository files navigation

Python New Project Package

This repository holds a minimal but complete python3 package with the following quality services already included:

  • setuptools flow for packaging;
  • unittest test suite sub-package suited for Test Driven Development;
  • coverage for test suite;
  • bandit and safety for security tests;
  • pylint and flake8 for syntax checks;
  • mypy for type hints checks and errors;
  • black and isort for code formatting;
  • jupyter notebooks rendering (with Sphinx integration);
  • Sphinx documentation builder;
  • anybadge for any session badges;
  • nox for session coordination;
  • GitLab CI Pipeline and GitHub Workflow (future).

How to?

Start a new project

To start a new project from this package few steps are required:

  1. Fork this repository to your hub account and rename it;
  2. Clone the forked repository to your workspace;
  3. Rename the project by renaming the package directory;
  4. Start to implement your project as usual.

Check package capabilities

Running Code Quality tool suite for this package requires Code Quality packages are installed (defined in ./docs/requirements.txt):

python -m pip install -r ./docs/requirements_ci.txt

Code Quality environment is also available in a dedicated Docker image.

Then, to check package capabilities (aka nox sessions), issue:

nox --list

- clean -> Package Code Cleaner
- package -> Package Builds (badge)
- install -> Package Installer
- uninstall -> Package Uninstaller
* tests -> Package Test Suite Report (badge)
* coverage -> Package Test Suite Coverage Report (badge)
* security -> Package Security Report (badges)
* linter -> Package Linter Report (badge)
* syntax -> Package Syntax Report (badge)
* types -> Package Type Hints Report (badge)
* styles -> Package Code Styles Report (badge)
- notebooks -> Package Notebooks (badge)
- docs -> Package Documentation (badge)

Install package

Create a virtual environment if required and activate it:

python3 -m virtualenv venv
source venv/bin/activate

This package follows the usual setuptools flow, installation is as simple as:

python3 setup.py install

This will install dependencies as well (as defined in requirements.txt).

To build a wheel and install from it, then issue:

nox --session package install

Test package

This package uses unittest to create its test suite, to run the complete package test suite, issue:

nox --session tests

Test coverage

This package uses coverage to assess code coverage. To run the test suite coverage, issue:

nox --session coverage

Check security

This package uses bandit for security checks. To check package python security know vulnerabilities, issue:

nox --session security safety

Check syntax

This package uses pylint and flake8 for syntax checks. To check package python syntax, issue:

nox --session linter syntax

Check types

This package uses mypy to check types hints. To check type hints and common errors, issue:

nox --session types

Check styles

This package uses black and isort to check or coerce python code styles. To check if your code is black, issue:

nox --session styles

To actually style the package code inplace, issue:

nox --session clean

Refresh notebooks

This package uses jupyter notebooks for tests and documentation purposes. To refresh all notebooks, issue:

nox --session notebooks

Note: it will rely on previously defined virtual environment venv.

Build documentation

This package uses Sphinx to build documentation. To generate the package documentation, issue:

nox --session docs

Generate badges

All badges are automatically generated for each nox session using anybadge and related report contents (see noxfile.py for details).

About

New Python3 Project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages