www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What's the latest news for calling D from python 3 using ctypes?

reply Enjoys Math <enjoysmath gmail.com> writes:
I am making a library that will run very speedily in D (or, 
failing that, C++) and do the backend work of a PyQt5 gui.  Was 
wondering the simplest route to accomplish this, preferably in 
ctypes calls.

Thanks.
Feb 27 2018
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Tuesday, 27 February 2018 at 23:59:10 UTC, Enjoys Math wrote:
 I am making a library that will run very speedily in D (or, 
 failing that, C++) and do the backend work of a PyQt5 gui.  Was 
 wondering the simplest route to accomplish this, preferably in 
 ctypes calls.

 Thanks.
http://code.dlang.org/packages/pyd With PyD you can wrap the D functions for python instead of calling them through types in python.
Feb 27 2018
next sibling parent reply Enjoys Math <enjoysmath gmail.com> writes:
On Wednesday, 28 February 2018 at 00:18:17 UTC, Nicholas Wilson 
wrote:
 On Tuesday, 27 February 2018 at 23:59:10 UTC, Enjoys Math wrote:
 I am making a library that will run very speedily in D (or, 
 failing that, C++) and do the backend work of a PyQt5 gui.  
 Was wondering the simplest route to accomplish this, 
 preferably in ctypes calls.

 Thanks.
http://code.dlang.org/packages/pyd With PyD you can wrap the D functions for python instead of calling them through types in python.
Thank you! That looks like what I need. How do you install pyd with dub so that I can import ? dub fetch pyd dub run pyd doesn't work. Will try other params and get back to this thread.
Feb 27 2018
parent reply Enjoys Math <enjoysmath gmail.com> writes:
Got it.

dub init myproject

from within my python frontend source dir will create a 
subdirectory.
Feb 27 2018
parent reply Enjoys Math <enjoysmath gmail.com> writes:
On Wednesday, 28 February 2018 at 01:10:36 UTC, Enjoys Math wrote:
 Got it.

 dub init myproject

 from within my python frontend source dir will create a 
 subdirectory.
Then you do dub generate visuald from within the subdir myproject.
Feb 27 2018
parent reply Enjoys Math <enjoysmath gmail.com> writes:
Can't build now:


------ Build started: Project: categorytheorybackend, 
Configuration: debug Win32 ------
Building 
C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\categorytheorybackend.exe...
Error: Error writing file 
'obj\debug\dummy\dummy\dummy\dummy\dummy\categorytheorybackend\..\..\..\..\..\Users\FruitfulApproach\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\abstract_.obj'
Building 
C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\categ
rytheorybackend.exe failed!
Details saved as 
"file://C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\.dub\obj\debug\dummy\dummy\dummy\dummy\dummy\categorytheorybackend\categorytheorybackend.buildlog.html"
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped 
==========
Feb 27 2018
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Wednesday, 28 February 2018 at 01:19:25 UTC, Enjoys Math wrote:
 Can't build now:


 ------ Build started: Project: categorytheorybackend, 
 Configuration: debug Win32 ------
 Building 
 C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\categorytheorybackend.exe...
 Error: Error writing file 
 'obj\debug\dummy\dummy\dummy\dummy\dummy\categorytheorybackend\..\..\..\..\..\Users\FruitfulApproach\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\abstract_.obj'
 Building 
 C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\categ
rytheorybackend.exe failed!
 Details saved as 
 "file://C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\.dub\obj\debug\dummy\dummy\dummy\dummy\dummy\categorytheorybackend\categorytheorybackend.buildlog.html"
 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 
 skipped ==========
For some reason, idk why, PyD is a dub source dependency (as opposed to a library). If you add \path\to\pyd to the include directory(?) dub variable (or -I\path\to\pyd to dmd/ldc/gdc) it should hopefully work.
Feb 27 2018
next sibling parent reply chuoiit18 <chuoiitc18 gmail.com> writes:
On Wednesday, 28 February 2018 at 02:40:59 UTC, Nicholas Wilson 
wrote:
 On Wednesday, 28 February 2018 at 01:19:25 UTC, Enjoys Math 
 wrote:
 [...]
For some reason, idk why, PyD is a dub source dependency (as opposed to a library). If you add \path\to\pyd to the include directory(?) dub variable (or -I\path\to\pyd to dmd/ldc/gdc) it should hopefully work.
 , This is a great article. It gave me a lot of useful 
 information. thank you very much. Link profile: 
 http://phongkhamdakhoathegioi.vn/me-day-ve-noi-va-cach-chua-tri-hieu-qua.html
Feb 27 2018
parent chuoiit18 <chuoiitc18 gmail.com> writes:
On Wednesday, 28 February 2018 at 03:08:05 UTC, chuoiit18 wrote:
 On Wednesday, 28 February 2018 at 02:40:59 UTC, Nicholas Wilson 
 wrote:
 On Wednesday, 28 February 2018 at 01:19:25 UTC, Enjoys Math 
 wrote:
 [...]
For some reason, idk why, PyD is a dub source dependency (as opposed to a library). If you add \path\to\pyd to the include directory(?) dub variable (or -I\path\to\pyd to dmd/ldc/gdc) it should hopefully work.
 , This is a great article. It gave me a lot of useful 
 information. thank you very much. Link profile: 
 http://phongkhamdakhoathegioi.vn/me-day-ve-noi-va-cach-chua-tri-hieu-qua.html
, This is a great article. It gave me a lot of useful information. thank you very much. Link profile: http://dakhoaauahcm.vn
Apr 20 2018
prev sibling parent reply Enjoys Math <enjoysmath gmail.com> writes:
 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 
 skipped ==========
For some reason, idk why, PyD is a dub source dependency (as opposed to a library). If you add \path\to\pyd to the include directory(?) dub variable (or -I\path\to\pyd to dmd/ldc/gdc) it should hopefully work.
Seems like it already is. In VisualD compiler settings / additional import paths it's set to: "..\source" "..\..\..\..\..\Users\FruitfulApproach\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure"
Feb 28 2018
parent Enjoys Math <enjoysmath gmail.com> writes:
On Wednesday, 28 February 2018 at 17:34:49 UTC, Enjoys Math wrote:
 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 
 skipped ==========
For some reason, idk why, PyD is a dub source dependency (as opposed to a library). If you add \path\to\pyd to the include directory(?) dub variable (or -I\path\to\pyd to dmd/ldc/gdc) it should hopefully work.
Seems like it already is. In VisualD compiler settings / additional import paths it's set to: "..\source" "..\..\..\..\..\Users\FruitfulApproach\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure"
Solution: Use C++ instead.
Feb 28 2018
prev sibling parent Enjoys Math <enjoysmath gmail.com> writes:
On Wednesday, 28 February 2018 at 00:18:17 UTC, Nicholas Wilson 
wrote:
 On Tuesday, 27 February 2018 at 23:59:10 UTC, Enjoys Math wrote:
 I am making a library that will run very speedily in D (or, 
 failing that, C++) and do the backend work of a PyQt5 gui.  
 Was wondering the simplest route to accomplish this, 
 preferably in ctypes calls.

 Thanks.
http://code.dlang.org/packages/pyd With PyD you can wrap the D functions for python instead of calling them through types in python.
How would you get VisualD + PyD to work nicely together? See my failed build post above.
Feb 27 2018