Reputation: 4305
I am trying to make a system-wide installation of my Python module with setuptools.
Let's say I have a file that has to have different content depending on whether I install in production or development environment.
One way I think I found, is from Post-install script with Python setuptools . As far as I understand, I could make some additional post-install actions and in them copy the correct version of the file depending on whether it is devel or install, however, how do I know from within the method, which directories to use for source and dest?
Upvotes: 3
Views: 174
Reputation: 22295
how do I know from within the method, which directories to use for source and dest?
This is not really well documented. You will have to read some of distutils
and setuptools
code. I believe the destination for the develop
should be self.install_dir
and self.install_lib
for the install
command. For the source, I believe it should be good enough to assume a path relative to the location of your setup.py
script.
Something like this (untested):
class develop(setuptools.command.develop.develop):
def run(self):
super().run(self)
self.copy_file('src/package/develop.bin', self.install_dir + 'package/data.bin')
class install(setuptools.command.install.install):
def run(self):
super().run(self)
self.copy_file('src/package/install.bin', self.install_lib + 'package/data.bin')
Upvotes: 1