Skip to main content
https://badge.fury.io/py/pytoolbox.png https://github.com/davidfischer-ch/pytoolbox/actions/workflows/python-package.yml/badge.svg https://coveralls.io/repos/davidfischer-ch/pytoolbox/badge.png

Afraid of red status ? Please click on the link, sometimes this is not my fault ;-)

This module is a Toolbox for Python scripts.

Documentation: https://pytoolbox.readthedocs.org

Repository: https://github.com/davidfischer-ch/pytoolbox

This library is tested on Python 3.12 and 3.13. Python 3.11 is supported on a best-effort basis but is no longer part of the CI matrix.

The entire codebase is fully type-hinted (Python 3.10+ syntax). This means you get autocompletion, inline documentation and static analysis out of the box in editors like Sublime Text, VS Code, PyCharm, or any tool supporting PEP 484 (e.g. mypy, pyright).

What the release number stands for ?

I do my best to follow this interesting recommendation : Semantic Versioning 2.0.0

How to install it ?

Install some packages that are not handled by pip:

$ sudo apt install liblzma-dev libxml2-dev libxslt-dev libyaml-dev libz-dev
$ sudo apt install ffmpeg git-core python3-dev python3-gi python3-pip screen

If planning to use the imaging extra, especially the exif classes, then you’ll have to install:

$ sudo apt install libcairo2 libcairo2-dev libexiv2-dev libgexiv2-dev libgirepository-2.0-dev

The gir1.2-gexiv2-0.10 should also be installed, maybe its already the case.

You may find useful to read PyGObject’s documentation.

If planning to use the vision feature, then you have to install some requirements for dlib:

$ sudo apt install build-essential cmake pkg-config

See https://learnopencv.com/install-dlib-on-ubuntu/ for an up-to-date procedure.

Make sure that pip is up-to-date (PIPception):

$ source /some/python3/venv/bin/active
$ pip install --upgrade pip setuptools wheel

Then, you only need to run setup.py:

$ source /some/python3/venv/bin/activate
$ pip install .

How to enable features/modules ?

Example:

$ python setup.py install --help

Common commands: (see '--help-commands' for more)

  setup.py build      will build the package underneath 'build/'
  setup.py install    will install the package

Global options:
  --verbose (-v)  run verbosely (default)
  --quiet (-q)    run quietly (turns verbosity off)
  --dry-run (-n)  don't actually do anything
  --help (-h)     show detailed help message
  --no-user-cfg   ignore pydistutils.cfg in your home directory

Options for 'WithExtra' command:
  ...
  --extra-all                          Install dependencies for All Modules.
  --extra-atlassian                    Install dependencies for Atlassian.
  --extra-aws                          Install dependencies for AWS.
  --extra-django                       Install dependencies for Django.
  --extra-django-filter                Install dependencies for Django Filter.
  --extra-django-formtools             Install dependencies for Django Form Tools.
  --extra-flask                        Install dependencies for Flask.
  --extra-imaging                      Install dependencies for Imaging.
  --extra-jinja2                       Install dependencies for Jinja2.
  --extra-mongodb                      Install dependencies for MongoDB.
  --extra-network                      Install dependencies for Networking.
  --extra-pandas                       Install dependencies for Pandas.
  --extra-rest-framework               Install dependencies for Django REST Framework.
  --extra-selenium                     Install dependencies for Selenium.
  --extra-smpte2022                    Install dependencies for SMPTE-2022.
  --extra-unittest                     Install dependencies for Unit Test.
  --extra-vision                       Install dependencies for Vision.
  --extra-voluptuous                   Install dependencies for Voluptuous.
  --extra-doc                          Install dependencies for Pytoolbox Docs.
  --extra-test                         Install dependencies for Pytoolbox Tests.

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help


$ python setup.py install --extra-smpte2022

Another way to do this, with pip:

$ pip install -e .[django,flask,mongo,smpte2022]

How to check coverage ?

$ source /some/python3/venv/bin/activate
$ pip install -e .[all,test]
$ flake8 pytoolbox
$ pytest
$ xdg-open htmlcov/index.html

Remarks:

  • Django 6+ is required for the django and rest_framework extras.

  • Django and REST framework tests run in CI on Python 3.12+.

How to use it ?

Here is an example hello.py using the cmd function provided by pytoolbox:

$ from pytoolbox.subprocess import cmd
$ print(cmd('echo Hello World!')['stdout'])

How to generate documentation ?

The documentation is generated by Sphinx. In fact most of this documentation is extracted from the docstrings of the code.

Here is the procedure:

$ source /some/python3/venv/bin/activate
$ pip install -e .[docs]
$ xdg-open docs/build/html/index.html

How to add it to dependencies of my own project ?

Here is an example setup.py for a project called my-cool-project:

  from setuptools import setup

  setup(
name='my-cool-project',
            version='0.8',
            author='Firstname Lastname',
            author_email='author@something.com',
            install_requires=['...', 'pytoolbox>=14<15', '...'],
            tests_require=['...', 'pytest', '...'],
            license='GPLv3',
            url='https://github.com/nickname/my-cool-project',
            packages=['my_cool_project'])

See pip vcs support to get further details about this.

You also need to install git-core, but it is probably already the case, at least on your development computer ;-)

2012 - 2025 David Fischer

Metadata

Release files for pytoolbox 14.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytoolbox 14.12.0
File Size Uploaded
pytoolbox-14.12.0.tar.gz 262.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytoolbox 14.12.0
File Interpreter ABI Platform
pytoolbox-14.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 496.3 kB

Release files / pytoolbox-14.12.0.tar.gz

Download URL pytoolbox-14.12.0.tar.gz
Size 262.3 kB
Tags Source
SHA-256 checksum
How to use checksums
39750ed83abedd139dc77e665d94a8e069a006f2782dfb09134d2ab23ce5ab62
BLAKE2b-256 checksum
How to use checksums
f4be5528b058201b5a6bef2ee6796f5c799348afc89c4ac6a403e25ce82c54b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / pytoolbox-14.12.0-py3-none-any.whl

Download URL pytoolbox-14.12.0-py3-none-any.whl
Size 234.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6127e89b476495a9cae546c252dc2a96e2d0de26b9f50c50b9e56daff2d9b4fb
BLAKE2b-256 checksum
How to use checksums
b080a68e80280a9a2319a9e3c58ead36da85d0966bddc1ca5d002a329b61d8a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

14.12.0 This release

2 release files

14.9.2

2 release files

14.8.5

2 release files

14.8.3

2 release files

14.8.0

2 release files

14.7.0

2 release files

14.6.0

2 release files

14.2.0

2 release files

14.0.2

2 release files

14.0.1

2 release files

13.5.0

3 release files

13.4.0

3 release files

13.3.5

3 release files

13.3.4

3 release files

13.3.3

3 release files

13.3.2

3 release files

13.3.1

3 release files

13.1.3

3 release files

13.0.4

3 release files

13.0.3

3 release files

13.0.2

3 release files

13.0.1

3 release files

13.0.0

3 release files

12.2.3

3 release files

12.2.2

3 release files

11.9.0

1 release file

11.8.6

1 release file

11.7.6

1 release file

11.6.4

1 release file

11.5.4

1 release file

11.4.3

1 release file

10.4.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page