--- id: python-hosts version: "1.1.2" license: MIT license_treatment: permissive maintenance: aging --- # python-hosts — A hosts file manager library written in python License: permissive · Maintenance: aging · Downloads: 184.1K/mo ## What it is and what it does python-hosts is a library for programmatic manipulation of the system hosts file. It lets you create, add, remove, and query hostname-to-IP mappings without manually editing the file, and supports importing entries from files or URLs. The library has no runtime dependencies and works as a pure Python module. It's designed for system administrators and automation scripts that need to manage network hostname resolution at the OS level. You instantiate a Hosts object pointing to a hosts file, manipulate entries using HostsEntry objects, and write changes back to disk. The package remains compatible with Python 2.7 and modern Python 3 releases, though it has not seen a release in over a year. Use it for: - Automate adding or removing hostname entries in CI/CD pipelines or deployment scripts. - Bulk import hosts from a remote URL or file to synchronize local DNS resolution. - Query the hosts file programmatically to check if a hostname or IP already exists before making changes. - Merge new hostname aliases with existing entries without overwriting the entire hosts file. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Manages hosts file entries programmatically—add, remove, import, and query IP-to-hostname mappings without manual file editing. Yes, if you need programmatic hosts file management. The package is stable (Production/Stable status), has no dependencies, and carries a permissive MIT license. However, the aging maintenance status (416 days since last release) means you should verify compatibility with your Python version before relying on it for critical automation. ## Install pip install python-hosts uv add python-hosts poetry add python-hosts ## Installing python-hosts Before you install: Low install friction with no runtime dependencies. Maintenance status is aging—last release was 416 days ago, though the repository remains active with a recent commit on 2025-08-11. License in practice: MIT license (permissive) means you can use, modify, and distribute this package freely with minimal restrictions. Quickstart: pip install python-hosts from python_hosts import Hosts, HostsEntry hosts = Hosts(path='hosts_test') entry = HostsEntry(entry_type='ipv4', address='1.2.3.4', names=['www.example.com']) hosts.add([entry]) hosts.write() Verify before relying: - Whether the package still works reliably on modern Python 3 versions given the aging maintenance status and lack of explicit requires_python specification. ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: aging - Downloads: 184.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags hosts file management, add remove hosts entries, hosts file parser, network hostname mapping, hosts file automation, system-administration, network-configuration [View on SkillFed](https://skillfed.io/packages/python-hosts) · [View on PyPI](https://pypi.org/project/python-hosts/)