1

How to add a cron job inside setup.py using the post installation commands (the cmdclass parameter).
The cron job will use the newly installed library to call a specific function from the library.

Drxxd
  • 1,860
  • 14
  • 34

1 Answers1

0

Your question is really vague, but you could do it if you wrote out a temp script somewhere to import said library and do whatever things you require, then write out a crontab to run a command such as:

py -<python version> <python script>

Some additional Python-specific info on cron jobs can be found in this question which may be good to read, just in case.

To actually DO this, you'd add something like this to your setup.py:

from setuptools import setup
from setuptools.command.install import install
class PostInstallCommand(install):
    def run(self):
        # PUT YOUR POST-INSTALL SCRIPT HERE or CALL A FUNCTION
        install.run(self)

You'd also need to add this to your setup() func:

setup(
    ...

    cmdclass={
        'install': PostInstallCommand,
    },

    ...
)

Source for this info.