Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: pysfml-cython  (Read 91445 times)

0 Members and 1 Guest are viewing this topic.

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #45 on: October 18, 2011, 09:00:00 pm »
Quote from: "bastien"


sf.dll needs to be in the Python path. The simplest way is to put it the current directory just before you execute the program. Or you can modify the PYTHONPATH environment variable.

Or you can run python setup.py install, and it should be available for all the programs. But I would do this only after testing the binding.


sf.dll? I only got sf.pyd as a result of my compilation. I put standard c++ libraries as well as the sf.pyd in the same folder as pong.py. The compiler still can't find the sf module... :(

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #46 on: October 19, 2011, 07:27:47 am »
You're right, it's .pyd on Windows apparently. What happens if you open a command prompt, go to the path where sf.pyd is, type “python”, and then type “import sf” interactively?
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #47 on: October 19, 2011, 06:14:46 pm »
Quote from: "bastien"
You're right, it's .pyd on Windows apparently. What happens if you open a command prompt, go to the path where sf.pyd is, type “python”, and then type “import sf” interactively?


calling "python" in cmd does not work for me, I had to enter full path:

Code: [Select]

E:\pysfml2\bastienleonard-pysfml2-cython-ca7f88f\build\lib.win32-2.7>c:\Python27\python.exe
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: Nie mo┐na odnalečŠ okreťlonego modu│u.
>>>


Last line says: Can't find specified module

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #48 on: October 19, 2011, 08:38:08 pm »
That's strange. Last try: did you also copy the DLLs that are in SFML/extlibs? (I don't see a “DLL loaded failed” message when importing a non-existing module, so my guess is that a dependency can't be loaded.)
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #49 on: October 19, 2011, 08:46:57 pm »
Quote from: "bastien"
That's strange. Last try: did you also copy the DLLs that are in SFML/extlibs? (I don't see a “DLL loaded failed” message when importing a non-existing module, so my guess is that a dependency can't be loaded.)


OMG it worked  :shock:

The pong example runs now. Also, when I type "import sf" with extlibs in the folder, it does not return error. This was one hell of a job to make this binding work. I guess it would be much easier with VC2008 or MinGW. But still, some binaries would be really appreciated and save quite some time, instead of compiling it all.

Thanks for help and feedback.

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #50 on: October 20, 2011, 02:51:45 pm »
Yeah, I'll try to add a binary release for Windows as soon as possible, now that the binding seems to be stable. I already tried to cross-compile it, but I have trouble testing things with Wine.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

mitsuharu

  • Newbie
  • *
  • Posts: 3
    • View Profile
pysfml2-cython
« Reply #51 on: October 21, 2011, 07:03:59 am »
For those running Win7 64bit with 64bit Python, I've found that you must place the SFML dlls in C:/Windows/SysWow64 to get everything working.  That put me back a couple hours trying to get my Windows box the same as my Mac.

I built SFML with MinGW (much easier than trying to do it with visual studio).

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #52 on: October 24, 2011, 06:50:38 pm »
Hi Bastien

A question about debugging. As we know, SFML can be compiled as Release or Debug, and for development process it is advisable to use the Debug libraries (I don't know why exactly, I guess more debug info is being produced during runtime).

Should we use the Debug libraries in PySFML too? Will it work? Is there any reason why we should/should not use them? Is compiling the bindings for Debug libraries as simple as removing the "-d" suffix from SFML lib filenames? Are you planning to include Debug libs in the binding so that there are two output files: sf.pyd and sfd.pyd?

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #53 on: October 24, 2011, 09:16:21 pm »
I haven't tried to debug PySFML applications, just the binding itself, and the users will normally never need to do that.
I never use debuggers for Python, except for really weird cases.

Currently, I'm using SFML compiled in release mode, but I guess you can use any version you want. The only upside I can see for using a debug version is if you plan to debug the library itself, and in some cases it might be possible that some low-level bugs occur only when some compiler optimizations are activated. I think this irrelevant for Python users.

I can't see which options are provided to cython by default when it's invoked by the setup.py script, but in practice I find that it provides enough information when an error occurs.
Looking at cython's command-line options, it looks like you can only disable doc strings, or add line directives to see where the error comes from the source file. Both are probably useless for most users since I don't use doc strings.
When I'll make a stable release, I'll try the various options to see if can significantly reduce the module size, though.

In the end, if you just want to debug your application, you can probably just use whatever Python debugger you prefer. I remember that I used Winpdb for debugging multi-threaded programs. There's also the standard module pdb. Personally, I find that print statements are enough most of the time. It's not like in C where you often just get “Segmentation fault” as an error message. ;-)
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #54 on: October 24, 2011, 09:46:42 pm »
Ah, very well. No special debug libs means one thing less to care about :P. So far my apps did not require special debugging, so I haven't really figured out what SFML debug libs do. If you say that regular python debugger will do, that's just perfect.

Well, I think I'm going to dedicate more time to learn Python and maybe start off a little project in PySFML. I'm really overwhelmed by Python philosophy :). I just hope you won't get bored too soon and that you keep updating and upgrading PySFML (e.g. reference/documentation).

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #55 on: October 24, 2011, 11:56:45 pm »
I keep updating it because people want it, don't hesitate to message me if something needs to be improved.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #56 on: October 26, 2011, 11:00:14 pm »
I just compiled something that looks like a Win32 module, but I can't get it to work with Wine (it tells it can't find dependent DLLs, even when they are in the current directory).
Can someone test it on Windows and tell me if it works? Here is the direct link: https://github.com/downloads/bastienleonard/pysfml2-cython/sf.pyd
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #57 on: October 27, 2011, 09:40:24 am »
Quote from: "bastien"
I just compiled something that looks like a Win32 module, but I can't get it to work with Wine (it tells it can't find dependent DLLs, even when they are in the current directory).
Can someone test it on Windows and tell me if it works? Here is the direct link: https://github.com/downloads/bastienleonard/pysfml2-cython/sf.pyd


I will test it as soon as I get hom from work. I can see you only put sf.pyd file. It makes no difference which SFML libs I use with it? (revision / compiler). I presume that when compiling the pyd file, you needed to have the dlls present, right? Maybe it would be good to include them in the package with the binding, so that the end-user does not have to compile SFML on his own.

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #58 on: October 27, 2011, 08:23:25 pm »
OK I tested your sf.pyd and it tells me that "import sf failed, module was not found". I've no idea what's wrong with your file :P.

I put my own sf.pyd on the web, accessible here:

http://grebocin.com/upload/sf.pyd

Also, I put the whole Pong example, with SFML dlls, extlibs, sf.pyd and main.py:

http://grebocin.com/upload/pong.zip

Perhaps this may be of help for all PySFML starters.

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #59 on: October 27, 2011, 09:27:54 pm »
When I try your Pong example with my sf.pyd, I get this:

Code: [Select]
err:module:import_dll Library libgcc_s_sjlj-1.dll (which is needed by L"Z:\\home\\bastien\\Desktop\\pong\\sf.pyd") not found
err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\bastien\\Desktop\\pong\\sf.pyd") not found
Traceback (most recent call last):
  File "main.py", line 9, in <module>
    import sf


Could you copy-paste here the command-lines that are issued when you build the binding? I guess I missed something to include the standard libraries.
Also, for some reason the SFML libs I cross-compiled aren't even detected by Wine.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

 

anything