Re: embedding Pyd in Windows program

2015-03-14 Thread Matt via Digitalmars-d-learn

On Saturday, 14 March 2015 at 00:28:59 UTC, Ellery Newcomer wrote:

On Friday, 13 March 2015 at 19:05:59 UTC, Matt wrote:

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


My penitence for not putting this information on readthedocs.



I've tried the hello.d example from GitHub, and get the error 
message:
  Error: template instance py_eval!string template 'py_eval' 
is not defined


Unfortunately, that's all I seem to get. Is py_eval not 
deprecated in 0.9.4?


hmm. that's odd. are you trying to build with dub? the only 
examples that build with dub are in examples/dub. the rest use 
distutils.


Yeah, dub is what I'm using. Actually, I made a mistake regarding 
the py_eval. I'm including the pyd modules in a module other than 
the one that has my main() function, so they weren't visible. I 
feel like a proper idiot for that one..


So I set up a separate project to test the samples exactly. The 
simple_embedded sample seems to work no problem.


I haven't gotten round to trying the shared_embedded, yet, but I 
will do at some point.


Does pyd have any documentation, or are we working from the 
source for understanding the functions?


Re: embedding Pyd in Windows program

2015-03-14 Thread Ellery Newcomer via Digitalmars-d-learn

On Saturday, 14 March 2015 at 07:28:04 UTC, Matt wrote:


Yeah, dub is what I'm using. Actually, I made a mistake 
regarding the py_eval. I'm including the pyd modules in a 
module other than the one that has my main() function, so they 
weren't visible. I feel like a proper idiot for that one..


So I set up a separate project to test the samples exactly. The 
simple_embedded sample seems to work no problem.


I haven't gotten round to trying the shared_embedded, yet, but 
I will do at some point.


Does pyd have any documentation, or are we working from the 
source for understanding the functions?


there is readthedocs: http://pyd.readthedocs.org/en/latest/

there is [old] ddoc: http://ariovistus.bitbucket.org/index.html
which I've been meaning to figure out how to get into readthedocs.

there is a confluence space: 
https://pythond.atlassian.net/wiki/display/pyd/pyd+Home

where I occasionally log tidbits that might be of value


Re: embedding Pyd in Windows program

2015-03-13 Thread Matt via Digitalmars-d-learn

On Friday, 13 March 2015 at 16:30:07 UTC, Matt wrote:


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


I've tried the hello.d example from GitHub, and get the error 
message:
   Error: template instance py_eval!string template 'py_eval' is 
not defined


Unfortunately, that's all I seem to get. Is py_eval not 
deprecated in 0.9.4?


Re: embedding Pyd in Windows program

2015-03-13 Thread Ellery Newcomer via Digitalmars-d-learn

On Friday, 13 March 2015 at 19:05:59 UTC, Matt wrote:

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


My penitence for not putting this information on readthedocs.



I've tried the hello.d example from GitHub, and get the error 
message:
   Error: template instance py_eval!string template 'py_eval' 
is not defined


Unfortunately, that's all I seem to get. Is py_eval not 
deprecated in 0.9.4?


hmm. that's odd. are you trying to build with dub? the only 
examples that build with dub are in examples/dub. the rest use 
distutils.


Re: embedding Pyd in Windows program

2015-03-13 Thread Matt via Digitalmars-d-learn

On Friday, 13 March 2015 at 01:40:34 UTC, Ellery Newcomer wrote:

On 03/11/2015 07:59 PM, Matt wrote:


Right, copying site.py into my program's working dir sorts out 
the

missing module error, but I now get a syntax error:

file=sys.stderr)
^
SyntaxError: invalid syntax
Error executing command run: Program exited with code 1

I googled this, and apparently it's caused by an older 
interpreter. The

only files I have transferred over are:
  python3.DLL
  python3.LIB
  python34.LIB

Does anyone have any idea what I might be doing wrong, or how 
I can fix

this?


I'm guessing your python path is screwed up. In your embedded 
python,


import sys
print (sys.path)

make sure everything is pointing where it should.

Failing that,

are you using the correct dub configuration? without checking, 
I believe it defaults to python 2.7.


Failing that,

you transferred python3.dll from somewhere to somewhere? I 
believe pyd links to \windows\system32\python3.dll or some 
such. At least, I think that's where those lib files point to. 
not sure. If that is an issue and you want to use your own lib 
files, you will need to generate OMF files from them.


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?


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.


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


