Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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: https://github.com/pybind/cmake_example/blob/11a644072b12ad78352b6e6649db9dfe7f406676/setup.py#L43

I'd like to invoke python setup.py install but turn debug property in build_ext class instance to 1.

like image 459
Gill Bates Avatar asked May 09 '20 06:05

Gill Bates


People also ask

How do I run Python setup py?

To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

Does pip install call setup py?

pip is a package manager, which can install, upgrade, list and uninstall packages, like familiar package managers including: dpkg, apt, yum, urpmi, ports etc. Under the hood, it will run python setup.py install , but with specific options to control how and where things end up installed. In summary: use pip .

What is Package_dir in setup py?

package_dir = {'': 'lib'} in your setup script. The keys to this dictionary are package names, and an empty package name stands for the root package. The values are directory names relative to your distribution root.


1 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

  • https://docs.python.org/3/distutils/configfile.html
  • https://setuptools.readthedocs.io/en/latest/setuptools.html#alias-define-shortcuts-for-commonly-used-commands
like image 99
sinoroc Avatar answered Oct 25 '22 15:10

sinoroc