This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: link_objects in setup.cfg crashes build
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alexis, bru, dstufft, eric.araujo, lambertv, mschatte, python-dev, r.david.murray, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2007-04-18 19:03 by mschatte, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
build_ext.diff lambertv, 2014-10-10 09:42 review
build_ext_v2.patch lambertv, 2014-12-09 21:29 review
Messages (11)
msg31832 - (view) Author: Markus Schatten (mschatte) Date: 2007-04-18 19:03
When I put the following into setup.cfg:

---

[build_ext]
include_dirs = /home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu:/home/mschatte/myPackages/XSB/emu
link_objects = /home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu/saved.o/xsb.o

---

in order to link a c extension to another object which should reside on the users computer, I get the following error (tested on two kubuntu machines, python 2.4):

# python setup.py build
Distribution.parse_config_files():
  reading setup.cfg
options (after parsing config files):
option dict for 'build_ext' command:
  {'include_dirs': ('setup.cfg',
                    '/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu:/home/mschatte/myPackages/XSB/emu'),
   'link_objects': ('setup.cfg',
                    '/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu/saved.o/xsb.o')}
options (after parsing command line):
option dict for 'build' command:
  {}
option dict for 'build_ext' command:
  {'include_dirs': ('setup.cfg',
                    '/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu:/home/mschatte/myPackages/XSB/emu'),
   'link_objects': ('setup.cfg',
                    '/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu/saved.o/xsb.o')}
running build
Distribution.get_command_obj(): creating 'build' command object
running build_py
Distribution.get_command_obj(): creating 'build_py' command object
creating build
creating build/lib.linux-i686-2.4
copying dbms.py -> build/lib.linux-i686-2.4
copying __init__.py -> build/lib.linux-i686-2.4
copying f.py -> build/lib.linux-i686-2.4
copying interface.py -> build/lib.linux-i686-2.4
copying py2f.py -> build/lib.linux-i686-2.4
copying reasonable.py -> build/lib.linux-i686-2.4
creating build/lib.linux-i686-2.4/xsb_swig
copying xsb_swig/__init__.py -> build/lib.linux-i686-2.4/xsb_swig
copying xsb_swig/xsb.py -> build/lib.linux-i686-2.4/xsb_swig
running build_ext
Distribution.get_command_obj(): creating 'build_ext' command object
  setting options for 'build_ext' command:
    link_objects = /home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu/saved.o/xsb.o (from setup.cfg)
    include_dirs = /home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu:/home/mschatte/myPackages/XSB/emu (from setup.cfg)
building 'xsb_swig._xsb' extension
creating build/temp.linux-i686-2.4
creating build/temp.linux-i686-2.4/xsb_swig
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes -fPIC -I/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu -I/home/mschatte/myPackages/XSB/emu -I/usr/include/python2.4 -c xsb_swig/swig_xsb_wrap.c -o build/temp.linux-i686-2.4/xsb_swig/swig_xsb_wrap.o
In file included from xsb_swig/swig_xsb.h:25,
                 from xsb_swig/swig_xsb_wrap.c:2346:
/home/mschatte/myPackages/XSB/emu/cinterf.h:259: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:262: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:285: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:286: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:294: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:296: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:300: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:304: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:305: warning: function declaration isn’t a prototype
In file included from xsb_swig/swig_xsb_wrap.c:2346:
xsb_swig/swig_xsb.h:101: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:135: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:137: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:141: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:145: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:146: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb_wrap.c:2498: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb_wrap.c:5124: warning: function declaration isn’t a prototype
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes -fPIC -I/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu -I/home/mschatte/myPackages/XSB/emu -I/usr/include/python2.4 -c xsb_swig/swig_xsb.c -o build/temp.linux-i686-2.4/xsb_swig/swig_xsb.o
In file included from xsb_swig/swig_xsb.h:25,
                 from xsb_swig/swig_xsb.c:28:
/home/mschatte/myPackages/XSB/emu/cinterf.h:259: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:262: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:285: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:286: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:294: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:296: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:300: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:304: warning: function declaration isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:305: warning: function declaration isn’t a prototype
In file included from xsb_swig/swig_xsb.c:28:
xsb_swig/swig_xsb.h:101: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:135: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:137: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:141: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:145: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:146: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.c: In function ‘intpointer’:
xsb_swig/swig_xsb.c:84: warning: function returns address of local variable
xsb_swig/swig_xsb.c: At top level:
xsb_swig/swig_xsb.c:140: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.c:174: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.c:176: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.c:180: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.c:184: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.c:185: warning: function declaration isn’t a prototype
Traceback (most recent call last):
  File "setup.py", line 11, in ?
    [ "xsb_swig/swig_xsb_wrap.c", "xsb_swig/swig_xsb.c" ]
  File "distutils/core.py", line 149, in setup
  File "distutils/dist.py", line 946, in run_commands
  File "distutils/dist.py", line 966, in run_command
  File "distutils/command/build.py", line 112, in run
  File "/usr/lib/python2.4/cmd.py", line 333, in run_command
    del help[cmd]
  File "distutils/dist.py", line 966, in run_command
  File "distutils/command/build_ext.py", line 279, in run
  File "distutils/command/build_ext.py", line 405, in build_extensions
  File "distutils/command/build_ext.py", line 502, in build_extension
  File "distutils/ccompiler.py", line 847, in link_shared_object
  File "distutils/unixccompiler.py", line 211, in link
