How to include post install script in python setuptools
Asked Answered
P

1

8
import os
from setuptools import setup
from distutils.command.install import install as _install
def _post_install(dir):
    from subprocess import call
    call([sys.executable, 'post_script.py'],
    cwd=os.path.join(dir, 'script_folder'))


class install(_install):
    def run(self):
        _install.run(self)
        self.execute(_post_install, (self.install_lib,),
                     msg="Running post install task")


VERSION = '123'
setup(name='XXXX',
      description='hello',
      url='http://giturl.com',
      packages=['package_folder'],
      cmdclass={'install': install},
      package_data={
              'package_folder': [
              '*.py',
              'se/*pp'
          ],
      },
)

# Basically the postscript should execute once I install the rpm that is being built. Its not working. Any other method as this is not working?

Pleurodynia answered 10/3, 2016 at 2:3 Comment(1)
If the answer helped you solve the problem, you should come back to upvote/acept it. Otherwise, leave a comment on why the answer was not applicable or how it could be improved.Philomenaphiloo
R
8

You can run python setup.py bdist_rpm --post-install=<script name> This will create an rpm which will run the contents of the script you provide after the normal rpm installation is completed.

If you want to do it in your setup.py you can pass along

setup( 
    ... 
    options={'bdist_rpm': {'post_install': '<post_install script name>'}},
    ... 
)

This will only affect bdist_rpm, and thus only the rpm you create with python setup.py bdist_rpm

Rejuvenate answered 17/5, 2016 at 9:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.