I have a sub command that requires to get number of CPU cores as an arguments.
As I understand tox commands doesn’t support bash template engine mechanism.
Do you know how to get count of CPU cores?
[tox]
min_version = 4.0
env_list =
py310
[testenv]
commands =
bin --jobs ${nproc}
make test
You could use a wrapper script which populates a template (say, tox.tmp), expanding {nprocs} appropriately, then exec’s tox on the generated tox.ini file. Alternatively, this would be a pretty trivial make target, something like (untested — mind the quoting!):
tox : tox.tmp # and other dependencies
cores=`python -c 'import multiprocessing as mp; print(mp.cpu_count())'` ; \
sed -e "s/{nprocs}/$$cores/" < tox.tmp > tox.ini
tox run