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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Benoit87

Pages: [1]
1
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.")
 

2
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)])
 

3
I up too, just in case.

4
In general, for windows it's quite easy, but in this case, we got an embarassing problem  ???

5
Hi again,
some news about the issue ?

Edit : If you prefer, we can go to french version ?

6
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 ?

7
Thanks, maybe we can find a solution  :)
But, perhaps only a modification on sfml binding or cx_freeze could correct that  ???

8
Python / Re: Saving sprites in a list
« on: July 01, 2013, 10:28:02 am »
It's a classic error when you have not learn how to use objects in Python correctly  ::)
You must know that in Python, when you do this :
>>> list = []
>>> print(list)
[]
>>> list2 = list
>>> list.append(5)
>>> print(list)
[5]
>>> print(list2)
[5]

Both lists are the same.
It's exacly what happen when you append your list with the sprite. You modify the position of the same sprite always.

This is a solution :
import sfml as sf

def stageLoader():
    texture = sf.Texture.from_file("Brown Block.png")
    spriteMap = []

    for xtile in range(8):
        for ytile in range(4):
            tileSprite = sf.Sprite(texture)
            tileSprite.position = (xtile*100, ytile*170)
            spriteMap.append(tileSprite)

    return spriteMap

stageMap = stageLoader()
for tile in range(len(stageMap)):
        print(stageMap[tile].position)
I create a new object each time (with the same name, but it's still a new instance).

And remove your "try: ... except: ..." if you got an error in this block, how can you know that ? You'll got an error farther, and you'll don't know that it's just here.

Have a nice day !

9
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.

10
Python / compilation error build (pysfml-cython)
« on: August 18, 2012, 11:08:02 am »
Hello ! I open this topic because I need help about an compilation error during Bastien Léonard binding pySFML2-cython build.
I use python 3.2 and I run under Linux (Linux mint 12).

When a start the build with command python3.2 setup.py build
If the build fails, run patch.py and try again
----------------------------------------------

running build
running build_ext
skipping 'src/sfml.cpp' Cython extension (up-to-date)
building 'sfml' extension
gcc -pthread -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python3.2m -c src/sfml.cpp -o build/temp.linux-x86_64-3.2/src/sfml.o
cc1plus: attention (warning ?) : command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
src/sfml.cpp:278:29: erreur fatale (fatal error) : SFML/Graphics.hpp : Aucun fichier ou dossier de ce type (No such file or folder)
compilation terminée. (compilation finished)
error: command 'gcc' failed with exit status 1
 

I have execute patch.py with python3.2 patch.py witch seem execute itself without exception, but that seem  not linked to my main problem.

I have ever search about a problem like that, but I haven't found the same :/

Thanks you in advance !  :)

Pages: [1]
anything