Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 12, 2019 is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Hi, I'd like to use D for the "brain" of a small robot (Anki vector) whose API is coded in Python 3.6+. I had a look at Pyd but it's limited to python 2.7... Would there be other ways to call python functions and retrieve the python objects (including camera image) inside a D program? Best regards |
May 12, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to torea | On Sunday, 12 May 2019 at 20:06:34 UTC, torea wrote: > Hi, > > I'd like to use D for the "brain" of a small robot (Anki vector) whose API is coded in Python 3.6+. > I had a look at Pyd but it's limited to python 2.7... > Would there be other ways to call python functions and retrieve the python objects (including camera image) inside a D program? > > Best regards You could try to do s.th. similar like this package http://code.dlang.org/packages/matplotlib-d Kind regards Andre |
May 12, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to torea | On Sunday, 12 May 2019 at 20:06:34 UTC, torea wrote:
> Hi,
>
> I'd like to use D for the "brain" of a small robot (Anki vector) whose API is coded in Python 3.6+.
> I had a look at Pyd but it's limited to python 2.7...
It isn't. You may needs to set a dub version, or it may pick up the 2.7 as the default but it definitely works (I'm travelling ATM, can't check).
|
May 12, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Sunday, 12 May 2019 at 21:01:31 UTC, Nicholas Wilson wrote:
> On Sunday, 12 May 2019 at 20:06:34 UTC, torea wrote:
>> Hi,
>>
>> I'd like to use D for the "brain" of a small robot (Anki vector) whose API is coded in Python 3.6+.
>> I had a look at Pyd but it's limited to python 2.7...
>
> It isn't. You may needs to set a dub version, or it may pick up the 2.7 as the default but it definitely works (I'm travelling ATM, can't check).
ok, I'll do some more tests with pyd then.
And if I cannot get it to work, I'll have a look at the package!
Many thanks!!
|
May 13, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to torea | On Sunday, 12 May 2019 at 22:36:43 UTC, torea wrote:
>
> ok, I'll do some more tests with pyd then.
> And if I cannot get it to work, I'll have a look at the package!
>
I have project using pyd with python 3.7, that also using ptvsd (visual studio debugger for python package) to allow mixed debugging right inside VS Code.
I'll reduce the code and upload somewhere later.
|
May 13, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to evilrat | On Monday, 13 May 2019 at 01:35:58 UTC, evilrat wrote: > > I have project using pyd with python 3.7, that also using ptvsd (visual studio debugger for python package) to allow mixed debugging right inside VS Code. > > I'll reduce the code and upload somewhere later. > https://github.com/Superbelko/pyd-min Here. Super minimal example, ptvsd can be commented out as well, it is there entirely for debugging. |
May 13, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to torea | On Sunday, 12 May 2019 at 20:06:34 UTC, torea wrote:
> Hi,
>
> I'd like to use D for the "brain" of a small robot (Anki vector) whose API is coded in Python 3.6+.
> I had a look at Pyd but it's limited to python 2.7...
> Would there be other ways to call python functions and retrieve the python objects (including camera image) inside a D program?
>
> Best regards
If pyd doesn't work you still have the option to use python's C interfaces (it has many). Write your D program normally, provide extern(C) functions as an interface and have python call those. There are some caveats but lots of resources exist on calling C from python and calling D from C. I haven't checked but it's also probable that this is how pyd does it, have a look if you want to reproduce its functionalities.
Pyd is easier to use, but it's not the only way.
|
May 13, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to torea Attachments:
| On Sun, 2019-05-12 at 20:06 +0000, torea via Digitalmars-d-learn wrote: > Hi, > > I'd like to use D for the "brain" of a small robot (Anki vector) > whose API is coded in Python 3.6+. > I had a look at Pyd but it's limited to python 2.7... PyD works entirely fine for me using Python 3.7. I am using PyD 0.10.5 from PyPI > Would there be other ways to call python functions and retrieve the python objects (including camera image) inside a D program? > > Best regards -- Russel. =========================================== Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk |
May 13, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to evilrat | On Monday, 13 May 2019 at 03:06:07 UTC, evilrat wrote:
>
> https://github.com/Superbelko/pyd-min
>
> Here. Super minimal example, ptvsd can be commented out as well, it is there entirely for debugging.
>
Pardon me, somehow I was completely misread the original question...
Well, maybe someone else will find this useful...
|
May 13, 2019 Re: is there a way to embed python 3.7 code in D program? | ||||
---|---|---|---|---|
| ||||
Posted in reply to evilrat | On Monday, 13 May 2019 at 09:03:02 UTC, evilrat wrote:
> On Monday, 13 May 2019 at 03:06:07 UTC, evilrat wrote:
>>
>> https://github.com/Superbelko/pyd-min
>>
>> Here. Super minimal example, ptvsd can be commented out as well, it is there entirely for debugging.
>>
>
> Pardon me, somehow I was completely misread the original question...
> Well, maybe someone else will find this useful...
Hey there,
I was looking for an embedded language to use within D and your example
looks interesting. Unfortunately I am unable to run it, since it keeps
complaining about:
"ImportError: No module named 'stuff'"
How do I make the py_import file from pyd find the stuff.py file ?
Kind regards,
Danny
ps. I removed the vs debugger stuff since I'm on Linux
pps. I am using python 3.4.3, and set the subConfigurations using dub to "pyd" : "python34"
|
Copyright © 1999-2021 by the D Language Foundation