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

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

0 Members and 2 Guests are viewing this topic.

rojohound

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #15 on: October 10, 2013, 09:31:37 pm »
Ok, I've come up with a solution for python 3.3.  The trick is copying sfml over manually and not letting cxfreeze do it.

My test.py
import sfml
 
My setup.py
import sys
from cx_Freeze import setup, Executable

if sys.platform == "win32":
    base = "Win32GUI"

buildOptions = {"includes":["numbers","re"],
                "excludes":["sfml"]
                }

setup(
        name = "Test",
        version = "1.0",
        description = "pysfml test",
        options = dict(build_exe = buildOptions),
        executables = [Executable("test.py", base=base)])

I then build with cxfreeze and then copy the sfml forder from "C:\Python33\Lib\site-packages" to the build directory.

Anvilfolk

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #16 on: October 10, 2013, 09:32:48 pm »
That's GREAT news!

Will try this as soon as I get home and report back. Amazing work!

Thanks!

Anvilfolk

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #17 on: October 11, 2013, 01:52:29 am »
The SFML errors disappeared, but unfortunately I'm getting an error that is easily reproduced. I am very unfamiliar with cx_Freeze, so I'm probably doing something wrong. Here's the example:

test.py
import mymodule.test

mymodule/test.py
print("Test successful")

mymodule/__init__.py exists and is empty.

$ python test.py
Test successful

$ test.exe
YADA YADA
ImportError: No modules named mymodule.test


I'm including the module explicitly, and I've tried both ways:
buildOptions = {"includes": ["mymodule.test"]}
buildOptions = {"includes": ["mymodule/test"]}

Any ideas?

Anvilfolk

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #18 on: October 11, 2013, 02:06:30 am »
If I use "include_files" to manually include the entire code, it appears to work. However, that replicates the entire directory structure along with the original source code in the build directory.

However, what I find strange is that library.zip includes all of the relevant .pyc files, so the code is there in compiled form. I shouldn't have to copy it over in source format.

Benoit87

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: cx_freeze pySFML compilation AttributeError, no attribute Rectangle
« Reply #19 on: November 05, 2013, 10:10:54 pm »
Ok, I've come up with a solution for python 3.3.  The trick is copying sfml over manually and not letting cxfreeze do it.

My test.py
import sfml
 
My setup.py
import sys
from cx_Freeze import setup, Executable

if sys.platform == "win32":
    base = "Win32GUI"

buildOptions = {"includes":["numbers","re"],
                "excludes":["sfml"]
                }

setup(
        name = "Test",
        version = "1.0",
        description = "pysfml test",
        options = dict(build_exe = buildOptions),
        executables = [Executable("test.py", base=base)])

I then build with cxfreeze and then copy the sfml forder from "C:\Python33\Lib\site-packages" to the build directory.

Oh, great, your solution work fine with me also.

@Anvilfolk : Your problem is weird, and probably it's an issue from cx_freeze for python3.3 ? Because my project under python3.2 still work properly after been packaged by cx_freeze without particular setting like "include_files", and I import a lot of custom module (like "engine.main", "engine.physics.body", ...).
Moreover, in my test with pymunk (chipmunk) I include files called "functions.py", "main.py" and "classes.py". I haven't the problem with the setup.py here :
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", "re"]
excludes = ["sfml"]
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":
#    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)])

print("=============================")
print("Il faut copier manuellement le repertoire C:\Python33\Lib\site-packages\sfml\ dans le dossier exe.win32-3.3.")
 

 

anything