thx

Rapid development assistant, and fast command runner for Python projects.

MIT Licensed PyPI Release Changelog Documentation Status Build Status

thx (“thanks”) is capable of running arbitrary jobs, configured via simple options in the PEP 518 standardized pyproject.toml. Jobs can be run on multiple Python versions at once, and independent steps can be executed in parallel for faster results.

Watch thx format the codebase, build sphinx docs, run the test and linter suites on five Python versions, and generate a final coverage report:

thx can also watch for modifications to your project, and automatically run jobs every time changes are detected—it will even reload its configuration when your pyproject.toml changes:

Usage

Configuration uses standard TOML elements, and jobs can reference shared values, which will be interpolated at runtime:

[tool.thx.values]
module = "thx"

[tool.thx.jobs]
lint = [
    "flake8 {module}",
    "ufmt check {module}",
]
test = "python -m unittest -v {module}.tests"

The configuration above defines two jobs, “lint” and “test”; the “lint” job defines two steps, and these can optionally be run in parallel. Both jobs present themselves as separate commands in thx. Note the automatic replacement of {module} with the configured value thx when running jobs:

$ thx lint
> flake8 thx
> ufmt check thx
$ thx test
> python -m unittest thx.tests

They can also be run together in order, similar to makefiles:

$ thx test lint
> python -m unittest thx.tests
> flake8 thx
> ufmt check thx

By default, thx uses the active Python runtime for jobs, but can also run jobs on multiple runtimes in parallel:

[tool.thx]
python_versions = ["3.7", "3.8", "3.9"]
$ thx test
3.9> python -m unittest thx.tests
3.8> python -m unittest thx.tests
3.7> python -m unittest thx.tests

See the user guide for details on all available configuration options.

Install

Note

thx is still in active development. Configuration options should be stable, but compatibility between minor releases is not guaranteed. For important production cases, please be sure to pin yourself to a single version, and test any new releases thoroughly.

thx is available on PyPI:

$ pip install thx

See the user guide for help getting started.

License

thx is copyright John Reese, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.