eine klein python #149

This commit is contained in:
nick black 2020-01-07 13:43:57 -05:00 committed by Nick Black
parent fb336bdde4
commit 92d73fc600
5 changed files with 50 additions and 5 deletions

3
.gitignore vendored
View File

@ -1,6 +1,9 @@
debian
obj-x86_64-linux-gnu
python/.eggs/
python/build/
python/dist/
python/src/notcurses.egg-info/
python/src/_notcurses.so
rust/target
*.pyc

View File

@ -1,2 +1,8 @@
[aliases]
test=pytest
[nosetests]
verbosity=1
detailed-errors=1
with-coverage=1
cover-package=nose
debug=nose.loader
pdb=1
pdb-failures=1

View File

@ -11,7 +11,7 @@ setup(
packages=find_packages('src'),
author="Nick Black",
author_email="nickblack@linux.com",
description="Blingful TUI construction library",
description="Blingful TUI construction library (python bindings)",
keywords="ncurses curses tui console graphics",
license='Apache License, Version 2.0',
url='https://github.com/dankamongmen/notcurses',
@ -19,8 +19,10 @@ setup(
platforms=["any"],
long_description=read('README.md'),
long_description_content_type="text/markdown",
setup_requires=["pytest-runner"],
tests_require=["pytest"],
setup_requires=["cffi"],
cffi_modules=["src/notcurses/build_notcurses.py:ffibuild"],
install_requires=["cffi"],
py_modules=["notcurses"],
# see https://pypi.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',

View File

@ -0,0 +1,17 @@
from cffi import FFI
ffibuild = FFI()
ffibuild.set_source(
"_notcurses",
"""
#include <notcurses.h>
""",
libraries=["notcurses"],
)
ffibuild.cdef("""
struct notcurses_options;
struct notcurses* notcurses_init(const struct notcurses_options*, FILE*);
int notcurses_stop(struct notcurses*);
int notcurses_render(struct notcurses*);
""")

View File

@ -0,0 +1,17 @@
from _notcurses import lib, ffi
class Notcurses:
def __init__(self):
self.nc = lib.notcurses_init()
def __del__(self):
lib.notcurses_stop(self.nc)
def render():
return lib.notcurses_render(self.nc)
def main():
print('ohhhh yeah')
nc = Notcurses()
nc.render()
print('ohhhh yeah')