How to Pass --Debug to Build_Ext When Invoking Setup. Py Install?
When I Execute a Command Python Setup. Py Install or Python Setup. Py Develop It Would Execute Build_Ext Command as One of the Steps. How Can I Pass --Debug...
When I execute a command python setup.py install or python setup.py develop it would execute build_ext command as one of the steps. How can I pass --debug option to it as if it was invoked as python setup.py build_ext --debug?
UPDATE
Here is a setup.py very similar to mine:
I'd like to invoke python setup.py install but turn debug property in build_ext class instance to 1.
2 Answers
A. If I am not mistaken, one could achieve that by adding the following to a setup.cfg file alongside the setup.py file:
[build_ext]
debug = 1
B.1. For more flexibility, I believe it should be possible to be explicit on the command line:
$ path/to/pythonX.Y setup.py build_ext --debug install
B.2. Also if I understood right it should be possible to define so-called aliases
# setup.cfg
[aliases]
release_install = build_ext install
debug_install = build_ext --debug install
$ path/to/pythonX.Y setup.py release_install
$ path/to/pythonX.Y setup.py debug_install
References
You can use something like below to do it
from distutils.core import setup
from distutils.command.install import install
from distutils.command.build_ext import build_ext
class InstallLocalPackage(install):
def run(self):
build_ext_command = self.distribution.get_command_obj("build_ext")
build_ext_command.debug = 1
build_ext.run(build_ext_command)
install.run(self)
setup(
name='psetup',
version='1.0.1',
packages=[''],
url='',
license='',
author='tarunlalwani',
author_email='',
description='',
cmdclass={
'install': InstallLocalPackage
}
)