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

Author Topic: [Solved] cx_freeze pySFML compilation AttributeError, no attribute Rectangle  (Read 21756 times)

0 Members and 1 Guest are viewing this topic.

Benoit87

  • Newbie
  • *
  • Posts: 11
    • View Profile
Hi everybody.
I used to work with pysfml-cython binding from Bastien Leonard, and it worked fine with cx_freeze compilation.
Today, I tried with the last PySFML official Jonathan De Wachter binding. It's a little bit different than Bastien Leonard's one and up to date.
I made a test with it and pymunk as physics engine.
And then, I juste tried to compile it with cx_freeze 4.3.1.
This is the error I got when I try to launch the executable.


And this is my setup.py :
http://pastebin.com/51L5PkX3

Thanks in advance ! :)

PS : Sorry if I do some errors in English, I'm French.
« Last Edit: November 10, 2013, 11:30:09 am by Benoit87 »

Sonkun

  • Moderator
  • Full Member
  • *****
  • Posts: 241
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #1 on: July 05, 2013, 10:52:47 pm »
I'll check that as soon as I'm on Windows :)
Interested in using SFML with Python ? Try out its Python binding!

Benoit87

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #2 on: July 05, 2013, 11:51:20 pm »
Thanks, maybe we can find a solution  :)
But, perhaps only a modification on sfml binding or cx_freeze could correct that  ???

Sonkun

  • Moderator
  • Full Member
  • *****
  • Posts: 241
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #3 on: July 05, 2013, 11:56:09 pm »
Don't worry, we'll fix that :) If you had cx_freeze working with Bastien's bindings, then there's no reason we can't make it work since both bindings use Cython.
Interested in using SFML with Python ? Try out its Python binding!

Benoit87

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #4 on: July 06, 2013, 12:11:16 am »
I hope so ! :)
Hmm, then I think the problem could be about the use of sub-modules.
Indeed, bastien's binding doesn't use sub-modules (sfml.graphics, sfml.system, ...). Maybe cx_freeze can't handle that ?
And I noticed :
>>> import sfml
>>> sfml.graphics.Rectangle
<class 'sfml.graphics.Rectangle'>
>>> sfml.Rectangle
<class 'sfml.graphics.Rectangle'>
 
Maybe cx_freeze doesn't hunderstand something about that ?

Benoit87

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #5 on: July 23, 2013, 11:07:02 am »
Hi again,
some news about the issue ?

Edit : If you prefer, we can go to french version ?
« Last Edit: July 23, 2013, 11:09:35 am by Benoit87 »

gaulois94

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #6 on: July 23, 2013, 10:38:59 pm »
I tried cx_freeze today, and I have the same problems. Creating executable for windows is very a difficult stage :D .
cx_freeze create 5 file : sfml.<module>.pyd (where <module> are graphics, window, network, etc.).

Benoit87

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #7 on: July 25, 2013, 11:20:18 pm »
In general, for windows it's quite easy, but in this case, we got an embarassing problem  ???

gaulois94

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #8 on: August 16, 2013, 06:26:43 pm »
I up this thread for knowing if a solution could be find.

Benoit87

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #9 on: August 26, 2013, 12:20:37 pm »
I up too, just in case.

gaulois94

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #10 on: September 27, 2013, 08:09:28 pm »
I up this thread again in the hope that we can find a solution about our problem :) (1 mouth it's a bit long, no ? :) )

rojohound

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #11 on: September 30, 2013, 11:04:46 pm »
It's not an issue with pysfml, it's from using pymunk.  Specifically chipmunk.dll is not being copied over.  Copy that file over to the built folder and it works fine.

It actually will tell you it's the issue if you specify "Console" instead of "Win32GUI".
executables = [Executable("test.py", base="Console")]

After that you get a message like this in the console if chipmunk.dll can't be loaded.
Quote
Loading chipmunk for Windows (32bit) [C:\py\build\exe.win32-2.7\chipmunk.dll]

Failed to load pymunk library.

This error usually means that you don't have a compiled version of chipmunk in
the correct spot where pymunk can find it. pymunk does not include precompiled
chipmunk library files for all platforms.
...

Benoit87

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #12 on: October 01, 2013, 06:19:41 pm »
Quote
I up this thread again in the hope that we can find a solution about our problem :) (1 mouth it's a bit long, no ? :) )
Yes, personnaly I still use bastien leonard binding instead until a solution :P

It's not an issue with pysfml, it's from using pymunk.  Specifically chipmunk.dll is not being copied over.  Copy that file over to the built folder and it works fine.

It actually will tell you it's the issue if you specify "Console" instead of "Win32GUI".
executables = [Executable("test.py", base="Console")]

After that you get a message like this in the console if chipmunk.dll can't be loaded.
Quote
Loading chipmunk for Windows (32bit) [C:\py\build\exe.win32-2.7\chipmunk.dll]

Failed to load pymunk library.

This error usually means that you don't have a compiled version of chipmunk in
the correct spot where pymunk can find it. pymunk does not include precompiled
chipmunk library files for all platforms.
...

I tried it, but my problem is the same.
I have this error now with PySFML 1.3 and chipmunk.dll in the repertory :

This time, it's import error : no module named "numbers"

But I do this in my setup : includes = ["numbers"]
And then, I have this again :



Edit : I can give more details, the repertory where the executable is :


My setup code :
from cx_Freeze import setup, Executable
import sys

# Les dependances sont automatiquement definies, mais certaines sont
# parfois omises, on peut les ajouter manuellement ici :
includes = ["numbers"]
excludes = []
packages = []
path = sys.path

# On defini qu'il s'agit d'un programme graphique si on est sous windows. (pour plus tard)
base = "Console"
if sys.platform == "win32": # These lines were commented to test the Console base.
    base = "Win32GUI"

#On appelle la fonction setup pour creer notre executable.
setup(name = "PySFML & Pymunk Test",
        version = "1.0.0",
        description = "Un test de PySFML et Pymunk.",
    options = {"build_exe": {"includes": includes,
                             "excludes": excludes,
                             "packages": packages,
                             "path": path,
                             "optimize": 2}
               },
        executables = [Executable("pysfml_pymunk_test.py", base=base)])
 
« Last Edit: October 01, 2013, 06:46:07 pm by Benoit87 »

Anvilfolk

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #13 on: October 08, 2013, 12:08:40 am »
Just registered because of this. I'm currently developing a Entity/Systems based engine along with a game called Planet 5521, which is open-source, and some people have started asking for easier ways to try this rather than installing both Python3 and PySFML.

I'm trying to use cx_Freeze and having exactly the same problems.

My setup.py is very similar. The only difference is that I try to be more explicit about the packages:

build_exe_options = {"packages": ["numbers", "sfml", "sfml.system", "sfml.window", "sfml.graphics", "xml.etree.ElementTree"]}


So, essentially, I'd love to see this fixed as well. It'd provide a much easier way to deploy pySFML based applications. Seems like a fairly complex issue though. Here's to hoping!

rojohound

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #14 on: October 10, 2013, 06:14:04 am »
I'd say it's an issue with using cxfreeze and python 3. Python27 works fine from my tests. I also tested python33 and it has the issue, I didn't test other 3x versions.  I've found some slightly similar issues with a google search of cxfreeze and python3, but nothing with solutions.

For reference for anyone digging further all that's needed to reproduce the error is a script that simply imports sfml.

I'd say the next step in debugging this is understanding what cxfreeze does and perhaps making a exe manually with the python c API to compare. For now using python27 could be a possible working option.