-
-
Notifications
You must be signed in to change notification settings - Fork 330
Missing tool leads to strange error messages #1671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I just ran into this issue with SCons v3.0.1 and the swig builder. When swig is not installed on the system then building an swig module for python leads to the following strange error message:
|
Any chance you can provide a simple test to reproduce? |
Sure, here you go: # -*- coding: utf-8 -*-
import subprocess
py_env = Environment()
py3_incl_dir = subprocess.check_output(
"python3 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())'",
shell=True
).replace('\n', '')
py_env.Append(CPPPATH=[py3_incl_dir], SWIGFLAGS=['-python'])
py_env["SHLIBPREFIX"] = ""
py_env.SharedLibrary("_test.so", ["test.i", "test.c"]) test.c int triple_it(int input) { return input * 3; } test.i %module test
%{
int triple_it(int input);
%}
int triple_it(int input); Without swig being installed, I get the following error: $ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test.os -c -fPIC -I/usr/include/python3.6m test.c
scons: *** [_test.so] Source file: test.i is static and is not compatible with shared target: _test.so
scons: building terminated because of errors. With swig installed, everything works as expected: $ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
swig -o test_wrap.c -python test.i
gcc -o test_wrap.os -c -fPIC -I/usr/include/python3.6m test_wrap.c
gcc -o test.os -c -fPIC -I/usr/include/python3.6m test.c
gcc -o _test.so -shared test_wrap.os test.os
scons: done building targets.
$ python3
Python 3.6.5 (default, Apr 4 2018, 15:01:18)
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
>>> test.triple_it(1)
3 Tested on Fedora 27 with the Python 2 version of SCons: $ scons --version
SCons by Steven Knight et al.:
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine path: ['/usr/lib/python2.7/site-packages/SCons']
Copyright (c) 2001 - 2017 The SCons Foundation |
Wouldn't you expect that test.i would generate test.c?
…On Mon, May 14, 2018 at 5:37 PM, D4N ***@***.***> wrote:
Sure, here you go:
SConstruct
# -*- coding: utf-8 -*-
import subprocess
py_env = Environment()
py3_incl_dir = subprocess.check_output(
"python3 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())'",
shell=True
).replace('\n', '')
py_env.Append(CPPPATH=[py3_incl_dir], SWIGFLAGS=['-python'])
py_env["SHLIBPREFIX"] = ""
py_env.SharedLibrary("_test.so", ["test.i", "test.c"])
test.c
int triple_it(int input) { return input * 3; }
test.i
%module test
%{
int triple_it(int input);
%}
int triple_it(int input);
Without swig being installed, I get the following error:
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test.os -c -fPIC -I/usr/include/python3.6m test.c
scons: *** [_test.so] Source file: test.i is static and is not compatible with shared target: _test.so
scons: building terminated because of errors.
With swig installed, everything works as expected:
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
swig -o test_wrap.c -python test.i
gcc -o test_wrap.os -c -fPIC -I/usr/include/python3.6m test_wrap.c
gcc -o test.os -c -fPIC -I/usr/include/python3.6m test.c
gcc -o _test.so -shared test_wrap.os test.os
scons: done building targets.
$ python3
Python 3.6.5 (default, Apr 4 2018, 15:01:18)
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
>>> test.triple_it(1)
3
Tested on Fedora 27 with the Python 2 version of SCons:
SCons by Steven Knight et al.:
script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14 13:16:53, by bdbaddog on hpmicrodog
engine path: ['/usr/lib/python2.7/site-packages/SCons']
Copyright (c) 2001 - 2017 The SCons Foundation
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1671 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFBNB77Xg6OnYZc6kzh_LN1eu9p1pJwks5tyfkEgaJpZM4RQhUZ>
.
|
Can you paste the output of:
scons --tree=prune
On Mon, May 14, 2018 at 6:40 PM, Bill Deegan <bill@baddogconsulting.com>
wrote:
… Wouldn't you expect that test.i would generate test.c?
On Mon, May 14, 2018 at 5:37 PM, D4N ***@***.***> wrote:
> Sure, here you go:
> SConstruct
>
> # -*- coding: utf-8 -*-
> import subprocess
>
>
> py_env = Environment()
>
> py3_incl_dir = subprocess.check_output(
> "python3 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())'",
> shell=True
> ).replace('\n', '')
>
> py_env.Append(CPPPATH=[py3_incl_dir], SWIGFLAGS=['-python'])
> py_env["SHLIBPREFIX"] = ""
>
> py_env.SharedLibrary("_test.so", ["test.i", "test.c"])
>
> test.c
>
> int triple_it(int input) { return input * 3; }
>
> test.i
>
> %module test
> %{
> int triple_it(int input);
> %}
> int triple_it(int input);
>
> Without swig being installed, I get the following error:
>
> $ scons
> scons: Reading SConscript files ...
> scons: done reading SConscript files.
> scons: Building targets ...
> gcc -o test.os -c -fPIC -I/usr/include/python3.6m test.c
> scons: *** [_test.so] Source file: test.i is static and is not compatible with shared target: _test.so
> scons: building terminated because of errors.
>
> With swig installed, everything works as expected:
>
> $ scons
> scons: Reading SConscript files ...
> scons: done reading SConscript files.
> scons: Building targets ...
> swig -o test_wrap.c -python test.i
> gcc -o test_wrap.os -c -fPIC -I/usr/include/python3.6m test_wrap.c
> gcc -o test.os -c -fPIC -I/usr/include/python3.6m test.c
> gcc -o _test.so -shared test_wrap.os test.os
> scons: done building targets.
> $ python3
> Python 3.6.5 (default, Apr 4 2018, 15:01:18)
> [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import test
> >>> test.triple_it(1)
> 3
>
> Tested on Fedora 27 with the Python 2 version of SCons:
>
> SCons by Steven Knight et al.:
> script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14 13:16:53, by bdbaddog on hpmicrodog
> engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14 13:16:53, by bdbaddog on hpmicrodog
> engine path: ['/usr/lib/python2.7/site-packages/SCons']
> Copyright (c) 2001 - 2017 The SCons Foundation
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#1671 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAFBNB77Xg6OnYZc6kzh_LN1eu9p1pJwks5tyfkEgaJpZM4RQhUZ>
> .
>
|
I think it creates a The output with swig installed: $ scons --tree=prune
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
swig -o test_wrap.c -python test.i
gcc -o test_wrap.os -c -fPIC -I/usr/include/python3.6m test_wrap.c
gcc -o test.os -c -fPIC -I/usr/include/python3.6m test.c
gcc -o _test.so -shared test_wrap.os test.os
+-.
+-SConstruct
+-_test.so
| +-test_wrap.os
| | +-test_wrap.c
| | | +-test.i
| | | +-/bin/swig
| | +-/usr/include/python3.6m/Python.h
| | +-/usr/include/python3.6m/abstract.h
| | +-/usr/include/python3.6m/bltinmodule.h
| | +-/usr/include/python3.6m/boolobject.h
| | +-/usr/include/python3.6m/bytearrayobject.h
| | +-/usr/include/python3.6m/bytesobject.h
| | +-/usr/include/python3.6m/cellobject.h
| | +-/usr/include/python3.6m/ceval.h
| | +-/usr/include/python3.6m/classobject.h
| | +-/usr/include/python3.6m/codecs.h
| | +-/usr/include/python3.6m/compile.h
| | +-/usr/include/python3.6m/complexobject.h
| | +-/usr/include/python3.6m/descrobject.h
| | +-/usr/include/python3.6m/dictobject.h
| | +-/usr/include/python3.6m/dtoa.h
| | +-/usr/include/python3.6m/enumobject.h
| | +-/usr/include/python3.6m/eval.h
| | +-/usr/include/python3.6m/fileobject.h
| | +-/usr/include/python3.6m/fileutils.h
| | +-/usr/include/python3.6m/floatobject.h
| | +-/usr/include/python3.6m/funcobject.h
| | +-/usr/include/python3.6m/genobject.h
| | +-/usr/include/python3.6m/import.h
| | +-/usr/include/python3.6m/intrcheck.h
| | +-/usr/include/python3.6m/iterobject.h
| | +-/usr/include/python3.6m/listobject.h
| | +-/usr/include/python3.6m/longintrepr.h
| | +-/usr/include/python3.6m/longobject.h
| | +-/usr/include/python3.6m/memoryobject.h
| | +-/usr/include/python3.6m/methodobject.h
| | +-/usr/include/python3.6m/modsupport.h
| | +-/usr/include/python3.6m/moduleobject.h
| | +-/usr/include/python3.6m/namespaceobject.h
| | +-/usr/include/python3.6m/object.h
| | +-/usr/include/python3.6m/objimpl.h
| | +-/usr/include/python3.6m/odictobject.h
| | +-/usr/include/python3.6m/osmodule.h
| | +-/usr/include/python3.6m/patchlevel.h
| | +-/usr/include/python3.6m/pyarena.h
| | +-/usr/include/python3.6m/pyatomic.h
| | +-/usr/include/python3.6m/pycapsule.h
| | +-/usr/include/python3.6m/pyconfig.h
| | +-/usr/include/python3.6m/pyctype.h
| | +-/usr/include/python3.6m/pydebug.h
| | +-/usr/include/python3.6m/pyerrors.h
| | +-/usr/include/python3.6m/pyfpe.h
| | +-/usr/include/python3.6m/pyhash.h
| | +-/usr/include/python3.6m/pylifecycle.h
| | +-/usr/include/python3.6m/pymacconfig.h
| | +-/usr/include/python3.6m/pymacro.h
| | +-/usr/include/python3.6m/pymath.h
| | +-/usr/include/python3.6m/pymem.h
| | +-/usr/include/python3.6m/pyport.h
| | +-/usr/include/python3.6m/pystate.h
| | +-/usr/include/python3.6m/pystrcmp.h
| | +-/usr/include/python3.6m/pystrtod.h
| | +-/usr/include/python3.6m/pythonrun.h
| | +-/usr/include/python3.6m/pytime.h
| | +-/usr/include/python3.6m/rangeobject.h
| | +-/usr/include/python3.6m/setobject.h
| | +-/usr/include/python3.6m/sliceobject.h
| | +-/usr/include/python3.6m/structseq.h
| | +-/usr/include/python3.6m/sysmodule.h
| | +-/usr/include/python3.6m/traceback.h
| | +-/usr/include/python3.6m/tupleobject.h
| | +-/usr/include/python3.6m/typeslots.h
| | +-/usr/include/python3.6m/unicodeobject.h
| | +-/usr/include/python3.6m/warnings.h
| | +-/usr/include/python3.6m/weakrefobject.h
| | +-/usr/include/python3.6m/code.h
| | +-/usr/include/python3.6m/dynamic_annotations.h
| | +-/usr/include/python3.6m/pyconfig-64.h
| | +-/bin/gcc
| +-test.os
| | +-test.c
| | +-/bin/gcc
| +-/bin/gcc
+-test.c
+-test.i
+-[test.os]
+-test.py
| +-test.i
| +-/bin/swig
+-[test_wrap.c]
+-[test_wrap.os]
scons: done building targets. And without swig installed: $ scons --tree=prune
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test.os -c -fPIC -I/usr/include/python3.6m test.c
scons: *** [_test.so] Source file: test.i is static and is not compatible with shared target: _test.so
+-.
+-SConstruct
+-_test.so
| +-test.i
| +-test.os
| | +-test.c
| | +-/bin/gcc
| +-/bin/gcc
+-test.c
+-test.i
+-[test.os]
scons: building terminated because of errors. |
The swig tool installs the |
hmm.. Might be able to check if it's not an object file and issue something
like "not object file, no builder for .i->.o?"
…On Mon, May 14, 2018 at 9:48 PM, GaryO ***@***.***> wrote:
The swig tool installs the .i -> .c builder, so without that SCons
doesn't know what to do with the .i so it assumes it's an object file.
Without more serious work on the toolchain logic (which I have done some
work on but it's not ready) it's hard to do much better here. Perhaps the
error message could be improved to say something like "... is static (or
it's not a known file type)"?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1671 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAFBNCgW4M-oMgrqVBIfokdYbWbMJMFdks5tyjPegaJpZM4RQhUZ>
.
|
Stupid question: How does SCons decide that it will use the swig builder for a .i file? If that logic is available without swig being installed, it could complain about the tool missing. |
Take a look at `SCons/Tool/swig.py`
…-Bill
On Tue, May 15, 2018 at 12:32 PM, D4N ***@***.***> wrote:
Stupid question: How does SCons decide that it will use the swig builder for a .i file? If that logic is available without swig being installed, it could complain about the tool missing.
|
The original report seems to be the same as #797 |
This issue was originally created at: 2007-05-29 21:37:06.
This issue was reported by:
gregnoel
.gregnoel said at 2007-05-29 21:37:06
garyo said at 2008-03-17 20:20:55
garyo said at 2008-03-17 20:22:14
gregnoel said at 2008-12-26 13:29:18
stevenknight said at 2009-11-10 18:00:20
dirkbaechle said at 2014-05-18 08:56:37
Votes for this issue: 5.
garyo said this issue is duplicated by #1007 at 2008-03-17 20:22:15.
The text was updated successfully, but these errors were encountered: