msg77883 - (view) |
Author: Andy Buckley (andybuckley) |
Date: 2008-12-15 22:22 |
When using distutils to build an extension module using SWIG, it makes most sense to use the built-in SWIG support. However, the distutils seem to "vet" the options passed via the Extension.swig_opts attr/arg: [...] ext_modules=[Extension('_hepmc', ['@top_srcdir@/hepmc.i'], swig_opts=['-c++', '-I@HEPMCINCPATH@', '-outdir .'], include_dirs=['@HEPMCINCPATH@'], library_dirs=['@HEPMCLIBPATH@'], libraries=['HepMC'])], [...] results in this error: building '_hepmc' extension swigging ./hepmc.i to ./hepmc_wrap.cpp swig -python -c++ -I/home/andy/heplocal/include -outdir . -o ./hepmc_wrap.cpp ./hepmc.i swig error : Unrecognized option -outdir . Use 'swig -help' for available options. error: command 'swig' failed with exit status 1 but calling the same swig command works fine. It's the same copy of swig, but it seems to be distutils rather than swig that is throwing the error. This is particularly relevant since I need to use -outdir to meet the autotools "distcheck" requirement of successfully building from a build-dir separate from the source dir: code generation tools like SWIG blur such a distinction and so need to support output location flags like -outdir. I see this was also noticed some time ago: http://osdir.com/ml/python.distutils.devel/2006-06/msg00009.html but no useful reply was ever forthcoming ;( Maybe this time will be luckier! |
|
|
msg80430 - (view) |
Author: William Fulton (postofficered) |
Date: 2009-01-24 01:10 |
This error can be replicated on the command line with suitable quoting of the -outdir option: swig -c++ "-outdir ." You need to pass the options correctly by separating them out, so use: swig_opts=['-c++', '-I@HEPMCINCPATH@', '-outdir', '.'] I suggest distutils is fixed to show the quotes it is effectively adding when displaying the command, so for the example Andy gave it should display: swigging ./hepmc.i to ./hepmc_wrap.cpp swig -python -c++ -I/home/andy/heplocal/include "-outdir ." -o ./hepmc_wrap.cpp ./hepmc.i The quotes would need adding for display when a user has a space in any of the options passed to SWIG (including the include_dirs etc). |
|
|
msg80441 - (view) |
Author: Tarek Ziadé (tarek) *  |
Date: 2009-01-24 10:29 |
Good suggestion, I'll add the quotes in the spawn call Which does a simple log.info(string.join(cmd, ' ')) at the moment |
|
|
msg80572 - (view) |
Author: Andy Buckley (andybuckley) |
Date: 2009-01-26 15:54 |
Dumb question, but why is distutils wrapping the command args in quotes anyway? I'm not even sure why lists are being used (rather than a string) for the options, except that lists are a bit more "Pythony" and can be used to semantically divide the options from each other. If you end up having to use separate list elements for the option flag and the value it takes, doesn't that indicate that the list isn't being used properly? |
|
|
msg140031 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2011-07-08 14:37 |
Lists are used because that’s what the UNIX exec call accepts, or the constructor of subprocess.Popen. About using %r in error messages, see also #11599. |
|
|
msg381143 - (view) |
Author: Irit Katriel (iritkatriel) *  |
Date: 2020-11-16 19:17 |
I think this was fixed in 11599. Any objections to closing this? |
|
|