Using Python in Far
Using Python in Far
Hi, Is there a way to use Python to make plugins or interact with Far in any way?
I haven't been able to decipher the Russian forum for anything useful about it.
jonib
I haven't been able to decipher the Russian forum for anything useful about it.
jonib
Last edited by jonib on Mon 28 Sep, 2015 15:41, edited 1 time in total.
- HaRT
- Moderator
- Posts: 10865
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Using Python in Far
Several years ago, there was a plugin to run IronPython scripts in Far (see links in this post). After that, the code was adapted to run via FarNet plugin, updated a couple of times, and later discontinued.
I haven't heard of any way to write plugins for Far in plain Python.
I haven't heard of any way to write plugins for Far in plain Python.
Фар есть инструмент, а не нянька. © 2009 DrKnS
Using Python in Far
I find a way how to make C code accessible from Python http://techtonik.rainforce.org/2008/01/ ... h-gcc.html but could not find a way how to load Python from Far plugin.
- HaRT
- Moderator
- Posts: 10865
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Using Python in Far
Depending on the technology the plugin is based on, the approaches will differ. E.g. a plugin written in C++ might use Boost.Python. If the plugin is Qt-based, then PyQt might be more appropriate.
Фар есть инструмент, а не нянька. © 2009 DrKnS
Using Python in Far
Plugin is in pure C, so I thought that maybe it is just possible to make it somehow load `python27.dll` dynamically. Python docs cover this to some degree https://docs.python.org/2/extending/embedding.html, but it kind of uncommon task for me to merge it with Far Manager.
As I understand there should be two shims (API adapters):
1. One that provides access to Far API from Python code
2. Another that allows Far API to call Python functions (callbacks etc.)
As I understand there should be two shims (API adapters):
1. One that provides access to Far API from Python code
2. Another that allows Far API to call Python functions (callbacks etc.)
- HaRT
- Moderator
- Posts: 10865
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Using Python in Far
Why not use a more appropriate technology if Python integration is needed?
Фар есть инструмент, а не нянька. © 2009 DrKnS
- HaRT
- Moderator
- Posts: 10865
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Using Python in Far
I mean why write the plugin in pure C when libraries for C++ supposedly provide for less-boilerplate-code bidirectional Python integration?
Фар есть инструмент, а не нянька. © 2009 DrKnS
Using Python in Far
The problem is with bridge #1:
and I don't know any sane way to call C++ from Python.
Last edited by techie on Thu 01 Jan, 1970 01:00, edited 0 times in total.
Reason: Исправлено форматирование цитат
Reason: Исправлено форматирование цитат
- HaRT
- Moderator
- Posts: 10865
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Using Python in Far
Both Boost.Python and PyQt provide that. Your notion of “sane” might differ though.
Фар есть инструмент, а не нянька. © 2009 DrKnS
Using Python in Far
At the moment at least my Python plugin uses cffi for Python to access C/C++. I like it as it moves most code to the Python side.
I'll try to post my code shortly, I'll just have to write some instructions how to use/compile.
jonib
Using Python in Far
jonib> FUI
©pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its
goals and syntax are similar to the excellent Boost.Python.
©pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its
goals and syntax are similar to the excellent Boost.Python.
- cmd.exe
- Posts: 378
- Joined: Fri 16 Apr, 2010 18:26
- Location: Нижний Новгород
- Has thanked: 181 times
- Been thanked: 10 times
- Contact:
Using Python in Far
Boost.Python or cffi. It's really good idea.
If You like Boost.Python. I have like to seen far manager with it for compare.
If You like cffi. I have like to seen it too.
If You like Boost.Python. I have like to seen far manager with it for compare.
If You like cffi. I have like to seen it too.
I've been using Vim for about 2 years now, mostly because I can't figure out how to exit it. (c) I Am Devloper
I know nothing except the fact of my ignorance. (с) Socrates
I know nothing except the fact of my ignorance. (с) Socrates
Using Python in Far
Thanks, looks like I missed it when I was looking for alternatives. I'll check it out next time I'm looking into alternative ways to bride C/C++ and Python.
jonib
- HaRT
- Moderator
- Posts: 10865
- Joined: Tue 30 Aug, 2005 17:21
- Has thanked: 221 times
- Been thanked: 358 times
Using Python in Far
jonib, please have a look at http://forum.farmanager.com/viewtopic.p ... 11#p134711 (just published).
Фар есть инструмент, а не нянька. © 2009 DrKnS