Skip to main content

A library for uninstalling packages

Project description

uninstaller

A library for uninstalling python packages. Inverse counterpart of https://github.com/pypa/installer

⚠General Warning⚠

This project uses a bunch of lightly tested logic to decide how to call os.unlink() and os.rmdir() which make changes to your file system that probably can't be undone. I personally think it's safe (if you're okay with the empty folder warning below) and effective, but it comes with no warranty it won't destroy some data you wish it didn't. That said, I wouldn't run it with root permissions at this point.

⚠Empty Folder Warning

This project reads The RECORD file to figure out how to remove a package. The RECORD file does not contain info on which folders were created during installation (only files), so we can't, with 100% certianty, know which folders should be removed when we try to uninstall a package. After removing all the files listed in RECORD, this project will remove all empty folders that were in the chain upwards of where each file in RECORD was. That means it's possible that an empty folder not created at install time will be removed by this tool.

Scope

The design intent here is that this project just undoes what https://github.com/pypa/installer (or a similar tool) does. This uninstaller can't uninstall all packages. A package to be uninstalled must at least have a RECORD file in its .dist-info directory for this to have a chance to work. The uninstall done by this tool can only be as complete and correct as that RECORD file allows for.

Usage

$ python -m uninstaller --help
usage: python -m uninstaller [-h] [--root path] [--base path] [--scheme scheme] [--not-pure-python] [--ignore-checksums] [--ignore-sizes] [--verbose] package [package ...]

uninstall python packages

positional arguments:
  package               name of the package to uninstall

options:
  -h, --help            show this help message and exit
  --root path, -r path  override package search root
  --base path, -b path  override base path (aka prefix)
  --scheme scheme, -s scheme
                        override the default installation scheme
  --not-pure-python, -n
                        you might need to use this if 'Root-is-Purelib' metadata parameter of the package you want to uninstall is false
  --ignore-checksums, -i
                        use this to skip checksum verification ☠️DANGEROUS☠️
  --ignore-sizes, -z    use this to skip file size verification ☠️DANGEROUS☠️
  --verbose, -v         print every file that's removed to stdout

--ignore-sizes and --ignore-checksums are particularly dangerous arguments to use because they bypass validation of files you're about to delete. These switches when paired with a maliciously crafted RECORD file can delete anything your user has the permissions to delete (although they don't completely protect you from a maliciously crafted RECORD file. If you avoid using these, you're pretty safe from a crafted RECORD file because an evil genius would need to know the checksum, size and location of the file(s) they want this tool to delete).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uninstaller-0.0.2.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

uninstaller-0.0.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file uninstaller-0.0.2.tar.gz.

File metadata

  • Download URL: uninstaller-0.0.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for uninstaller-0.0.2.tar.gz
Algorithm Hash digest
SHA256 07df3a9594fb52dc614391ff9a72e49bc3f12b85e6c3ea3c8eabe044fc80c7bd
MD5 c2590beee9f74d7721fb0e63c47a9432
BLAKE2b-256 3d79a360159532452a0e9eb1b204a8d6c7246cee5ca1e555e1e7e638f7f1394c

See more details on using hashes here.

File details

Details for the file uninstaller-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: uninstaller-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for uninstaller-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6023652e1c40da70f45ed3da6f7e6cdba7e847d89e9f5f1ff4e3d54fcd974302
MD5 5466e1d6d0f32c4dec07821b7fe1d176
BLAKE2b-256 37db9ebd4ebcc4eb04f214d6177cccb31f33be39e973acc2f47e43533ac95288

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page