Re: embedding Pyd in Windows program

2015-03-13 Thread Ellery Newcomer via Digitalmars-d-learn

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



Re: embedding Pyd in Windows program

2015-03-13 Thread Matt via Digitalmars-d-learn

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


Re: embedding Pyd in Windows program

2015-03-12 Thread Ellery Newcomer via Digitalmars-d-learn

On 03/11/2015 07:59 PM, Matt wrote:


Right, copying site.py into my program's working dir sorts out the
missing module error, but I now get a syntax error:

 file=sys.stderr)
 ^
SyntaxError: invalid syntax
Error executing command run: Program exited with code 1

I googled this, and apparently it's caused by an older interpreter. The
only files I have transferred over are:
   python3.DLL
   python3.LIB
   python34.LIB

Does anyone have any idea what I might be doing wrong, or how I can fix
this?


I'm guessing your python path is screwed up. In your embedded python,

import sys
print (sys.path)

make sure everything is pointing where it should.

Failing that,

are you using the correct dub configuration? without checking, I believe 
it defaults to python 2.7.


Failing that,

you transferred python3.dll from somewhere to somewhere? I believe pyd 
links to \windows\system32\python3.dll or some such. At least, I think 
that's where those lib files point to. not sure. If that is an issue and 
you want to use your own lib files, you will need to generate OMF files 
from them.





Re: embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn

On Wednesday, 11 March 2015 at 19:32:05 UTC, Matt wrote:
I'm trying to build a simple platformer using SDL2 and python 
to script entities, but I'm struggling to include Pyd. I'm 
using DMD v2.066.1, with dub as the package manager, and 
derelict for the SDL2 bindings.


Now, when I add Pyd to my dub.json everything works fine, but 
as soon as I add py_init(), my code compiles and links fine, 
but I get ImportError: No module named site. Have I done 
something wrong? Can anyone shed some light on this? Or am I 
asking in the wrong place?


Any help would be very much appreciated, and I can provide code 
on request if that helps.


Well, apparently I didn't check the Python side of things. site 
is a python module that is loaded by the interpreter, meaning my 
python environment variables apparently haven't been set 
properly, despite the fact that my standalone interpreter can 
find them with no problem. I'm going to keep plugging away at 
this, see if there's any way to sort this out.


embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn
I'm trying to build a simple platformer using SDL2 and python to 
script entities, but I'm struggling to include Pyd. I'm using DMD 
v2.066.1, with dub as the package manager, and derelict for the 
SDL2 bindings.


Now, when I add Pyd to my dub.json everything works fine, but as 
soon as I add py_init(), my code compiles and links fine, but I 
get ImportError: No module named site. Have I done something 
wrong? Can anyone shed some light on this? Or am I asking in the 
wrong place?


Any help would be very much appreciated, and I can provide code 
on request if that helps.


Re: embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn

On Wednesday, 11 March 2015 at 21:45:20 UTC, Matt wrote:

On Wednesday, 11 March 2015 at 19:32:05 UTC, Matt wrote:
I'm trying to build a simple platformer using SDL2 and python 
to script entities, but I'm struggling to include Pyd. I'm 
using DMD v2.066.1, with dub as the package manager, and 
derelict for the SDL2 bindings.


Now, when I add Pyd to my dub.json everything works fine, but 
as soon as I add py_init(), my code compiles and links fine, 
but I get ImportError: No module named site. Have I done 
something wrong? Can anyone shed some light on this? Or am I 
asking in the wrong place?


Any help would be very much appreciated, and I can provide 
code on request if that helps.


Well, apparently I didn't check the Python side of things. 
site is a python module that is loaded by the interpreter, 
meaning my python environment variables apparently haven't been 
set properly, despite the fact that my standalone interpreter 
can find them with no problem. I'm going to keep plugging away 
at this, see if there's any way to sort this out.


Right, copying site.py into my program's working dir sorts out 
the missing module error, but I now get a syntax error:


file=sys.stderr)
^
SyntaxError: invalid syntax
Error executing command run: Program exited with code 1

I googled this, and apparently it's caused by an older 
interpreter. The only files I have transferred over are:

  python3.DLL
  python3.LIB
  python34.LIB

Does anyone have any idea what I might be doing wrong, or how I 
can fix this?