SFML community forums

Bindings - other languages => Python => Topic started by: iUnknown on November 29, 2011, 03:22:46 am

Title: Help with PySFML
Post by: iUnknown on November 29, 2011, 03:22:46 am
I have spent at least three hours trying to figure out how to combine Python and SFML and I just can't do it and I'm irritated..
Can someone please give me step by step instructions?

I have Python 3.2
I also have a 64-bit computer

Thanks in advance,
David
Title: Help with PySFML
Post by: Zerralin on November 29, 2011, 07:30:31 pm
Hello, this is not official but this is how i do

1] Installing MinGW(http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/mingw-get-inst-20111118/)
2] Adding MinGW\bin to WINDOWS path(can be added temporary)
4] getting sfml2 by git.
3] Installing cmake
5] launch cmake-gui, select sfml2-source-dir and sfml2-build-dir. Select the mingw generator and Configure->Generate.
7] now alt+r -> cmd -> cd sfml-build-dir -> mingw32-make -> mingw32-make install(as admin)
8] go to sfml_install_dir and copy directories "include" and "lib" to mingw_install_dir.
copy the dll inside bin to windows/system.

Now SFML should works..

PySFML
9] installing python 3.2 32bits
10] installing cython (http://www.lfd.uci.edu/~gohlke/pythonlibs/#cython) Cython-0.15.1.win32-py3.2.‌exe

11] Create distutils.cfg in C:\Python32\Lib\distutils\ if not exists and add
[build]
compiler=mingw32

12] In C:\Python32\Lib\distutils\cygwinccompiler.py from the class MinGW32CCompiler remove all -mno-cygwin

13] Now try to install : alt+r -> cmd -> cd pysfml  and
python setup3k.py build_ext
and finally
python setup.py build_ext install

good luck
Title: Help with PySFML
Post by: kolofsson on November 29, 2011, 09:05:12 pm
I don't understand why anybody who has windows should bother to compile SFML and PySFML on his own. It's that stupid linux obsession to compile everything. Give us one lib pack for windows and it will work. I think using MinGW is bad. Python was compiled in VC++ 2008.

I have complete PySFML2 libs compiled for Python 2.7 if you want.
Title: Help with PySFML
Post by: thisdyingsoul on November 30, 2011, 02:40:04 am
I tried to compile on windows too with no success..
But Bastien already help us  :D

https://github.com/downloads/bastienleonard/pysfml2-cython/python2-sfml2-cython-win32.zip
Title: Help with PySFML
Post by: bastien on November 30, 2011, 03:47:06 am
I have uploaded a new zip that should contain the compiled binding and all the dependencies: https://github.com/downloads/bastienleonard/pysfml2-cython/python2-sfml2-cython-win32-nodeps.zip

Quote from: "Zerralin"
Hello, this is not official but this is how i do

1] Installing MinGW(http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/mingw-get-inst-20111118/)
2] Adding MinGW\bin to WINDOWS path(can be added temporary)
4] getting sfml2 by git.
3] Installing cmake
5] launch cmake-gui, select sfml2-source-dir and sfml2-build-dir. Select the mingw generator and Configure->Generate.
7] now alt+r -> cmd -> cd sfml-build-dir -> mingw32-make -> mingw32-make install(as admin)
8] go to sfml_install_dir and copy directories "include" and "lib" to mingw_install_dir.
copy the dll inside bin to windows/system.

Now SFML should works..

PySFML
9] installing python 3.2 32bits
10] installing cython (http://www.lfd.uci.edu/~gohlke/pythonlibs/#cython) Cython-0.15.1.win32-py3.2.‌exe

11] Create distutils.cfg in C:\Python32\Lib\distutils\ if not exists and add
[build]
compiler=mingw32

12] In C:\Python32\Lib\distutils\cygwinccompiler.py from the class MinGW32CCompiler remove all -mno-cygwin

13] Now try to install : alt+r -> cmd -> cd pysfml  and
python setup3k.py build_ext
and finally
python setup.py build_ext install

good luck


The --compiler option doesn't work with Python 3? It's shown in the options list when I use build_ext --help.

Quote from: "kolofsson"
I don't understand why anybody who has windows should bother to compile SFML and PySFML on his own. It's that stupid linux obsession to compile everything.


SFML 2 has no binary release, so I didn't want to make binary release unless necessary. The vast majority of Linux users never compile anything.

Quote from: "kolofsson"
I think using MinGW is bad. Python was compiled in VC++ 2008.


The packager obviously had to choose one compiler, it doesn't mean that the others are bad.
Title: Help with PySFML
Post by: iUnknown on November 30, 2011, 06:13:40 am
I really appreciate the links but I have python 3.2.
Is it possible to get PySFML for 3.2?
Title: Help with PySFML
Post by: bastien on December 21, 2011, 05:19:31 pm
I have uploaded two new binary releases, for Python 2 and Python 3: https://github.com/bastienleonard/pysfml2-cython/downloads. Sorry for the delay.

Feedback is welcome.
Title: Help with PySFML
Post by: iUnknown on December 21, 2011, 08:57:26 pm
You're fine I just decided to skip Python for now and learn more C++ Thank you tho.
Title: Coping Sprites - PySFML (cython)
Post by: mathninja on January 14, 2012, 12:38:36 am
Is there any facility to copy a sprite (That is create a new sprite with a reference to the same texture and all the same transformations?)
Title: Help with PySFML
Post by: bastien on January 14, 2012, 01:32:52 pm
Is it possible in C++? As far as I can tell, there's no copy constructor.
Title: Help with PySFML
Post by: Nexus on January 14, 2012, 02:17:25 pm
Quote from: "bastien"
Is it possible in C++? As far as I can tell, there's no copy constructor.
Yes. There's no need for a handwritten copy constructor, the compiler implictly generates one.

The Big Three should only appear explicitly in a few low-level classes. The need to write them all the time indicates a possible design flaw, namely the lack of value semantics for member variables. This just as an aside...
Title: Help with PySFML
Post by: bastien on January 14, 2012, 07:10:04 pm
The default copy constructor may also be disabled, so I can only trust the documentation (since I was too lazy to read the source code). :)
Looks like I should add a copy() method, and maybe __copy__() too.
Title: Help with PySFML
Post by: mathninja on January 15, 2012, 05:51:50 am
Quote from: "bastien"
The default copy constructor may also be disabled, so I can only trust the documentation (since I was too lazy to read the source code). :)
Looks like I should add a copy() method, and maybe __copy__() too.

Well I tried using both copy.copy() and copy.deepcopy() on a sprite and the result appears to be the same as using sf.Sprite() to generate a new object.