Build and install Python wrappers #294 (#298)

* cmake: build python extension
* Python: remove obsolete clear_screen_start
* Debian: python3-cffi, not python-cffi
* Debian: add dep on python3-setuptools
* Python: build extension module from CMake #294
* Python: install python wrappers #294
* drone: disable focal for now
pull/300/head
Nick Black 4 years ago committed by GitHub
parent eae259f3bc
commit 16dfe05a93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,22 +17,22 @@ steps:
- cmake .. -DCMAKE_BUILD_TYPE=Release
- make
- make test || ./notcurses-tester -p ../data
---
kind: pipeline
type: docker
name: ubuntu-focal
steps:
- name: ubuntu-build
image: dankamongmen/focal:2020-01-25b
commands:
- apt-get update
- apt-get -y dist-upgrade
- apt-get -y install git-buildpackage
- mk-build-deps --install -t'apt-get -y'
- export LANG=en_US.UTF-8
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Release
- make
- make test || ./notcurses-tester -p ../data
#---
#kind: pipeline
#type: docker
#name: ubuntu-focal
#
#steps:
#- name: ubuntu-build
# image: dankamongmen/focal:2020-01-25b
# commands:
# - apt-get update
# - apt-get -y dist-upgrade
# - apt-get -y install git-buildpackage
# - mk-build-deps --install -t'apt-get -y'
# - export LANG=en_US.UTF-8
# - mkdir build
# - cd build
# - cmake .. -DCMAKE_BUILD_TYPE=Release
# - make
# - make test || ./notcurses-tester -p ../data

1
.gitignore vendored

@ -1,4 +1,3 @@
debian
obj-x86_64-linux-gnu
python/.eggs/
python/build/

@ -431,8 +431,30 @@ write_basic_package_version_file(
)
# Python bindings
find_package(Python3 COMPONENTS Development REQUIRED)
# FIXME
find_package(Python3 COMPONENTS Development Interpreter REQUIRED)
file(GLOB PYSRC CONFIGURE_DEPENDS python/src/notcurses/*.py)
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/python/setup.py.in")
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/python/setup.py")
set(SETUP_CFG_IN "${CMAKE_CURRENT_SOURCE_DIR}/python/setup.cfg.in")
set(SETUP_CFG "${CMAKE_CURRENT_BINARY_DIR}/setup.cfg")
configure_file(${SETUP_PY_IN} ${SETUP_PY})
configure_file(${SETUP_CFG_IN} ${SETUP_CFG})
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/build/pytimestamp"
COMMAND
"${Python3_EXECUTABLE}" ${SETUP_PY} build &&
mkdir -p "${CMAKE_CURRENT_BINARY_DIR}/build" &&
${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/build/pytimestamp"
DEPENDS
${PYSRC} ${SETUP_PY} ${SETUP_CFG} notcurses
COMMENT "Building Python wrappers"
)
add_custom_target(pymod
ALL
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/build/pytimestamp"
)
install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)")
# Installation
install(FILES
@ -476,3 +498,6 @@ install(TARGETS notcurses
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Development
)
install(
CODE
"execute_process(COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} install --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ../python)")

@ -0,0 +1,10 @@
[nosetests]
verbosity=1
detailed-errors=1
with-coverage=1
cover-package=nose
debug=nose.loader
pdb=1
pdb-failures=1
[build_ext]
library_dirs = '${CMAKE_CURRENT_BINARY_DIR}'

@ -0,0 +1,15 @@
from setuptools import setup, find_packages
import os
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
if __name__ == '__main__':
setup(name='notcurses',
version='${PROJECT_VERSION}',
package_dir={ '': '${CMAKE_CURRENT_SOURCE_DIR}/python/src/notcurses' },
packages=find_packages('${CMAKE_CURRENT_SOURCE_DIR}/python/src/notcurses'),
cffi_modules=['${CMAKE_CURRENT_SOURCE_DIR}/python/src/notcurses/build_notcurses.py:ffibuild'],
py_modules=["notcurses"],
include_dirs=['${CMAKE_CURRENT_SOURCE_DIR}/include']
)
Loading…
Cancel
Save