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?

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. Commented Sep 6, 2018 at 20:16

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.