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
Post a Comment