Passing arguments in python setup.py install_requires list

后端 未结 2 1384
星月不相逢
星月不相逢 2021-01-18 18:53

I have used pip to install PIL. It requires two additional arguments while installation. So the command for installation looks something like this.

pip insta         


        
2条回答
  •  野的像风
    2021-01-18 19:17

    Currently, there is no way to specify extra arguments in install_requires in setup.py. But, I solved my problem of installing dependencies with global-options by sub-classing setuptools.command.install class and overriding its run() method, like following code -

    from setuptools import setup
    from setuptools.command.install import install
    from subprocess import call
    
    
    class CustomInstall(install):
        def run(self):
            install.run(self)
            call(['pip', 'install', 'PIL', '--allow-external', 'PIL', '--allow-unverified', 'PIL'])
    
    setup( ...
          cmdclass={
              'install': CustomInstall,
          },
    )
    

提交回复
热议问题