Python: Fix test requires, run build by default

This commit is contained in:
Vicki Pfau 2017-08-12 18:35:17 -07:00
parent 73d37a2a37
commit 65a7233d5f
2 changed files with 5 additions and 3 deletions

View File

@ -34,11 +34,13 @@ set_target_properties(${BINARY_NAME}-pylib PROPERTIES INCLUDE_DIRECTORIES "${CMA
set_target_properties(${BINARY_NAME}-pylib PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}") set_target_properties(${BINARY_NAME}-pylib PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
set(PYTHON_LIBRARY ${BINARY_NAME}-pylib PARENT_SCOPE) set(PYTHON_LIBRARY ${BINARY_NAME}-pylib PARENT_SCOPE)
add_custom_target(${BINARY_NAME}-py ALL DEPENDS ${BINARY_NAME}-pylib ${CMAKE_CURRENT_BINARY_DIR}/build/lib/${BINARY_NAME}/__init__.py) add_custom_target(${BINARY_NAME}-py ALL
COMMAND ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build
DEPENDS ${BINARY_NAME}-pylib ${CMAKE_CURRENT_BINARY_DIR}/build/lib/${BINARY_NAME}/__init__.py)
file(GLOB TESTS ${CMAKE_CURRENT_SOURCE_DIR}/test_*.py) file(GLOB TESTS ${CMAKE_CURRENT_SOURCE_DIR}/test_*.py)
foreach(TEST IN LISTS TESTS) foreach(TEST IN LISTS TESTS)
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/test_" "" TEST_NAME "${TEST}") string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/test_" "" TEST_NAME "${TEST}")
string(REPLACE ".py" "" TEST_NAME "${TEST_NAME}") string(REPLACE ".py" "" TEST_NAME "${TEST_NAME}")
add_test(python-${TEST_NAME} pytest ${TEST}) add_test(python-${TEST_NAME} ${PYTHON} ${CMAKE_CURRENT_BINARY_DIR}/setup.py pytest --addopts ${TEST})
endforeach() endforeach()

View File

@ -25,7 +25,7 @@ setup(name="${BINARY_NAME}",
setup_requires=['cffi>=1.6', 'pytest-runner'], setup_requires=['cffi>=1.6', 'pytest-runner'],
install_requires=['cffi>=1.6', 'cached-property'], install_requires=['cffi>=1.6', 'cached-property'],
extras_require={'pil': ['Pillow>=2.3'], 'cinema': ['pyyaml', 'pytest']}, extras_require={'pil': ['Pillow>=2.3'], 'cinema': ['pyyaml', 'pytest']},
tests_require=['mgba[cinema]', 'pytest'], tests_require=['Pillow>=2.3', 'pyyaml', 'pytest'],
cffi_modules=["_builder.py:ffi"], cffi_modules=["_builder.py:ffi"],
license="MPL 2.0", license="MPL 2.0",
classifiers=classifiers classifiers=classifiers