mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.59k stars 768 forks source link

How to install python bindings? #997

Open JoelSjogren opened 6 years ago

JoelSjogren commented 6 years ago

Hello,

I have tried installing the python bindings (actually, I enabled all optional things :). I got no direct error messages from make or make install but python cannot find mgba.

I tried import mgba and import gba. Does the PYTHONPATH need to be modified? It is currently /usr/local/lib/python3.6/site-packages:/usr/local/lib/python3.6/site-packages

The qt executable works very well. I am building from git, version 0.7-5037-523fb63c, running on arch linux, with a modern intel cpu and msi gpu.

Relevant part of the make install output: (the only place I saw python mentioned)


[ 70%] Built target mgba-pylib
running egg_info
writing /home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/PKG-INFO
writing dependency_links to /home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/dependency_links.txt
writing requirements to /home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/requires.txt
writing top-level names to /home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/top_level.txt
package init file '/home/joel/Documents/pokemon/mgba/src/platform/python/__init__.py' not found (or not a regular file)
reading manifest file '/home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/SOURCES.txt'
writing manifest file '/home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/SOURCES.txt'
running build
running build_py
package init file '/home/joel/Documents/pokemon/mgba/src/platform/python/__init__.py' not found (or not a regular file)
running build_ext
generating cffi module '/home/joel/Documents/pokemon/mgba/build/python/temp.linux-x86_64-3.6/mgba._pylib.c'
already up-to-date
[ 70%] Built target mgba-py
[ 72%] Built target mgba-sdl
JoelSjogren commented 6 years ago

I also tried entering the build directory and running


box% python3 setup.py install --user
running install
running bdist_egg
running egg_info
writing mgba.egg-info/PKG-INFO
writing dependency_links to mgba.egg-info/dependency_links.txt
writing requirements to mgba.egg-info/requires.txt
writing top-level names to mgba.egg-info/top_level.txt
package init file '/home/joel/Documents/pokemon/mgba/src/platform/python/__init__.py' not found (or not a regular file)
reading manifest file 'mgba.egg-info/SOURCES.txt'
writing manifest file 'mgba.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/conftest.py -> build/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/_builder.py -> build/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/test_cinema.py -> build/lib.linux-x86_64-3.6/mgba
running build_ext
generating cffi module 'build/temp.linux-x86_64-3.6/mgba._pylib.c'
creating build/temp.linux-x86_64-3.6
building 'mgba._pylib' extension
creating build/temp.linux-x86_64-3.6/build
creating build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/home
creating build/temp.linux-x86_64-3.6/home/joel
creating build/temp.linux-x86_64-3.6/home/joel/Documents
creating build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon
creating build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba
creating build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src
creating build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform
creating build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -fPIC -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/usr/include/python3.6m -c build/temp.linux-x86_64-3.6/mgba._pylib.c -o build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/mgba._pylib.o -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/home/joel/Documents/pokemon/mgba/build
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -fPIC -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/usr/include/python3.6m -c /home/joel/Documents/pokemon/mgba/src/platform/python/vfs-py.c -o build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python/vfs-py.o -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/home/joel/Documents/pokemon/mgba/build
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -fPIC -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/usr/include/python3.6m -c /home/joel/Documents/pokemon/mgba/src/platform/python/core.c -o build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python/core.o -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/home/joel/Documents/pokemon/mgba/build
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -fPIC -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/usr/include/python3.6m -c /home/joel/Documents/pokemon/mgba/src/platform/python/log.c -o build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python/log.o -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/home/joel/Documents/pokemon/mgba/build
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -fPIC -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/usr/include/python3.6m -c /home/joel/Documents/pokemon/mgba/src/platform/python/sio.c -o build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python/sio.o -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m -I/home/joel/Documents/pokemon/mgba/src/platform/python/../../../include -I/home/joel/Documents/pokemon/mgba/src/platform/python/../.. -I/home/joel/Documents/pokemon/mgba/build
gcc -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -I/home/joel/Documents/pokemon/mgba/src -I/home/joel/Documents/pokemon/mgba/include -I/usr/include/editline -I/usr/include/ImageMagick-7 -I/usr/include -I/usr/include -I/usr/include -I/home/joel/Documents/pokemon/mgba/src/third-party/lzma -I/usr/include/python3.6m -I/usr/include/python3.6m build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/mgba._pylib.o build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python/vfs-py.o build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python/core.o build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python/log.o build/temp.linux-x86_64-3.6/home/joel/Documents/pokemon/mgba/src/platform/python/sio.o -L/home/joel/Documents/pokemon/mgba/build -L/usr/lib -lmgba -lpython3.6m -o build/lib.linux-x86_64-3.6/mgba/_pylib.abi3.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/mgba
copying build/lib.linux-x86_64-3.6/mgba/conftest.py -> build/bdist.linux-x86_64/egg/mgba
copying build/lib.linux-x86_64-3.6/mgba/_builder.py -> build/bdist.linux-x86_64/egg/mgba
copying build/lib.linux-x86_64-3.6/mgba/test_cinema.py -> build/bdist.linux-x86_64/egg/mgba
copying build/lib.linux-x86_64-3.6/mgba/_pylib.abi3.so -> build/bdist.linux-x86_64/egg/mgba
byte-compiling build/bdist.linux-x86_64/egg/mgba/conftest.py to conftest.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/mgba/_builder.py to _builder.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/mgba/test_cinema.py to test_cinema.cpython-36.pyc
creating stub loader for mgba/_pylib.abi3.so
byte-compiling build/bdist.linux-x86_64/egg/mgba/_pylib.py to _pylib.cpython-36.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying mgba.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying mgba.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying mgba.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying mgba.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying mgba.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
mgba.__pycache__._builder.cpython-36: module references __file__
mgba.__pycache__._pylib.cpython-36: module references __file__
mgba.__pycache__.test_cinema.cpython-36: module references __file__
creating dist
creating 'dist/mgba-0.7.0-py3.6-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing mgba-0.7.0-py3.6-linux-x86_64.egg
creating /home/joel/.local/lib/python3.6/site-packages/mgba-0.7.0-py3.6-linux-x86_64.egg
Extracting mgba-0.7.0-py3.6-linux-x86_64.egg to /home/joel/.local/lib/python3.6/site-packages
Adding mgba 0.7.0 to easy-install.pth file

