summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-10-27 16:32:12 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2016-10-27 16:32:12 +0200
commit987be16ee8e33f8c4521971bef7d704990753c44 (patch)
treefa8adb8b5135dcae8f82c9394a159185007e205d
parent476eea61feb38e2f2dccfc5adcb24dd883981b07 (diff)
downloadpsutil-987be16ee8e33f8c4521971bef7d704990753c44.tar.gz
winmake: more aggressive logic to uninstall psutil
-rw-r--r--Makefile1
-rwxr-xr-xscripts/internal/winmake.py72
2 files changed, 47 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index f051a97d..3c6343a3 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@ all: test
clean:
rm -rf `find . \
-type f -name \*.pyc \
+ -o -type f -name \*.pyd \
-o -type f -name \*.pyo \
-o -type f -name \*.so \
-o -type f -name \*.~ \
diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py
index 8351a675..714e02d6 100755
--- a/scripts/internal/winmake.py
+++ b/scripts/internal/winmake.py
@@ -23,8 +23,6 @@ import tempfile
import textwrap
-HERE = os.path.abspath(os.path.dirname(__file__))
-ROOT = os.path.abspath(os.path.join(HERE, '../..'))
PYTHON = sys.executable
TSCRIPT = os.environ['TSCRIPT']
GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
@@ -111,7 +109,32 @@ def rm(pattern, directory=False):
safe_remove(path)
+# ===================================================================
+# commands
+# ===================================================================
+
+
+@cmd
+def help():
+ """Print this help"""
+ print('Run "make <target>" where <target> is one of:')
+ for name in sorted(_cmds):
+ print(" %-20s %s" % (name.replace('_', '-'), _cmds[name] or ''))
+
+
+@cmd
+def build():
+ """Build / compile"""
+ sh("%s setup.py build" % PYTHON)
+ # copies compiled *.pyd files in ./psutil directory in order to
+ # allow "import psutil" when using the interactive interpreter
+ # from within this directory.
+ sh("%s setup.py build_ext -i" % PYTHON)
+
+
+@cmd
def install_pip():
+ """Install pip"""
try:
import pip # NOQA
except ImportError:
@@ -139,29 +162,6 @@ def install_pip():
os.remove(tfile)
-# ===================================================================
-# commands
-# ===================================================================
-
-
-@cmd
-def help():
- """Print this help"""
- print('Run "make <target>" where <target> is one of:')
- for name in sorted(_cmds):
- print(" %-20s %s" % (name.replace('_', '-'), _cmds[name] or ''))
-
-
-@cmd
-def build():
- """Build / compile"""
- sh("%s setup.py build" % PYTHON)
- # copies compiled *.pyd files in ./psutil directory in order to
- # allow "import psutil" when using the interactive interpreter
- # from within this directory.
- sh("%s setup.py build_ext -i" % PYTHON)
-
-
@cmd
def install():
"""Install in develop / edit mode"""
@@ -173,9 +173,29 @@ def install():
@cmd
def uninstall():
"""Uninstall psutil"""
+ clean()
+ try:
+ import psutil
+ except ImportError:
+ return
install_pip()
sh("%s -m pip uninstall -y psutil" % PYTHON)
+ # Uninstalling psutil on Windows seems to be tricky as we may have
+ # different versions installed. Also we don't want to be in main
+ # psutil source dir as "import psutil" will always succeed.
+ here = os.getcwd()
+ try:
+ os.chdir('C:\\')
+ while True:
+ try:
+ import psutil # NOQA
+ except ImportError:
+ return
+ sh("%s -m pip uninstall -y psutil" % PYTHON)
+ finally:
+ os.chdir(here)
+
@cmd
def clean():
@@ -191,6 +211,7 @@ def clean():
rm("*.core")
rm("*.orig")
rm("*.pyc")
+ rm("*.pyd")
rm("*.pyo")
rm("*.rej")
rm("*.so")
@@ -294,7 +315,6 @@ def install_git_hooks():
def main():
- os.chdir(ROOT)
try:
cmd = sys.argv[1].replace('-', '_')
except IndexError: