Re: is there a way to embed python 3.7 code in D program?

2019-05-19 Thread torea via Digitalmars-d-learn

On Monday, 13 May 2019 at 03:06:07 UTC, evilrat wrote:

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.


Your example helped me a lot!
Thank you evilrat!


Re: is there a way to embed python 3.7 code in D program?

2019-05-14 Thread torea via Digitalmars-d-learn

On Monday, 13 May 2019 at 08:33:46 UTC, Russel Winder wrote:
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.



Yes, it seems to work so far for me too, just modifying the 
dub.json file.


Thank you all for the tips!!



Re: is there a way to embed python 3.7 code in D program?

2019-05-13 Thread evilrat via Digitalmars-d-learn

On Monday, 13 May 2019 at 21:29:18 UTC, Danny Arends wrote:


"ImportError: No module named 'stuff'"

How do I make the py_import file from pyd find the stuff.py 
file ?




On Linux PYTHONPATH doesn't have current directory by default, so 
a hacky way to do it is to add it to PYTHONPATH prior to each run


PYTHONPATH=. ./prog

More realistic solution of course is to add it before importing 
anything in your code


void main()
{
py_stmts("import sys; sys.path += './'");
...
}

Or alternatively set the environment variable from D



ps. I removed the vs debugger stuff since I'm on Linux



It is cross platform, I just tested it myself and it works fine. 
You can mixed debugging D and Python is VS Code even on Linux.


Re: is there a way to embed python 3.7 code in D program?

2019-05-13 Thread Danny Arends via Digitalmars-d-learn

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"


Re: is there a way to embed python 3.7 code in D program?

2019-05-13 Thread evilrat via Digitalmars-d-learn

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...


Re: is there a way to embed python 3.7 code in D program?

2019-05-13 Thread Russel Winder via Digitalmars-d-learn
On Sun, 2019-05-12 at 20:06 +, 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 Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



signature.asc
Description: This is a digitally signed message part


Re: is there a way to embed python 3.7 code in D program?

2019-05-13 Thread Cym13 via Digitalmars-d-learn

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.


Re: is there a way to embed python 3.7 code in D program?

2019-05-12 Thread evilrat via Digitalmars-d-learn

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.


Re: is there a way to embed python 3.7 code in D program?

2019-05-12 Thread evilrat via Digitalmars-d-learn

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.




Re: is there a way to embed python 3.7 code in D program?

2019-05-12 Thread torea via Digitalmars-d-learn

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!!


Re: is there a way to embed python 3.7 code in D program?

2019-05-12 Thread Nicholas Wilson via Digitalmars-d-learn

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).


Re: is there a way to embed python 3.7 code in D program?

2019-05-12 Thread Andre Pany via Digitalmars-d-learn

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



is there a way to embed python 3.7 code in D program?

2019-05-12 Thread torea via Digitalmars-d-learn

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