all repos — mgba @ 0d1d5c988e2f60abb5c05a8cd61bdd9ec16d94f1

mGBA Game Boy Advance Emulator

Python: Basic setup.py
Jeffrey Pfau jeffrey@endrift.com
Thu, 13 Oct 2016 23:02:01 -0700
commit

0d1d5c988e2f60abb5c05a8cd61bdd9ec16d94f1

parent

99a85aaf3aaef60af2a768a1ee35a449a655ba75

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

@@ -8,13 +8,21 @@ foreach(COMPILE_DEF IN LISTS COMPILE_DEFINITIONS)

list(APPEND PY_COMPILE_DEFS -D${COMPILE_DEF}) endforeach() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py) + add_custom_command(OUTPUT _builder.h 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_command(OUTPUT ${BINARY_NAME}/_pylib.so - COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py ${PY_COMPILE_DEFS} ${PY_INCLUDE_DIRS} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/_builder.py - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_builder.h) -add_custom_target(_pylib.so ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}/_pylib.so)+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 + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setup.py + DEPENDS ${BINARY_NAME}-pylib) + +add_custom_target(${BINARY_NAME}-py ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}/__init__.py)
M src/platform/python/mCore.pysrc/platform/python/mgba/core.py

@@ -4,7 +4,7 @@ def find(path):

core = lib.mCoreFind(path.encode('UTF-8')) if core == ffi.NULL: return None - return mCore(core) + return Core(core) def loadPath(path): core = find(path)

@@ -12,7 +12,7 @@ if not core or not core.loadFile(path):

return None return core -class mCore: +class Core: def __init__(self, native): self._core = ffi.gc(native, self._deinit) success = bool(self._core.init(self._core))

@@ -81,9 +81,9 @@

if hasattr(lib, 'PLATFORM_GBA'): from .gba import GBA from .arm import ARMCore - mCore.PLATFORM_GBA = lib.PLATFORM_GBA + Core.PLATFORM_GBA = lib.PLATFORM_GBA if hasattr(lib, 'PLATFORM_GB'): from .gb import GB from .lr35902 import LR35902Core - mCore.PLATFORM_GB = lib.PLATFORM_GB+ Core.PLATFORM_GB = lib.PLATFORM_GB
A src/platform/python/setup.py.in

@@ -0,0 +1,18 @@

+from setuptools import setup + +classifiers = [ + "Programming Language :: Python :: 2", +# "Programming Language :: Python :: 3", + "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)" +] + + +setup(name="${BINARY_NAME}", + version="${VERSION_STRING}", + author="Jeffrey Pfau", + author_email="jeffrey@endrift.com", + url="http://github.com/mgba-emu/mgba/", + packages=["mgba"], + license="MPL 2.0", + classifiers=classifiers + )