python - How to avoid overwriting previous package installation with distutils -


i have python package uses distutils. configure setup.py either of following:

  • detect previously-installed version of package , raise error
  • offer remove previously-installed version before proceeding installation

any hints? custom subclass of distutils.command.install needed, documentation bit terse.

ok, here's initial answer. else has better plan. i'm not sure if install.install_libbase correct place or if happens correct on system..

import distutils.command.install  class install(distutils.command.install.install):     def run(self):         name = self.config_vars['dist_name']         if name in os.listdir(self.install_libbase):             raise exception("it appears version of %s "                             "installed @ %s; remove before installing."                              % (name, self.install_libbase))         print("installing %s" % self.install_libbase)         return distutils.command.install.install.run(self)  setup(cmdclass={'install': install}) 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -