classification
Title: Letting "build_ext --libraries" take more than one lib
Type: behavior Stage: test needed
Components: Distutils, Distutils2 Versions: Python 3.2, Python 3.1, Python 2.7, 3rd party
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: christian.heimes, eric.araujo, palm.kevin, pitrou, slanger, tarek
Priority: normal Keywords: patch

Created on 2005-10-13 19:07 by slanger, last changed 2010-11-16 03:40 by eric.araujo.

Files
File name Uploaded Description Edit
build_ext.diff slanger, 2005-10-13 19:07 patch for build_ext.py
Messages (8)
msg48863 - (view) Author: Stephen A. Langer (slanger) Date: 2005-10-13 19:07
It's impossible to specify more than one external library to link using 
build_ext --libraries.  Bug 716634 says that the problem is fixed, but it isn't.    
Assuming that the desired format is --libraries="lib1 lib2 etc", then there's a 
simple one line fix which I've attached. 

The problem exists in python 2.3.5, 2.4.1, 2.4.2 and in cvs HEAD. 
msg59315 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-05 19:40
Another bug day task
msg121221 - (view) Author: Palm Kevin (palm.kevin) Date: 2010-11-15 11:17
This one is really annoying. Could you please consider fixing this one for the next release? (=lightweight change)
msg121223 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-11-15 11:37
Distutils is frozen and we fix only bugs. This case is a little bit at the edge. 

Can you show us an example of a call you are trying to make, and the gcc command line output that fails ? 

I want to see if we can find a workaround. If so, this will be changed only in Distutils2. If not I'll change this to a bug and we'll fix it in distutils too.
msg121225 - (view) Author: Palm Kevin (palm.kevin) Date: 2010-11-15 12:31
I applied the patch proposed by slanger. This one is working.
Now, I'm executing this instruction to build my extension:
"%pythonRoot%\python.exe" setup.py build_ext --include-dirs "C:\MyApp\include" --library-dir "C:\MyApp\lib" --libraries "myLib1 myLib2"
If I don't use the patch, then the error I get is 'unresolved external symbol _xxx referenced in function _abc'. Which is quite normal since I can only point to one library...
msg121236 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-11-15 16:26
Since "--libraries" is plural, and since the help text says:

--libraries (-l)     external C libraries to link with

it should IMO be considered a bug.

(Standard UNIX linkers have a different convention: you can specify -l several times in order to link against several libraries; however, distutils seems to ignore all but the last -l option)
msg121260 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-16 03:08
I agree this is a bug: it’s a broken feature, not a new one, even if it can be argued that fixing a long-standing behavior enables new usages, and is thus comparable to a new feature.

I found no mention of --libraries in the docs, so I looked at the file history, and it’s clear that the intent of the code does not match its behavior.  The fix is simple:

-        if isinstance(self.libraries, str):
-            self.libraries = [self.libraries]
+        self.ensure_string_list('libraries')

I guess Greg forgot to change that line of code when he invented the ensure_* methods.  No test is broken by this change.  Do we need a regression test for this?  It’s not strictly required IMO.

FTR, in distutils2, I want to make the types and formats clear for everything.  For example, build_ext.swig_opts is defined as “a list” in the current docs, this time with an example that shows it’s space-separated (“--swig-opts="-modern -I../include"”).  The code does not use ensure_string_list, and hence does not support comma-separated.  IMO, any value described as list should accept space-separated and comma-separated.  This is probably out of scope for distutils, but something I definitely want to improve in distutils2.  Supporting multiple options (-lm -lfoo) is IMO feasible too.
msg121262 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-16 03:40
I’ve reviewed other modules for the same error and found two candidates: config.libraries, the same thing as build_ext.libraries, and install.extra_path, for which I’m not sure.

(More distutils2 thoughts: A number of options are split on os.pathsep, a new ensure_dirs_list method looks in order.  Regarding the type system, an angry comment in build_py confirmed the need :)
History
Date User Action Args
2010-11-16 03:40:50eric.araujosetmessages: + msg121262
2010-11-16 03:08:31eric.araujosetversions: + 3rd party, Python 3.1, Python 2.7
nosy: slanger, pitrou, christian.heimes, tarek, eric.araujo, palm.kevin
messages: + msg121260

assignee: tarek -> eric.araujo
components: + Distutils2
type: enhancement -> behavior
stage: test needed
2010-11-16 02:23:25eric.araujolinkissue716634 superseder
2010-11-15 16:26:21pitrousetnosy: + pitrou, eric.araujo
messages: + msg121236
2010-11-15 12:31:26palm.kevinsetmessages: + msg121225
2010-11-15 11:37:37tareksetmessages: + msg121223
2010-11-15 11:17:01palm.kevinsetnosy: + palm.kevin
messages: + msg121221
2010-07-10 22:56:48terry.reedysetversions: + Python 3.2, - Python 2.6, Python 3.0, Python 3.1, Python 2.7
2009-02-08 19:32:41tareksetassignee: tarek
versions: + Python 3.0, Python 3.1, Python 2.7
2009-02-08 18:57:48akitadasetnosy: + tarek
type: enhancement
2008-01-05 19:40:31christian.heimessetnosy: + christian.heimes
messages: + msg59315
versions: + Python 2.6
2005-10-13 19:07:43slangercreate