Installed /home/joel/.local/lib/python3.6/site-packages/mgba-0.7.0-py3.6-linux-x86_64.egg
Processing dependencies for mgba==0.7.0
Searching for cached-property
Reading https://pypi.python.org/simple/cached-property/
Downloading https://pypi.python.org/packages/40/57/2d305c9d4df1894aef360f6ccafe73b9ae2fcc75866b799e7452eb4465ca/cached_property-1.3.1-py2.py3-none-any.whl#md5=bbd81d7534820b27dea6ffc7c14ce01b
Best match: cached-property 1.3.1
Processing cached_property-1.3.1-py2.py3-none-any.whl
Installing cached_property-1.3.1-py2.py3-none-any.whl to /home/joel/.local/lib/python3.6/site-packages
Adding cached-property 1.3.1 to easy-install.pth file

Installed /home/joel/.local/lib/python3.6/site-packages/cached_property-1.3.1-py3.6.egg
Searching for cffi==1.11.4
Best match: cffi 1.11.4
Adding cffi 1.11.4 to easy-install.pth file

Using /usr/lib/python3.6/site-packages
Searching for pycparser==2.18
Best match: pycparser 2.18
Adding pycparser 2.18 to easy-install.pth file

Using /usr/lib/python3.6/site-packages
Finished processing dependencies for mgba==0.7.0
box% cd
box% python3
Python 3.6.4 (default, Jan  5 2018, 02:35:40) 
[GCC 7.2.1 20171224] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mgba
>>> mgba.__
mgba.__class__(          mgba.__getattribute__(   mgba.__name__            mgba.__setattr__(
mgba.__delattr__(        mgba.__gt__(             mgba.__ne__(             mgba.__sizeof__(
mgba.__dict__            mgba.__hash__(           mgba.__new__(            mgba.__spec__
mgba.__dir__(            mgba.__init__(           mgba.__package__         mgba.__str__(
mgba.__doc__             mgba.__init_subclass__(  mgba.__path__            mgba.__subclasshook__(
mgba.__eq__(             mgba.__le__(             mgba.__reduce__(         
mgba.__format__(         mgba.__loader__          mgba.__reduce_ex__(      
mgba.__ge__(             mgba.__lt__(             mgba.__repr__(           
>>> import mgba.core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mgba.core'
>>>
JoelSjogren commented 6 years ago

I also tried sudo python3 setup.py develop.

It seems like package init file '/home/joel/Documents/pokemon/mgba/src/platform/python/__init__.py' not found (or not a regular file) could be the crucial warning message. Should python/__init__.py be python/mgba/__init__.py?

endrift commented 6 years ago

weird. pip install -e python from your build root should get it working.

JoelSjogren commented 6 years ago

box% pwd                         
/home/joel/Documents/pokemon/mgba/build
box% sudo pip install -e python  
Obtaining file:///home/joel/Documents/pokemon/mgba/build/python
Requirement already satisfied: cffi>=1.6 in /usr/lib/python3.6/site-packages (from mgba==0.7.0)
Requirement already satisfied: cached-property in /usr/lib/python3.6/site-packages/cached_property-1.3.1-py3.6.egg (from mgba==0.7.0)
Requirement already satisfied: pycparser in /usr/lib/python3.6/site-packages (from cffi>=1.6->mgba==0.7.0)
Installing collected packages: mgba
  Found existing installation: mgba 0.7.0
    Uninstalling mgba-0.7.0:
      Successfully uninstalled mgba-0.7.0
  Running setup.py develop for mgba
Successfully installed mgba
box% python3
Python 3.6.4 (default, Jan  5 2018, 02:35:40) 
[GCC 7.2.1 20171224] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mgba
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mgba'
>>>
endrift commented 6 years ago

Is that the right pip for python3? It can raise an error if it can't the shared lib, but...not that one.

JoelSjogren commented 6 years ago

Yes, it is pip for python3.

JoelSjogren commented 6 years ago

I am writing from a virtualbox machine now, running ubuntu 17.10. The error is reproducable with cmake .. -DBUILD_PYTHON=ON -DBUILD_QT=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr make -j4 sudo make install sudo pip3 install -e python

Could you try installing ubuntu in a virtual machine to reproduce the problem? I can send you vdi a disk image if you want but it's about 8 GB.

endrift commented 6 years ago

I am not in a position to try reproduce on Linux right now. Maybe next weekend.

endrift commented 6 years ago

Just pushed a potential fix. Try it out.

JoelSjogren commented 6 years ago

I think there is some progress, since make now produces the following. But python still doesn't find the package. I still get ModuleNotFoundError: No module named 'mgba'. I have removed the build root and re-run the 4 commands from my last message.


[ 58%] Built target mgba-pylib
running egg_info
writing /home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/PKG-INFO
writing dependency_links to /home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/dependency_links.txt
writing requirements to /home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/requires.txt
writing top-level names to /home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/top_level.txt
reading manifest file '/home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/SOURCES.txt'
writing manifest file '/home/joel/Documents/pokemon/mgba/build/python/mgba.egg-info/SOURCES.txt'
running build
running build_py
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/gamedata.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/png.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/gb.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/log.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/lr35902.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/vfs.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/__init__.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/memory.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/tile.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/image.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/arm.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/core.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/debugger.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/gba.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
copying /home/joel/Documents/pokemon/mgba/src/platform/python/mgba/thread.py -> /home/joel/Documents/pokemon/mgba/build/python/lib.linux-x86_64-3.6/mgba
running build_ext
generating cffi module '/home/joel/Documents/pokemon/mgba/build/python/temp.linux-x86_64-3.6/mgba._pylib.c'
already up-to-date
[ 58%] Built target mgba-py
endrift commented 6 years ago

What does /usr/lib/python3.6/site-packages/mgba.egg-link contain?

JoelSjogren commented 6 years ago

box% file /usr/lib/python3.6/site-packages/mgba.egg-link
/usr/lib/python3.6/site-packages/mgba.egg-link: ASCII text
box% cat /usr/lib/python3.6/site-packages/mgba.egg-link
/home/joel/Documents/pokemon/mgba/build/python
.%                                                                                              
box% xxd -p /usr/lib/python3.6/site-packages/mgba.egg-link
2f686f6d652f6a6f656c2f446f63756d656e74732f706f6b656d6f6e2f6d
6762612f6275696c642f707974686f6e0a2e
JoelSjogren commented 6 years ago

It is the only file sith suffix egg-link.

Sample:


sphinx:                                                     directory
Sphinx-1.7.0-py3.6.egg-info:                                directory
sphinxcontrib:                                              directory
sphinxcontrib_websupport-1.0.1.dev20170522-py3.6.egg-info:  directory
sphinxcontrib_websupport-1.0.1.dev20170522-py3.6-nspkg.pth: ASCII text, with very long lines
sphinx_rtd_theme:                                           directory
sphinx_rtd_theme-0.2.4-py3.6.egg-info:                      directory
sqlalchemy:                                                 directory
SQLAlchemy-1.2.3-py3.6.egg-info:                            directory
sympy:                                                      directory
sympy-1.1.1-py3.6.egg-info:                                 directory
team:                                                       directory
team-1.0-py3.6.egg-info:                                    UTF-8 Unicode text
test:                                                       directory
traitlets:                                                  directory
traitlets-4.3.2-py3.6.egg-info:                             ASCII text
twisted:                                                    directory
JoelSjogren commented 6 years ago

Maybe this file is of interest: build/python/dist/mgba-0.7.0.tar.gz build/python/dist/mgba-0.7.0.tar.gz

Aside from that, I just realized that mgba can be imported without need to install it (edit: one still needs to install it, but the error of python not finding mgba is circumvented) if the current working directory is src/platform/python. This seems to work (but only if imported from the python repl loop...). Based on https://gist.github.com/endrift/752230729cbf2e29192dbe2c4a5e86c2,


os.chdir('/home/joel/Documents/pokemon/mgba/src/platform/python')
from mgba import core,image
c=core.loadPath('/home/joel/Documents/pokemon/pokemon-ruby.gba')
i=image.Image(*c.desiredVideoDimensions())
c.setVideoBuffer(i)
c.reset()
for x in range(800): c.runFrame()
with open('/home/joel/Documents/pokemon/out-ruby.png', 'wb') as f:
    i.savePNG(f)