Skip to main content

Put tox work directories in a cache directory by default.


By default, tox will create packaging and test environments in a .tox/ subdirectory in the same directory as the project’s tox.ini or pyproject.toml file.

.tox/
|   +-- .pkg/
|   +-- docs/
|   +-- mypy/
|   +-- py39/
|   +-- py310/
|   +-- py311/
|   +-- py312/
|   \-- py313/
|
\-- tox.ini

As you interact with more and more projects, those .tox/ directories will proliferate throughout your filesystem.

This default behavior makes it harder to clean up all of your cached environments and can make backups slow (and potentially expensive).

tox-workdir changes the default work directory to point to your user cache directory, keeping your development directories trim and sleek over time.

Installation

If you’re using pipx, inject tox-workdir into your existing tox install:

pipx inject tox tox-workdir

If you’re using a virtual environment, install tox-workdir as a regular package:

pip install tox-workdir

No configuration is needed; installing the plugin immediately changes the default work_dir value.

Work directory paths

Where tox defaults to .tox/, tox-workdir defaults to your user cache directory:

Operating system

Base path

Linux

$XDG_CACHE_DIR/tox-workdir/

macOS

/Users/{user}/Library/Caches/tox-workdir/

Windows

C:\Users\{user}\AppData\Local\kurtmckee\tox-workdir\Cache\

Note that $XDG_CACHE_DIR, above, defaults to $HOME/.cache if unset.

A hash of the path to the tox config file is used as a subdirectory for uniqueness.

You can see the workdir value that will be used by running:

tox workdir

Feel-good benefits

To feel good about your choice to install this plugin, simply check how much space .tox/ directories are consuming. Then, think about how much faster your backups will process without all of those .tox/ directories!

Assuming that you have a development directory with a number of project directories, you can run one of the following commands to see how much space is consumed by .tox/ subdirectories.

On Linux and macOS:

$ du -csh */.tox | tail -n 1
10G     total

On Windows, using Powershell:

$ (Get-ChildItem -Recurse */.tox | Measure-Object -Property Length -Sum).Sum / 1GB
10.00000000

Release files for tox-workdir 0.1.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 tox-workdir 0.1.0
File Size Uploaded
tox_workdir-0.1.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tox-workdir 0.1.0
File Interpreter ABI Platform
tox_workdir-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / tox_workdir-0.1.0.tar.gz

Download URL tox_workdir-0.1.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9be41c8939468b60f599efb9a0b70a75feef9d1b0ee801470a5e8c57936c9750
BLAKE2b-256 checksum
How to use checksums
0d5802c5b791b6bf1dd5ceebb3881484bd244f50fa18a113115d240bb0539c28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Release files / tox_workdir-0.1.0-py3-none-any.whl

Download URL tox_workdir-0.1.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c210b3e2dc9243e829094aaaed6266c569b34a5990ba65890caa3638e9c67c40
BLAKE2b-256 checksum
How to use checksums
b8faba933d47a1bfd95847a0fc19addc0dbc3b3e712d8f061f6f53b28e00ee4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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