Skip to main content

Run and handle the output of multiple executables in pyallel (as in parallel)

Reason this release was yanked:

Includes creation of an unintentional pyallel.log file that was supposed to be released in version 2.1.0

Project description

Pyallel

Run and handle the output of multiple executables in pyallel (as in parallel)

demo

Tested on Linux and MacOS only

Installation

Pre-built executables are available on the Releases page.

pyallel can also be installed using pipx (requires Python >=3.8):

pipx install pyallel

Quick start

Once installed, you can run pyallel to see usage information, like so:

usage: pyallel [-h] [-t] [-n] [-V] [--colour {yes,no,auto}] [commands ...]

run and handle the output of multiple executables in pyallel (as in parallel)

RUNNING COMMANDS
================
to run multiple commands you must separate them using the command separator symbol (::)

  pyallel mypy . :: black .

if you want to provide options to a command you need to use the double dash symbol (--) to indicate that
any options provided after this symbol should not be interpreted by pyallel

  pyallel -n -- mypy -V :: black --version

commands can also be grouped using the group separator symbol (:::)

  pyallel echo boil kettle :: sleep 1 ::: echo make coffee

the above will print 'boil kettle' and sleep for 1 second first before printing 'make coffee'.
command groups are ran in the sequence you provide them, and if a command within a command group fails,
the rest of the command groups in the sequence are not run

modifiers can also be set for commands to augment their behaviour using the command modifier symbol (::::)

lines (only used in interactive mode):
  the lines modifier allows you to specify how many lines the command output can take up on the screen

    pyallel lines=90 :::: echo running long command... :: echo running other command...

  90 is expressed as a percentage value, which must be between 1 and 100 inclusive

SHELL SYNTAX
============
each command is executed inside its own shell, this means shell syntax is supported.
it is important to note that certain shell syntax must be escaped using backslashes (\)
or wrapped in single quotes (''), otherwise it will be evaluated in your current
shell immediately instead of the shell that your command will run within.

some examples of using shell syntax are below (single quotes are used only if required)

  pyallel MYPY_FORCE_COLOR=1 mypy .            <- provide environment variables
  pyallel 'mypy . | tee -a mypy.log'           <- use pipes to redirect output
  pyallel 'cat > test.log <<< hello!'          <- use input and output redirection
  pyallel 'mypy .; pytest .'                   <- run commands one at a time in sequence
  pyallel 'echo $SHELL; $(echo mypy .)'        <- expand variables and commands to evaluate
  pyallel 'pytest . && mypy . || echo failed!' <- use AND (&&) and OR (||) to run commands conditionally

positional arguments:
  commands              list of commands and their arguments to run in parallel

options:
  -h, --help            show this help message and exit
  -t, --no-timer        don't time how long each command is taking
  -n, --non-interactive
                        run in non-interactive mode
  -V, --version         print version and exit
  --colour {yes,no,auto}
                        colour terminal output, defaults to "auto"

Currently you can provide a variable number of commands to run to pyallel, like so:

pyallel -- MYPY_FORCE_COLOR=1 mypy . :: black --check --diff . :: pytest .

Build

You can also build an executable with the following (executables will be written to ./dist):

[!NOTE] The arch=x86_64 values in the following code blocks can be replaced with arch=aarch64 and any other architecture that is supported by docker to build an executable for that given architecture

[!NOTE] To build aarch64 binaries on an x86_64 host machine, you will need to run the following commands to setup qemu to allow this to work

sudo apt-get install qemu binfmt-support qemu-user-static && \
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Build for generic linux

docker build --tag pyallel --build-arg 'arch=x86_64' --build-arg "uid=$(id -u)" . && \
    docker run -e 'arch=x86_64' --rm --volume "$(pwd):/src" pyallel

Build for alpine linux

docker build --tag pyallel-alpine --build-arg 'arch=x86_64' --build-arg "uid=$(id -u)" --file Dockerfile.alpine . && \
    docker run -e 'arch=x86_64' --rm --volume "$(pwd):/src" pyallel-alpine

Build locally

pipx install uv && \
  uv sync && \
  source .venv/bin/activate && \
  ./build.sh

Build all

./build_all.sh

TODOs

  • Add support to have commands depend on other commands (some commands must complete before a given command can start)
  • Add support to state how many lines a command can use for it's output in interactive mode
  • Improve printing of output performance by only printing lines that have changed
  • Add a debug mode that logs debug information to a log file
  • Maybe add support to allow the user to provide stdin for commands that request it (such as a REPL)
  • Add custom parsing of command output to support filtering for errors (like vim's errorformat)
  • Allow list of files to be provided to supply as input arguments to each command
  • Allow input to be piped into pyallel via stdin to supply as standard input to each command

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyallel-2.0.6.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyallel-2.0.6-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file pyallel-2.0.6.tar.gz.

File metadata

  • Download URL: pyallel-2.0.6.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pyallel-2.0.6.tar.gz
Algorithm Hash digest
SHA256 8dcf639b135454b824aa9deab8f2a2fd3066d63fd411f5a96b92a2991ea40a2a
MD5 9db958d9cc3364af485ad1c5d603c66b
BLAKE2b-256 b8d78dc40a85db250e9dd62445047b28cf89c31b8470822149ff98deaf6b5889

See more details on using hashes here.

File details

Details for the file pyallel-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: pyallel-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pyallel-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bd56fb915aab1d006a192101673876c78141da15ee5ebeeecca66d6adf7bc7dc
MD5 0ed2b34824cdc9c7282b695f89d6e40c
BLAKE2b-256 a7b3edefe29140514a3b38c5ef4ba4e28d09b238a7ab140ffd53be18d70eb460

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page