Title: distutils.core.Extension: empty strings in library_dirs and include_dirs should not be allowed
Type: behavior Stage: resolved
Components: Distutils Versions: Python 2.7
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, jaraco, robotron
Priority: normal Keywords:

Created on 2013-10-25 18:00 by robotron, last changed 2020-10-23 03:55 by eric.araujo. This issue is now closed.

File name Uploaded Description Edit robotron, 2013-10-25 18:00
Messages (3)
msg201269 - (view) Author: (robotron) Date: 2013-10-25 18:00
When empty string element is passed in include_dirs or library_dirs (e.g. include_dirs = [""]) param of distutils.core.Extension constructor, it is propagated to compiler/linker params and in the case of gcc it eats subsequent command line option. excerpt:

extensions = [
    Extension("test_extension", ["test_extension.cpp"],
        include_dirs = [""],
        libraries = ["rt"],
        library_dirs = [""],

$ python build
gcc ... -I -I/usr/include/python2.7 -c test_extension.cpp ...

Standard include dir "/usr/include/python2.7" is ommited now. The same is valid for library_dirs.

Example scripts attached.
msg213216 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-12 08:22
Thanks for the report.  What fix do you suggest?  Printing an error if empty strings are passed for include/library_dirs?
msg379404 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2020-10-23 03:55
distutils isn’t improved anymore.
Date User Action Args
2020-10-23 03:55:35eric.araujosetstatus: open -> closed
nosy: + jaraco, - tarek
messages: + msg379404

assignee: eric.araujo ->
resolution: wont fix
stage: resolved
2014-03-12 08:22:14eric.araujosetmessages: + msg213216
2013-10-25 18:00:28robotroncreate