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

Author Topic: Which Python binding to use  (Read 5143 times)

0 Members and 1 Guest are viewing this topic.

RobertArk

  • Newbie
  • *
  • Posts: 2
    • View Profile
Which Python binding to use
« on: April 08, 2013, 02:37:26 am »
Hi, I am a high school teacher. I teach Python and C++. I want to teach making simple video games using SFML's python binding. But I noticed there are 2 versions based on SFML2. Which one is recommended?

python-sfml (http://python-sfml.org/index.html)
pysfml-cython (http://pysfml2-cython.readthedocs.org/en/latest/)

I have tried to build both. I was successful with the second one (bastienleonard) version. But I have problems building the first one (Sonkun). Here is my info

CentOS 6.4 x86_64
gcc-4.4.7
Python 2.6.6
cmake-2.8.4
Cython-0.17.1

(the setup.py file uses dict comprehension which is 2.7+ feature, so I edited the file

#   sources = {k: v.replace('cpp', 'pyx') for k, v in sources.items()}
    sources = dict([(k, v.replace('cpp', 'pyx')) for k, v in sources.items()])

#files = {root: [os.path.join(root, fname) for fname in fnames] for root, dirs, fnames in os.walk('include')}
files = dict([(root, [os.path.join(root, fname) for fname in fnames]) for root, dirs, fnames in os.walk('include')])

but I get the following error

$python setup.py build
running build
running build_py
creating build/lib.linux-x86_64-2.6
creating build/lib.linux-x86_64-2.6/sfml
copying src/sfml/__init__.py -> build/lib.linux-x86_64-2.6/sfml
running build_ext
skipping 'src/sfml/system.cpp' Cython extension (up-to-date)
building 'sfml.system' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Iinclude -Isrc/sfml -I/usr/include/python2.6 -c src/sfml/system.cpp -o build/temp.linux-x86_64-2.6/src/sfml/system.o
src/sfml/system.cpp:7415: warning: ‘PyObject* __pyx_pw_4sfml_6system_7Vector3_25__div__(PyObject*, PyObject*)’ defined but not used
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Iinclude -Isrc/sfml -I/usr/include/python2.6 -c src/sfml/error.cpp -o build/temp.linux-x86_64-2.6/src/sfml/error.o
g++ -pthread -shared build/temp.linux-x86_64-2.6/src/sfml/system.o build/temp.linux-x86_64-2.6/src/sfml/error.o -L/usr/lib64 -lsfml-system -lsfml-graphics -lpython2.6 -o build/lib.linux-x86_64-2.6/sfml/system.so
skipping 'src/sfml/window.cpp' Cython extension (up-to-date)
building 'sfml.window' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Iinclude -Isrc/sfml -I/usr/include/python2.6 -c src/sfml/window.cpp -o build/temp.linux-x86_64-2.6/src/sfml/window.o
src/sfml/window.cpp:264:27: error: pysfml/system.h: No such file or directory
src/sfml/window.cpp: In function ‘PyObject* __pyx_f_6pysfml_6system_wrap_time(sf::Time*)’:
src/sfml/window.cpp:13622: error: invalid use of incomplete type ‘struct PyTimeObject’
src/sfml/window.cpp:13593: error: forward declaration of ‘struct PyTimeObject’
src/sfml/window.cpp: In function ‘void initwindow()’:
src/sfml/window.cpp:19588: error: invalid application of ‘sizeof’ to incomplete type ‘PyTimeObject’
src/sfml/window.cpp:19589: error: invalid application of ‘sizeof’ to incomplete type ‘PyVector2Object’
src/sfml/window.cpp:19590: error: invalid application of ‘sizeof’ to incomplete type ‘PyVector3Object’
error: command 'gcc' failed with exit status 1

RobertArk

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Which Python binding to use
« Reply #1 on: April 11, 2013, 07:42:52 am »
Regarding Sonkun's version, I deleted the "pysfml" in the path of the #include statements in the files that produced errors and it compiled ok. Kind of disappointed in the forum though. It doesn't seem very active. Any others try either of the two Python bindings? comments, recommendations...

Sonkun

  • Moderator
  • Full Member
  • *****
  • Posts: 241
    • View Profile
Re: Which Python binding to use
« Reply #2 on: April 14, 2013, 02:46:56 am »
Hello, sorry to be late, the Python section isn't very active which doesn't make me check the forum every day :/

What version are you compiling ? The latest available is 1.2 and if you try to compile from github's master branch, you might encounter issues since I re-factored many things in order to ease the code reuse (soon, other SFML-based project will be available for Python too).

Unfortunately, I can't help you for now since I haven't touched the code for a long time (I'm currently porting SFML to Android and iOS), but I would definitively move my ass if you can't compile the 1.2 version!

As for recommendations, I won't claim anything as I'm the author but hope others will answer you :)

By the way, there's a website: http://python-sfml.org where you might find useful information.
Interested in using SFML with Python ? Try out its Python binding!

shackra

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • http://swt.encyclomundi.org
Re: Which Python binding to use
« Reply #3 on: April 18, 2013, 09:59:57 am »
Regarding Sonkun's version, I deleted the "pysfml" in the path of the #include statements in the files that produced errors and it compiled ok. Kind of disappointed in the forum though. It doesn't seem very active. Any others try either of the two Python bindings? comments, recommendations...

in order to build Sonkun's SFML bindings, install SFML-2RC files on your system, don't try to use github version because Sonkun version is based on the stable release candidate!

GNU User
Python programmer
Blog

 

anything