January 26, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | On Sun, 2014-01-26 at 01:33 +0000, Ellery Newcomer wrote: > On Friday, 24 January 2014 at 10:55:34 UTC, Russel Winder wrote: > > > > Probably want to use a virtualenv for this rather than install > > into the > > base installation > > > > you can also do > > python setup.py build > python runtests.py -b hello > > > > > It needs to work for Python 3.3 as well! > > try the latest commit OK, that works for me, at least as far as installing is concerned. You probably want to reject my pull request given the boundary conditions you want to work with. However with Python 2 the example from: https://bitbucket.org/ariovistus/pyd/wiki/QuickStart leads to: |> python setup.py build Traceback (most recent call last): File "setup.py", line 11, in <module> d_lump=True File "/home/users/russel/PythonEnvironments/Fedora_Python2_PyD/lib/python2.7/site-packages/celerid/support.py", line 53, in __init__ std_Extension.__init__(self, *args, **kwargs) TypeError: __init__() takes at least 3 arguments (2 given) on Fedora 20 using a virtualenv created from the standard Python 2. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
January 26, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
On Sun, 2014-01-26 at 12:11 +0000, Russel Winder wrote: […] > However with Python 2 the example from: > > https://bitbucket.org/ariovistus/pyd/wiki/QuickStart > > leads to: > > |> python setup.py build > Traceback (most recent call last): > File "setup.py", line 11, in <module> > d_lump=True > File > "/home/users/russel/PythonEnvironments/Fedora_Python2_PyD/lib/python2.7/site-packages/celerid/support.py", line 53, in __init__ > std_Extension.__init__(self, *args, **kwargs) > TypeError: __init__() takes at least 3 arguments (2 given) > > on Fedora 20 using a virtualenv created from the standard Python 2. Of course using the far superior Python 3: |> python setup.py build Traceback (most recent call last): File "setup.py", line 13, in <module> d_lump=True File "/home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/support.py", line 53, in __init__ std_Extension.__init__(self, *args, **kwargs) TypeError: __init__() missing 1 required positional argument: 'sources' so srcs → sources cures the problem. I get a dmd error thought: dmd -property -c -fPIC -version=PydPythonExtension -version=Python_2_4_Or_Later -version=Python_2_5_Or_Later -version=Python_2_6_Or_Later -version=Python_2_7_Or_Later -version=Python_3_0_Or_Later -version=Python_3_1_Or_Later -version=Python_3_2_Or_Later -version=Python_3_3_Or_Later -version=Python_Unicode_UCS4 -debug -I/home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure -ofbuild/temp.linux-x86_64-3.3/infra/temp.o hello.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/class_wrap.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/ctor_wrap.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/def.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/embedded.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/exception.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/extra.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/func_wrap.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/make_object.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/make_wrapper.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/op_wrap.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/pyd.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/pydobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/references.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/pyd/struct_wrap.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/util/conv.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/util/typeinfo.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/util/typelist.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/util/multi_index.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/util/replace.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/meta/Demangle.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/meta/Nameof.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/abstract_.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/ast.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/boolobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/bufferobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/bytearrayobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/bytesobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/cellobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/ceval.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/classobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/cobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/codecs.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/code.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/compile.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/complexobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/cStringIO.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/datetime.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/descrobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/dictobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/enumobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/errcode.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/eval.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/fileobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/floatobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/frameobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/funcobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/genobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/grammar.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/import_.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/intobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/intrcheck.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/iterobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/listobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/longintrepr.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/longobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/marshal.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/memoryobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/methodobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/modsupport.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/moduleobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/node.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/object.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/objimpl.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/parsetok.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pgenheaders.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pyarena.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pyatomic.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pycapsule.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pydebug.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pyerrors.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pymem.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pyport.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pystate.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pystrcmp.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pystrtod.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/Python.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pythonrun.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/pythread.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/rangeobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/setobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/sliceobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/stringobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/structmember.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/structseq.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/symtable.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/sysmodule.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/timefuncs.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/traceback.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/tupleobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/unicodeobject.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/deimos/python/weakrefobject.d build/temp.linux-x86_64-3.3/infra/pydmain.d /home/users/russel/PythonEnvironments/Fedora_Python3_PyD/lib/python3.3/site-packages/celerid/infrastructure/d/python_so_linux_boilerplate.d in here! def: hello_func hello.d(9): Error: not a property def error: command 'dmd' failed with exit status 1 -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
February 01, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On Sunday, 26 January 2014 at 14:17:18 UTC, Russel Winder wrote: > On Sun, 2014-01-26 at 12:11 +0000, Russel Winder wrote: > […] >> However with Python 2 the example from: >> >> https://bitbucket.org/ariovistus/pyd/wiki/QuickStart >> >> leads to: >> This all sounds suspiciously like stuff I thought I'd already fixed. see https://bitbucket.org/ariovistus/pyd/issue/15/some-issues-getting-pyd-to-work |
February 01, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | On Sat, 2014-02-01 at 20:58 +0000, Ellery Newcomer wrote: > On Sunday, 26 January 2014 at 14:17:18 UTC, Russel Winder wrote: > > On Sun, 2014-01-26 at 12:11 +0000, Russel Winder wrote: […] > >> However with Python 2 the example from: > >> > >> https://bitbucket.org/ariovistus/pyd/wiki/QuickStart > >> > >> leads to: > >> > > This all sounds suspiciously like stuff I thought I'd already fixed. see > > https://bitbucket.org/ariovistus/pyd/issue/15/some-issues-getting-pyd-to-work The problem was the source → sources edit: Python 2 does not give a reasonable error message, Python 3 does and leads to an immediate fix :-) My problem of the moment is segmentation faults during execution, and I have no model of how to go about providing useful data to debug this :-(( -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
February 02, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On Saturday, 1 February 2014 at 22:02:24 UTC, Russel Winder wrote: > > My problem of the moment is segmentation faults during execution, and I > have no model of how to go about providing useful data to debug > this :-(( It wouldn't by any chance be related to https://bitbucket.org/ariovistus/pyd/issue/17/it-seems-py_incref-missed-when-pydobject would it? |
February 02, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | On Sun, 2014-02-02 at 01:07 +0000, Ellery Newcomer wrote: > On Saturday, 1 February 2014 at 22:02:24 UTC, Russel Winder wrote: > > > > My problem of the moment is segmentation faults during > > execution, and I > > have no model of how to go about providing useful data to debug > > this :-(( > > It wouldn't by any chance be related to > > https://bitbucket.org/ariovistus/pyd/issue/17/it-seems-py_incref-missed-when-pydobject > > would it? Possibly but I am working with the trivial hello world: import std.stdio ; extern(C) { void sayHello() { writeln("Hello World."); } } is compiled into a shared object and the python is: import ctypes if __name__ == '__main__': module = ctypes.cdll.LoadLibrary('lib_helloWorld.so') module.sayHello() result is: |> LD_LIBRARY_PATH=. python execute.py Segmentation fault I am not sure how I should go about getting a stack trace that is meaningful. I am on Debian Unstable the above is with a Python 2 virtualenv with PyD installed. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
February 04, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On Sunday, 2 February 2014 at 15:31:30 UTC, Russel Winder wrote:
> result is:
>
> |> LD_LIBRARY_PATH=. python execute.py
> Segmentation fault
You should call Runtime.initialize() prior to calling any other D functions.
|
February 04, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Artem Tarasov | On Tue, 2014-02-04 at 07:13 +0000, Artem Tarasov wrote: > On Sunday, 2 February 2014 at 15:31:30 UTC, Russel Winder wrote: > > result is: > > > > |> LD_LIBRARY_PATH=. python execute.py > > Segmentation fault > > You should call Runtime.initialize() prior to calling any other D functions. Hummm… obvious once pointed out :-) Thanks for doing exactly that. The question is how to get this run. I tried a module initializer: static this() { Runtime.initialize(); } but this module never actually gets loaded per se, so that is never going to work. So this means calling a C linkage function to do the initialization in every entry point: import core.runtime: Runtime; import std.stdio: writeln; auto initialized = false; extern (C) void initializeIfNotAlreadyDone() { if (!initialized) { Runtime.initialize(); initialized = true; } } extern(C) { void sayHello() { initializeIfNotAlreadyDone(); writeln("Hello World."); } } works a treat: scons: Building targets ... dmd -I. -fPIC -c -fPIC -ofhelloWorld.o helloWorld.d dmd -shared -defaultlib=libphobos2.so -oflib_helloWorld.so helloWorld.o -fPIC -L-L. LD_LIBRARY_PATH=. python execute.py Hello World. scons: done building targets. So D extensions to CPython are possible without PyD! Now to continue with PyD anyway so as to compare and contrast. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
February 04, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On Tuesday, 4 February 2014 at 11:33:40 UTC, Russel Winder wrote:
> The question is how to get this run.
Pointing out obvious things, part 2: wrap it into a C function and call that function when loading the Python module.
library.d:
...
extern (C) export void attach() { Runtime.initialize(); }
library/__init__.py:
...
lib = ctypes.CDLL("myawesomelib.so")
lib.attach()
def foo():
lib.foo()
...
|
February 04, 2014 Re: Python calling D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Artem Tarasov | On Tue, 2014-02-04 at 12:45 +0000, Artem Tarasov wrote: > On Tuesday, 4 February 2014 at 11:33:40 UTC, Russel Winder wrote: > > The question is how to get this run. > > Pointing out obvious things, part 2: wrap it into a C function and call that function when loading the Python module. I had thought of this and rejected it as an API fail. (Possibly wrongly, but…) > library.d: > ... > extern (C) export void attach() { Runtime.initialize(); } > > library/__init__.py: > ... > lib = ctypes.CDLL("myawesomelib.so") > lib.attach() This violates the principle of least surprise: you don't have to do this with C or C++ extensions so it is an API fail for D to have to do this. > def foo(): > lib.foo() > ... > But it does lead to a working system :-) -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
Copyright © 1999-2021 by the D Language Foundation