[Scons-users] Creating a class in a SConscript

Jack Brennen jbrennen at qti.qualcomm.com
Thu May 4 16:23:14 EDT 2017


It's because you're importing my_script twice under two different names.

You're importing it from SConstruct under the name project.my_script, 
and you're importing it from SConscript under the name my_script.

Thus you have two separate definitions of a class named B.  The object D 
is based on my_script.D, but in SConstruct, you're checking if it's 
based on project.my_script.D, which it is not.

- Jack


On 5/4/2017 12:48 PM, Dynastic Space wrote:
> Attaching files here.
>
> I obfuscated my directory structure, but I am sure you can 
> reconstitute it. In the 'project' directory there is an empty 
> __init__.py file just to satisfy python. gmail does not let me attach 
> it here.
>
> The output I get is:
>
>  scons
> scons: Reading SConscript files ...
> isinstance(d, B) = True
> PrintIsInstance called from SConstruct, type <class 'SCons.Script.D'>, 
> isinstance: True, hierarchy (<class 'SCons.Script.D'>, <class 
> 'my_script.C'>, <class 'my_script.B'>, <class 'my_script.A'>, <type 
> 'object'>)
> PrintIsInstance called from SConstruct, type <class 'SCons.Script.D'>, 
> isinstance: False, hierarchy (<class 'SCons.Script.D'>, <class 
> 'my_script.C'>, <class 'my_script.B'>, <class 'my_script.A'>, <type 
> 'object'>)
> scons: done reading SConscript files.
> scons: Building targets ...
> scons: `.' is up to date.
> scons: done building targets.
>
> Thanks for the quick response.
>
> Howling
>
>
> On Thu, May 4, 2017 at 10:14 PM, Bill Deegan 
> <bill at baddogconsulting.com <mailto:bill at baddogconsulting.com>> wrote:
>
>     Can you provide a small complete example? (A SConstruct which
>     demonstrate this?)
>
>     On Thu, May 4, 2017 at 3:05 PM, Dynastic Space
>     <dynasticspace at gmail.com <mailto:dynasticspace at gmail.com>> wrote:
>
>         I have a python script defining a hierarchy of classes. This
>         script is not part of the scons environment.
>
>         In a SConscript file I derive from one of the classes defined
>         in my script.
>
>         I store an instance of the new class in the environment, to
>         access it later in my script.
>         However, when I use isinstance(instance, MyParentClass) it
>         returns False.
>
>         See the following print:
>         binary: app type: <class 'SCons.Script.MyAppBinaryDesc'>
>         instance of AppBinaryDesc: False hierarchy: (<class
>         'SCons.Script.MyBinaryDesc'>, <class
>         'binary_descriptor.SPAppBinaryDesc'>, <class
>         'binary_descriptor.AppBinaryDesc'>, <class
>         'binary_descriptor.BuildableDesc'>, <class
>         'binary_descriptor.BinaryDesc'>, <type 'object'>)
>
>         The instantiated object is app.
>         The class that was instantiated in my SConscript is
>         MyAppBinaryDesc.
>         I use isinstance(app, AppBinaryDesc) which returns False.
>
>         I expect it to return 'True', as the hierarchy clearly shows
>         MyAppBinaryDesc inheriting from AppBinaryDesc.
>
>         I tried importing SCons.Script in my script, but that did not
>         help.
>
>         Thanks,
>
>         Howling
>
>         _______________________________________________
>         Scons-users mailing list
>         Scons-users at scons.org <mailto:Scons-users at scons.org>
>         https://pairlist4.pair.net/mailman/listinfo/scons-users
>         <https://pairlist4.pair.net/mailman/listinfo/scons-users>
>
>
>
>     _______________________________________________
>     Scons-users mailing list
>     Scons-users at scons.org <mailto:Scons-users at scons.org>
>     https://pairlist4.pair.net/mailman/listinfo/scons-users
>     <https://pairlist4.pair.net/mailman/listinfo/scons-users>
>
>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170504/4ac37df4/attachment-0001.html>


More information about the Scons-users mailing list