skillfed

backports.tempfile

Backport of new features in Python's tempfile module

backports-tempfile v1.0 1.2M downloads/30d#4,188 on PyPI5
Permissive license Python Software Foundation License Abandoned released

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-tempfile

uv

uv add backports-tempfile

poetry

poetry add backports-tempfile

Installing 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

Development Status :: 6 - MatureIntended Audience :: DevelopersLicense :: OSI Approved :: Python Software Foundation LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

temporary directory context managerbackport tempfile python 2.7TemporaryDirectory older pythontemporary file handlingpython 2 tempfile backport
legacy-supportpython-2

More Python Modules packages