backports.tempfile
Backport of new features in Python's tempfile module
What it is and what it does
backports.tempfile backports the TemporaryDirectory context manager from Python's standard tempfile module to older Python versions that lack it. TemporaryDirectory is a context manager that creates a temporary directory and automatically cleans it up when the context exits.
This package targets Python 2.7, 3.4, 3.5, and 3.6. It has no runtime dependencies and installs with low friction. However, the package is abandoned—no releases since 2017-10-13 and no commits since 2019-04-02. It is only relevant if you are maintaining legacy code that must run on these old Python versions.
Use it for:
- Legacy Python 2.7 codebases that need safe temporary directory handling without manual cleanup.
- Supporting Python 3.4 or 3.5 applications where TemporaryDirectory is not yet available in the standard library.
- Unified code that must run on both Python 2 and early Python 3 versions using a single import.
- Migrating older projects away from manual tempfile cleanup logic to a context-manager approach.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides the TemporaryDirectory context manager for Python 2.7 and early Python 3 versions that lack it in their standard library.
No, unless you are actively maintaining legacy code on Python 2.7, 3.4, or 3.5. The package is abandoned (last release 2017-10-13, last commit 2019-04-02) and unnecessary for any modern Python project. If you do need it for legacy support, it installs cleanly with no dependencies, but expect no future maintenance or security updates.
Install
backports-tempfile on PyPI
pip
pip install backports-tempfileuv
uv add backports-tempfilepoetry
poetry add backports-tempfileInstalling backports.tempfile
Before you install
Low install friction with no runtime dependencies. However, the package is abandoned—last release was 2017-10-13 and last commit 2019-04-02. Only relevant if you must support Python 2.7, 3.4, or 3.5.
License in practice
Licensed under Python Software Foundation License (permissive). No restrictions on use or redistribution in typical commercial or open-source contexts.
Quickstart
pip install backports.tempfile
from backports.tempfile import TemporaryDirectory
with TemporaryDirectory() as tmpdir:
# Use tmpdir for temporary files
pass
Only useful on Python 2.7, 3.4, 3.5, or 3.6 where TemporaryDirectory is not available in the standard library.
Verify before relying
- Whether the backport's TemporaryDirectory behavior exactly matches the standard library implementation across all tested versions.
- Whether this backport remains compatible with Python versions beyond 3.6 despite classifiers stopping there.
Package facts
| License | Python Software Foundation License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 3,227 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,228,976/month — #4,188 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: backports.tempfile-1.0-py2.py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
contextlib2contextlib2 backports the Python standard…
permissive · top 5,000 on PyPI
memory-tempfileIdentifies and provides access to RAM-based…
permissive · top 15,000 on PyPI
backports.weakrefBackports the `weakref.finalize` class from…
permissive · top 5,000 on PyPI
linecache2Provides a backport of Python's linecache…
permissive · top 5,000 on PyPI
backports.zstdProvides Zstandard compression support for…
permissive · top 1,000 on PyPI
django-utils-sixProvides a backport of Django 2.2's…
permissive · top 15,000 on PyPI
unittest2Backports unittest features from Python 2.7 and…
permissive · top 5,000 on PyPI
traceback2Provides a backport of Python's traceback…
permissive · top 5,000 on PyPI
pickle5Backports the pickle 5 protocol (PEP 574) and…
permissive · top 15,000 on PyPI
weakrefmethodProvides a WeakMethod class for storing bound…
permissive · top 15,000 on PyPI