<div dir="ltr">I have this script (setup.py):<br><br>import os<br>import sys<br>import shutil<br>from argparse import ArgumentParser<br><br>if os.getuid() != 0:<br> sys.exit("can't proceed, sudo privileges needed")<br>
<br><br>installManto = '/usr/share/man/man1/'<br>installBinTo = '/usr/local/bin/'<br>capsLoc = '/usr/local/bin/myapp'<br>mansLoc = '/usr/share/man/man1/mymanpage.1.gz'<br><br><br>def install():<br>
shutil.copy2('doc/mymanpage.1.gz', installManto)<br> shutil.copy2('myapp', installBinTo)<br><br><br>def uninstall():<br> os.remove(capsLoc)<br> os.remove(mansLoc)<br><br><br>def update():<br>
uninstall()<br>
install()<br><br><br>parser = ArgumentParser(<br> prog='setup.py',<br> description='installer for myapp',<br> )<br><br>parser.add_argument(<br> 'install',<br> nargs='?',<br>
help='install myapp'<br> )<br><br>parser.add_argument(<br> 'uninstall',<br> nargs='?',<br> help='uninstall myapp'<br> )<br><br>args = parser.parse_args()<br><br>if args.install:<br>
if os.path.isfile(capsLoc) or os.path.isfile(mansLoc):<br> print("The files exists, getting ready to update.")<br> update()<br> else:<br> print("Running the initial setup...")<br>
install()<br>elif args.uninstall:<br> print("Uninstalling..")<br> uninstall()<br>else:<br> parser.print_help()<br clear="all"><div><br><br></div><div>Here is what happens:<br><br></div><div>1. I can copy the <i>myapp</i> and <i>mymanpage.1.gz</i> to their appropriate locations with <b>sudo python setup.py install</b>. This is what I expected, their is no problem upto here. <br>
<br></div><div>2. Running<b> python setup.py uninstall</b> <i>copies</i> the files instead of removing them.<br><br>3. Running <b> python setup.py uninstall </b>when installed <i>updates</i> the files instead of removing them.<br>
<br>So what's the problem? What is the fix? Any further tips for me?<br></div><div>-- <br><div dir="ltr"><span style="font-family:arial,helvetica,sans-serif"><a href="https://twitter.com/sntshk" target="_blank">Twitter</a> | <span style="color:rgb(153,153,153)"><a href="https://github.com/santosh" target="_blank">Github</a></span></span><br>
</div>
</div></div>