all repos — mgba @ 33295b129779e8e5e6d8b15829b5fdc0b07e421f

mGBA Game Boy Advance Emulator

Python: Python 3 support
Jeffrey Pfau jeffrey@endrift.com
Sat, 15 Oct 2016 00:44:56 -0700
commit

33295b129779e8e5e6d8b15829b5fdc0b07e421f

parent

0723646354a46d5ad6ef33089af288684f350b41

M src/platform/python/CMakeLists.txtsrc/platform/python/CMakeLists.txt

@@ -1,3 +1,5 @@

+find_program(PYTHON python) + set(PY_INCLUDE_DIRS -I${CMAKE_SOURCE_DIR}/src) get_property(INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) get_property(COMPILE_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)

@@ -15,13 +17,13 @@ COMMAND ${CMAKE_C_COMPILER} ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} -fno-inline -E -P -c ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h -o _builder.h

DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.h) add_custom_target(_builder.h ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h) -add_custom_target(${BINARY_NAME}-pylib COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} +add_custom_target(${BINARY_NAME}-pylib COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py DEPENDS _builder.h) add_custom_command(OUTPUT ${BINARY_NAME}/__init__.py COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME} - COMMAND python ${CMAKE_CURRENT_BINARY_DIR}/setup.py build + COMMAND ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setup.py DEPENDS ${BINARY_NAME}-pylib)
M src/platform/python/mgba/arm.pysrc/platform/python/mgba/arm.py

@@ -3,7 +3,7 @@ #

# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib class _ARMRegisters: def __init__(self, cpu):
M src/platform/python/mgba/core.pysrc/platform/python/mgba/core.py

@@ -3,7 +3,7 @@ #

# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib def find(path): core = lib.mCoreFind(path.encode('UTF-8'))

@@ -31,7 +31,7 @@ return core

class Core: def __init__(self, native): - self._core = ffi.gc(native, self._deinit) + self._core = ffi.gc(native, native.deinit) success = bool(self._core.init(self._core)) if not success: raise RuntimeError("Failed to initialize core")
M src/platform/python/mgba/gb.pysrc/platform/python/mgba/gb.py

@@ -3,7 +3,7 @@ #

# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib class GB: def __init__(self, native):
M src/platform/python/mgba/gba.pysrc/platform/python/mgba/gba.py

@@ -3,7 +3,7 @@ #

# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib class GBA: def __init__(self, native):
M src/platform/python/mgba/image.pysrc/platform/python/mgba/image.py

@@ -3,7 +3,7 @@ #

# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib from . import png class Image:

@@ -23,4 +23,4 @@ p = png.PNG(f)

success = p.writeHeader(self) success = success and p.writePixels(self) p.writeClose() - return success+ return success
M src/platform/python/mgba/lr35902.pysrc/platform/python/mgba/lr35902.py

@@ -3,7 +3,7 @@ #

# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib class LR35902Core: def __init__(self, native):

@@ -52,4 +52,4 @@ self._native.l = value

if key == 'sp': self._native.sp = value else: - self.__dict__[key] = value+ self.__dict__[key] = value
M src/platform/python/mgba/png.pysrc/platform/python/mgba/png.py

@@ -3,7 +3,7 @@ #

# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib from . import vfs class PNG:

@@ -21,4 +21,4 @@

def writeClose(self): lib.PNGWriteClose(self._png, self._info) del self._png - del self._info+ del self._info
M src/platform/python/mgba/vfs.pysrc/platform/python/mgba/vfs.py

@@ -3,7 +3,7 @@ #

# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from _pylib import ffi, lib +from ._pylib import ffi, lib import mmap import os
M src/platform/python/setup.py.insrc/platform/python/setup.py.in

@@ -3,7 +3,7 @@ import re

classifiers = [ "Programming Language :: Python :: 2", -# "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)" ]

@@ -13,6 +13,8 @@ author="Jeffrey Pfau",

author_email="jeffrey@endrift.com", url="http://github.com/mgba-emu/mgba/", packages=["mgba"], + setup_requires=['cffi>=1.6'], + install_requires=['cffi>=1.6'], license="MPL 2.0", classifiers=classifiers )