TypeError: can only concatenate list (not "str") to list

---

maybe it isn't a bug, but link_objects is not well documented, so I wasn't able to find the appropriate syntax for setup.cfg

Best regards,

--
Markus Schatten, dipl. inf.
e-mail: markus.schatten@foi.hr
Faculty of Organization and Informatics
Varaždin, Croatia
msg113017 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-05 19:10
Is there still a problem with 2.7 or 3.x?
msg158948 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-04-22 05:53
The code in build_ext is missing a few ensure_string_list calls; it is a method that converts a string (from the setup.cfg file or command line) into a list, or if the attribute is already a list (if it was given in setup.py) then leave it alone.  Recently I fixed the same bug with the build_ext --libraries option (#1326113), so it’s easy to make a patch with the same kind of tests and the code fix.
msg228973 - (view) Author: Valerie Lambert (lambertv) * Date: 2014-10-10 09:42
Here is a simple one-line-fix patch with a test. 

Except for the libraries option, other options separate using ':'. The documentation didn't seem to say much, so I wasn't sure if link_objects should be consistent with that or if it should follow libraries's example and instead allow spaces and commas for separation. This patch uses ensure_string_list as suggested, but let me know if using .split(os.pathsep) is a better idea.
msg229009 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-10 15:12
Valerie, I cannot review this.  If Éric does not respond in a month or two, you might enquire on python-dev or core-mentorship lists.
msg232331 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-12-08 21:47
Donald, can you look at this one-line patch?  Éric has not responded.
msg232333 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-12-08 22:20
Thanks for the patch.  It looks good to me.
msg232357 - (view) Author: Bruno Cauet (bru) * Date: 2014-12-09 08:59
There's a small typo in the comments:

+        # make sure cmd.link_objects is turned into a list
+        # is it's a string

Should be:

+        # make sure cmd.link_objects is turned into a list
+        # if it's a string
msg232401 - (view) Author: Valerie Lambert (lambertv) * Date: 2014-12-09 21:29
Fixed the typo and reuploaded. Thanks for spotting that!
msg233092 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-12-25 02:40
This issue is marked for 2.7, 3.4, and 3.5, but the test runs only on 3.5.
msg277684 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-29 06:17
New changeset 520ca3652422 by Benjamin Peterson in branch '2.7':
build_ext: correctly parse the link_objects user option (closes #1703178)
https://hg.python.org/cpython/rev/520ca3652422

New changeset b2f0a31fa441 by Benjamin Peterson in branch '3.5':
build_ext: correctly parse the link_objects user option (closes #1703178)
https://hg.python.org/cpython/rev/b2f0a31fa441

New changeset eac20127d51e by Benjamin Peterson in branch '3.6':
merge 3.5 (#1703178)
https://hg.python.org/cpython/rev/eac20127d51e

New changeset 9485165435e4 by Benjamin Peterson in branch 'default':
merge 3.6 (#1703178)
https://hg.python.org/cpython/rev/9485165435e4
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44861
2019-01-10 22:15:03cheryl.sabellalinkissue26239 superseder
2016-09-29 06:17:26python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg277684

resolution: fixed
stage: patch review -> resolved
2014-12-25 02:40:32r.david.murraysetnosy: + r.david.murray
messages: + msg233092

assignee: eric.araujo
stage: commit review -> patch review
2014-12-09 22:07:32berker.peksagsetstage: patch review -> commit review
2014-12-09 21:29:46lambertvsetfiles: + build_ext_v2.patch

messages: + msg232401
2014-12-09 08:59:42brusetnosy: + bru
messages: + msg232357
2014-12-08 22:20:08eric.araujosetassignee: eric.araujo -> (no value)
messages: + msg232333
2014-12-08 21:47:13terry.reedysetnosy: + terry.reedy, dstufft, - tarek
messages: + msg232331
2014-10-10 15:13:14terry.reedysetnosy: - terry.reedy
2014-10-10 15:12:29terry.reedysetnosy: terry.reedy, mschatte, tarek, eric.araujo, alexis, lambertv
versions: + Python 3.5, - Python 3.3
messages: + msg229009
stage: test needed -> patch review
2014-10-10 09:42:17lambertvsetfiles: + build_ext.diff

nosy: + lambertv
messages: + msg228973

keywords: + patch
2014-03-12 10:18:04eric.araujosetcomponents: - Distutils2
versions: + Python 3.4, - 3rd party, Python 3.2
2012-04-22 05:53:02eric.araujosetstatus: pending -> open

assignee: tarek -> eric.araujo
components: + Distutils2, - Build
versions: + 3rd party, Python 3.2, Python 3.3
keywords: + easy
nosy: + eric.araujo, alexis

messages: + msg158948
2010-08-05 19:10:23terry.reedysetstatus: open -> pending
versions: + Python 2.7, - Python 2.6, Python 3.0
nosy: + terry.reedy

messages: + msg113017
2009-03-30 16:49:31ajaksu2setnosy: + tarek
versions: + Python 2.6, Python 3.0, - Python 2.4
assignee: tarek
components: + Build, Distutils, - None
type: behavior
stage: test needed
2007-04-18 19:03:11mschattecreate