[Scons-users] Creating a class in a SConscript

Dynastic Space dynasticspace at gmail.com
Thu May 4 15:48:22 EDT 2017


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>
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>
> 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
>> 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/e07aa8c5/attachment.html>
-------------- next part --------------
class A(object):
    pass

class B(A):
    pass

class C(B):
    pass

def PrintIsInstance(obj, called_from):
    print "PrintIsInstance called from {0}, type {1}, isinstance: {2}, hierarchy {3}".format(called_from, type(obj), isinstance(obj, B), obj.__class__.__mro__)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: SConstruct
Type: application/octet-stream
Size: 112 bytes
Desc: not available
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170504/e07aa8c5/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SConscript
Type: application/octet-stream
Size: 239 bytes
Desc: not available
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170504/e07aa8c5/attachment-0001.obj>


More information about the Scons-users mailing list