digitalmars.D.learn - is there a way to embed python 3.7 code in D program?
- torea (7/7) May 12 2019 Hi,
- Andre Pany (5/12) May 12 2019 You could try to do s.th. similar like this package
- Nicholas Wilson (4/8) May 12 2019 It isn't. You may needs to set a dub version, or it may pick up
- torea (4/13) May 12 2019 ok, I'll do some more tests with pyd then.
- evilrat (5/7) May 12 2019 I have project using pyd with python 3.7, that also using ptvsd
- evilrat (4/8) May 12 2019 https://github.com/Superbelko/pyd-min
- evilrat (4/7) May 13 2019 Pardon me, somehow I was completely misread the original
- Danny Arends (14/24) May 13 2019 Hey there,
- evilrat (14/18) May 13 2019 On Linux PYTHONPATH doesn't have current directory by default, so
- torea (3/14) May 19 2019 Your example helped me a lot!
- Cym13 (9/16) May 12 2019 If pyd doesn't work you still have the option to use python's C
- Russel Winder (10/19) May 13 2019 PyD works entirely fine for me using Python 3.7.
- torea (4/9) May 14 2019 Yes, it seems to work so far for me too, just modifying the
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
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 regardsYou could try to do s.th. similar like this package http://code.dlang.org/packages/matplotlib-d Kind regards Andre
May 12 2019
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
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: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!!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
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 12 2019
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 12 2019
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
On Monday, 13 May 2019 at 09:03:02 UTC, evilrat wrote:On Monday, 13 May 2019 at 03:06:07 UTC, evilrat wrote: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"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
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 Dps. I removed the vs debugger stuff since I'm on LinuxIt 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.
May 13 2019
On Monday, 13 May 2019 at 03:06:07 UTC, evilrat wrote:On Monday, 13 May 2019 at 01:35:58 UTC, evilrat wrote:Your example helped me a lot! Thank you evilrat!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 19 2019
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 regardsIf 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 12 2019
On Sun, 2019-05-12 at 20:06 +0000, torea via Digitalmars-d-learn wrote:Hi, =20 I'd like to use D for the "brain" of a small robot (Anki vector)=20 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 PyPIWould there be other ways to call python functions and retrieve=20 the python objects (including camera image) inside a D program? =20 Best regards--=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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
On Monday, 13 May 2019 at 08:33:46 UTC, Russel Winder wrote:Yes, it seems to work so far for me too, just modifying the dub.json file. Thank you all for the tips!!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.
May 14 2019