embedding Pyd in Windows program

Matt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Mar 13 09:30:05 PDT 2015


On Friday, 13 March 2015 at 14:21:15 UTC, Ellery Newcomer wrote:
> On Friday, 13 March 2015 at 09:38:45 UTC, Matt wrote:
>>
>> I used the "~>0.9.4" branch in dub, and I'm not sure how to 
>> change "configuration". Do you mean I should be using 
>> "~master" or "~develop"?
>
> nope. configurations are a different thing.
>
> you can set them in your project's dub.json. example:
>
> https://github.com/ariovistus/pyd/blob/master/examples/dub/simple_embedded/dub.json
>
> for your project, I think you'd want
>
> "subConfigurations": {
>   "pyd": "python34",
> }
>
>>
>> as for the transferring the python3.dll, I downloaded and 
>> installed a fresh copy of the latest Python build, version 
>> 3.4, and copied the libraries from there. Even so, I had to 
>> add PYD_PACKAGE_DIR manually to get it to work.
>
> PYD_PACKAGE_DIR is necessary for linking the OMF files found in 
> infrastructure/windows. hmm. why did it not Just Work?
>>
>> I'm not sure I'm going to be able to run the python snippet 
>> you sent, since my program, which currently opens a window for 
>> three seconds before closing again, doesn't even get that far, 
>> and chokes when I run py_init().
>
> you can put it in the top of site.py

Thank you, adding the "subConfigurations" section to dub.json 
seems to allow the program to compile and run successfully.

However, to test the code, I first tried in the main program:

---

py_eval!string("import sys\nprint(sys.path)");

---

and it didn't print anything. No error, the program just ran and 
closed.
Then, I removed that and added "print(sys.path)" to my site.py as 
you suggested (the sys module is already imported), and still the 
program runs without printing anything, so I'm a little confused 
by that. I'll probably try running some of the example code, see 
if I can figure it out, but if you can advise, that would be 
fantastic. Thank you for all the help so far, it's really been 
appreciated


More information about the Digitalmars-d-learn mailing list