Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getrmpytools: reinstalling the hard way #57

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
51 changes: 46 additions & 5 deletions bin/getrmpytools
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,54 @@ class RMPyToolsSetup(paella.Setup):
def common_last(self):
self.install("git")
if self.reinstall:
self.pip_uninstall("redis redis-py-cluster ramp-packer RLTest")
self.uninstall("redis")
self.uninstall("redis-py-cluster", ["rediscluster", "redis_py_cluster"])
self.uninstall("ramp-packer", ["RAMP", "ramp_packer"])
self.uninstall("rltest", ["RLTest"])
self.uninstall("click", ["Click"])
# redis-py-cluster should be installed from git due to redis-py dependency
# self.pip_install("--no-cache-dir git+https://github.com/Grokzen/redis-py-cluster.git@master")
self.pip_install("--no-cache-dir --ignore-installed git+https://github.com/redisfab/[email protected]")
self.pip_install("--no-cache-dir --ignore-installed redis-py-cluster")
self.pip_install("--no-cache-dir --ignore-installed git+https://github.com/RedisLabsModules/RLTest.git@master")
self.pip_install("--no-cache-dir --ignore-installed git+https://github.com/RedisLabs/RAMP@master")
self.pip_install("--no-cache-dir --ignore-installed git+https://github.com/RedisLabsModules/RLTest.git@rafi-redispy2")
self.pip_install("--no-cache-dir --ignore-installed git+https://github.com/redisfab/[email protected]")
self.pip_install("--no-cache-dir --ignore-installed git+https://github.com/redisfab/[email protected]")

def uninstall(self, package, pack_dirs=[]):
if package not in pack_dirs:
pack_dirs += [package]
base_dirs = sh("{PYTHON} -m pip list -v | grep '^{PACK}\s' | awk '{{print $3}}'".format(PYTHON=self.python, PACK=package)).strip()
n_base_dirs = len(base_dirs.split())
if n_base_dirs == 0:
return
if n_base_dirs > 1:
eprint("cannot determine base python installation dir for '{}'".format(package))
return
base_dir = base_dirs
self.pip_uninstall(package) # this does more damage than good
pack_re_suffixes = ['',
r'\.dist-info',
r'-\d+\.\d+\.\d+',
r'-\d+\.\d+\.\d+\.dist-info',
r'-\d+\.\d+\.\d+\.post\d+',
r'-\d+\.\d+\.\d+\.post\d+\.dist-info',
r'-\d+\.\d+\.\d+\.post\d+',
r'-\d+\.\d+\.\d+\.dev\d+\.dist-info']
with paella.cwd(base_dir):
print("cd {}".format(base_dir))
rm_d = []
for pack_dir in pack_dirs:
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use os.walk, but this works.

dirs = sh("ls -d {DIR}*".format(DIR=pack_dir))
for d in dirs.split():
for re_suff in pack_re_suffixes:
re1 = r'^{DIR}{SUFF}$'.format(DIR=pack_dir, SUFF=re_suff)
if paella.match(re1, d):
rm_d += [d]
break
except:
pass
if rm_d != []:
self.run("rm -rf {DIR}".format(DIR=' '.join(rm_d)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shutil.rmtree(rm_d)

print("cd -")

#----------------------------------------------------------------------------------------------

Expand Down