8000 GitHub - 813gan/emacs-python-ffi: Emacs dynamic module that implements foreign function interface for python. It allows usage of python modules in elisp.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Emacs dynamic module that implements foreign function interface for python. It allows usage of python modules in elisp.

License

Notifications You must be signed in to change notification settings

813gan/emacs-python-ffi

 
 

Repository files navigation

Emacs Python FFI

Emacs dynamic module that implements foreign function interface for python. It allows usage of python modules in Elisp.

https://github.com/813gan/emacs-python-ffi

Installation

There is no binary distribution now, so you need development tools to compile this module.

System dependencies:

  • make
  • GCC
  • pkg-config
  • python>=3.10 with development tools; it essentially means header Python.h must be present. On Debian/Ubuntu you need package python-dev.

If you compiled Python yourself and want to use it, then compile Emacs Python FFI with venv activated, or export PYTHON= with path to your exeutable before compilation. Custom Python build needs to be ./configure d with --enable-shared flag.

Elisp dependencies:

  • python-environment

Usage

NOTE for GitHub users: As of beginning of 2025 GitHub don’t display function definitions in repository overview. See rendered github page instead.

This module is going to (See Bugs and limitations) utilize Python sub-interpreters to isolate Emacs modes using this module from each other. See Pyhton documentation for details.

Most of functions in this module takes subinterpreter as first argument.

Examples of usage

Troubleshooting

Python-FFI fails to load

Error 1

Mismatch of module API version between Emacs and python-ffi. Update python-ffi to newest version. If problem persist file bug report.

Error 2

attemted loading python-ffi more then once. This shouldn’t have any effect.

Error 3

Starting of Python thread failed (pthread_create). Try restart. If problem persist file bug report.

Error 6

One of pthread functions failed. It’s possible if Emacs was running on system with low memory. Try restart. If problem persist file bug report.

Bugs and limitations

As of Python 3.13 only Main python interpreter handles signals. It means it’s impossible to send KeyboardInterrupt to subinterpreter; (See related GH issue) Consequently, it is impossible (or, at least i have no idea how) to implement keyboard-quit. Thus, any long running python code could “hang” Emacs and even C-g would not work. In my opinion it’s far more severe issue then theoretical problems of multiple Emacs modes that break each other. I didn’t want to neither delay release of this module or change API in some undefined future so, all revelant functions take argument subinterpreter anyway. It just don’t have any effect now.

About

Emacs dynamic module that implements foreign function interface for python. It allows usage of python modules in elisp.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 38.8%
  • C++ 28.3%
  • Emacs Lisp 25.7%
  • Makefile 4.5%
  • Python 2.1%
  • Shell 0.6%
0