{"library":"sccache","title":"Sccache","description":"Sccache (Shared Compilation Cache) is a ccache-like tool written in Rust that acts as a compiler wrapper to accelerate build times by caching compilation results. It supports C/C++, Rust, and CUDA, and can utilize various local and cloud storage backends like S3, Google Cloud Storage, Redis, and Memcached. The PyPI package for sccache (version 0.14.0) primarily provides access to this binary tool for Python environments. It is actively maintained by Mozilla and a community of contributors, with regular releases providing new features and bug fixes.","language":"python","status":"active","last_verified":"Mon Apr 13","install":{"commands":["pip install sccache"],"cli":{"name":"sccache","version":"sccache 0.15.0"}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport subprocess\n\n# Ensure sccache is in PATH or set SCCACHE env var if installed elsewhere\n# For simplicity, assuming 'sccache' is callable from PATH after 'pip install sccache'\n\n# Start the sccache server in the background (optional, but recommended for efficiency)\n# The server automatically stops after 10 minutes of inactivity by default.\nsubprocess.run(['sccache', '--start-server'])\n\n# Example usage: Compile a Rust project with sccache\n# This environment variable tells Cargo/rustc to use sccache as a wrapper\nenv = os.environ.copy()\nenv['RUSTC_WRAPPER'] = 'sccache'\n\nprint('Building Rust project with sccache...')\ntry:\n    # Simulate a Rust build command\n    subprocess.run(['cargo', 'build', '--release'], env=env, check=True)\n    print('First build (warming cache) completed.')\n\n    # Run again to demonstrate caching effect\n    subprocess.run(['cargo', 'clean'], check=True)\n    print('Cache cleaned, running second build...')\n    subprocess.run(['cargo', 'build', '--release'], env=env, check=True)\n    print('Second build (should be faster due to cache) completed.')\n\n    # Show sccache statistics\n    subprocess.run(['sccache', '--show-stats'], check=True)\n\nfinally:\n    # Stop the sccache server\n    subprocess.run(['sccache', '--stop-server'])\n    print('Sccache server stopped.')\n","lang":"python","description":"Sccache is primarily used as a command-line wrapper for compilers, configuring your build system to use `sccache` as the compiler executable or wrapper. The PyPI package installs the `sccache` binary. This example demonstrates how to invoke `sccache` via Python's `subprocess` module to wrap a Rust build, showing the typical `RUSTC_WRAPPER` environment variable usage. For C/C++ builds, you would typically set `CC='sccache gcc'` or `CXX='sccache g++'`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}