diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-02 17:25:19 -0800 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-02 17:25:19 -0800 |
commit | 004f330aedaad5739457322487cdab0323ba7af1 (patch) | |
tree | 6672e1cd2410d94c25ff1f7fb85d5089e82d91b3 | |
parent | ad620104e778642e8a1fa5a5d725283baf376b55 (diff) | |
download | psutil-004f330aedaad5739457322487cdab0323ba7af1.tar.gz |
winmake / uninstall: remove installation path from easy-install.pth file
-rwxr-xr-x | scripts/internal/winmake.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index ce6b5a83..2ddc1707 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -350,6 +350,24 @@ def uninstall(): for name in os.listdir(dir): if name.startswith('psutil'): rm(os.path.join(dir, name)) + elif name == 'easy-install.pth': + # easy_install can add a line (installation path) into + # easy-install.pth; that line alters sys.path. + path = os.path.join(dir, name) + with open(path, 'rt') as f: + lines = f.readlines() + hasit = False + for line in lines: + if 'psutil' in line: + hasit = True + break + if hasit: + with open(path, 'wt') as f: + for line in lines: + if 'psutil' not in line: + f.write(line) + else: + print("removed line %r from %r" % (line, path)) @cmd |