You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: 'Completely uninstalls all pip packages in the current Python environment, including editable (-e) installations. Includes verification that the environment is clean afterward.'
4
+
runs:
5
+
using: 'composite'
6
+
steps:
7
+
- name: Uninstall all pip packages
8
+
shell: bash
9
+
run: |
10
+
#!/bin/bash
11
+
set -euo pipefail
12
+
13
+
echo "Listing installed packages before uninstallation..."
14
+
pip freeze
15
+
16
+
# Extract package names:
17
+
# - For editable installs: capture the egg name (e.g., 'apio' from #egg=apio)
18
+
# - For normal installs: strip the version part
19
+
# - sort -u removes potential duplicates
20
+
package_list=$(pip freeze \
21
+
| sed -E 's/^-e .*#egg=([^-]+).*/\1/; s/==.*$//' \
22
+
| sort -u)
23
+
24
+
if [ -z "$package_list" ]; then
25
+
echo "No packages found to uninstall."
26
+
else
27
+
echo "Uninstalling the following packages:"
28
+
echo "$package_list"
29
+
# Use process substitution to feed the list as a "requirements file"
30
+
pip uninstall -y -r <(echo "$package_list")
31
+
fi
32
+
33
+
echo "Verifying that no packages remain..."
34
+
output=$(pip freeze)
35
+
36
+
if [ -z "$output" ]; then
37
+
echo "Assertion passed: pip freeze is empty. All packages successfully uninstalled."
0 commit comments