VIM pyeval() unavailable

Anyone knows why pyeval() seems unavailable on the FreeBSD port of VIM? No matter how I tried to compile the port, you don't get pyeval().

Also, what exactly are the BADPATCHES in the VIM Makefile? Why are they considered "bad"?
 
Dan1973 said:
Anyone knows why pyeval() seems unavailable on the FreeBSD port of VIM? No matter how I tried to compile the port, you don't get pyeval().
How did you determine that pyeval() isn't available? The reason I'm asking is because sharing the method will make it easier on others to confirm the problem, or not..

Dan1973 said:
Also, what exactly are the BADPATCHES in the VIM Makefile? Why are they considered "bad"?
That's something best answered by the port maintainer (see # make maintainer). My guess is that these patches provide functionality which either isn't compatible or maybe unsuitable for FreeBSD usage.
 
ShelLuser said:
How did you determine that pyeval() isn't available? The reason I'm asking is because sharing the method will make it easier on others to confirm the problem, or not..
  1. Any plugin using pyeval() chokes with
    Code:
    E117: Unknown function.
  2. No :pyeval command works:
    Code:
    E117: Unknown function. Try it with a combination of :py something followed by a :pyeval something.
  3. If you get VIM from a Mercurial repo and compile it (not using ports) everything is working as it should.

ShelLuser said:
That's something best answered by the port maintainer (see # make maintainer). My guess is that these patches provide functionality which either isn't compatible or maybe unsuitable for FreeBSD usage.

See point 3 above. A clone of VIM Mercurial (up to patch 1084) compiled with no issues, and the binary works perfectly as far as I can tell from several hours of using it. Of course, this doesn't mean I guarantee for it being FreeBSD bug free.

I didn't really needed pyeval until I switched from Clang-complete + Supoertab plugins to YouCompleteMe + Syntastic plugin, so I had no idea the FreeBSD port is missing it until some days ago. But YouCompleteMe is IMO an excellent plugin and its actively developed so I will stick with it in the future.
 
Just a small disclaimer: I'm not a Python user and thus initially compiled vim without Python support. But things like these intrigue me so I recompiled it, looked up an example on how to use pyeval() and all seems to work just fine. I'm using FreeBSD 9.1-RELEASE-p3. My ports revision sits at 308183, and we're talking about Vim 7.3.

I came across this thread on Stack Overflow where someone suggested to use Python in a search/replace task:

Code:
:python import datetime
:%s/\v\w+\ \d{2}\ \d{4}/\=pyeval('datetime.datetime.strptime(vim.eval("submatch(0)"), "%b %d %Y").isoformat()')/g

If I use this on my vim environment the only error I get is the well known "Pattern not found":

Code:
E486: Pattern not found: \v\w+\ \d{2}\ \d{4}
Press ENTER or type command to continue

Just for clarity here is my port configuration:

Code:
root@smtp2:/usr/ports/editors/vim # make showconfig
===> The following configuration options are available for vim-7.3.1014:
     CSCOPE=on: cscope support
     EXUBERANT_CTAGS=off: Use exctags instead of ctags
     LUA=off: Lua scripting language support
     NLS=on: Native Language Support
     PERL=on: Perl scripting language support
     PYTHON=on: Python bindings or support
     RUBY=off: Ruby bindings or support
     TCL=off: Tcl scripting language support
     X11=off: X11 (graphics) support
     XTERM_SAVE=off: Restore xterm screen after exit
====> Options available for the radio UI: you can only select none or one of them
     ATHENA=off: Athena GUI toolkit
     GTK2=off: GTK+ 2 GUI toolkit support
     GNOME=off: GNOME desktop environment support
     MOTIF=off: Motif widget library support
===> Use 'make config' to modify these settings
At first I compiled this port with the well known # make install clean, now I rely on ports-mgmt/portmaster to cleanly reinstall it.

Hope this can help.
 
Can you please try this? It's a very simple test.

Code:
:py x={'1':''}
:echo pyeval("x")

It works with Mercurial Vim, but fails for me with the port.
 
Well, sorry if I might have gotten your hopes up but unfortunately your test confirms it very clearly. I was under the impression that because I didn't got the error I got now it actually worked. But this is what happens when I try your test:

Code:
E117: Unknown function: pyeval
E15: Invalid expression: pyeval("x")
Press ENTER or type command to continue

I started checking for Port dependencies and the moment you enable Python support it immediately updates its dependencies:

Code:
root@smtp2:/usr/ports/editors/vim # make run-depends-list
/usr/ports/converters/libiconv
/usr/ports/devel/cscope
/usr/ports/devel/gettext
/usr/ports/lang/perl5.14
[B]/usr/ports/lang/python27[/B]
Needless to say, but that version is obviously installed on my server, and when checking its dependencies you can clearly see that vim has registered itself too:

Code:
root@smtp2:/usr/ports/editors/vim # pkg_info -R python27\*
Information for python27-2.7.5:

Required by:
...
mc-4.8.8
webmin-1.630
[B]vim-7.3.1014[/B]
(I cut out some ports from the list and only kept the last part).

So, then I configured editors/vim using # make fetch extract patch configure and then examined work/vim73/src/auto/config.log (navigated from the Port directory obviously) and I discovered this:

Code:
  $ auto/configure --enable-gui=no --without-x --enable-perlinterp [B]--enable-pyth
oninterp[/B] --enable-cscope --enable-multibyte --enable-fontset --enable-xim --with
-features=big --prefix=/usr/local --with-tlib=termlib --srcdir=. --cache-file=au
to/config.cache
However, when I example the output from # ./configure --help | less I find these options:

Code:
  --enable-pythoninterp=OPTS   Include Python interpreter. default=no OPTS=no/yes/dynamic
  --enable-python3interp=OPTS   Include Python3 interpreter. default=no OPTS=no/yes/dynamic
Notice the =OPTS? But the initial configure command (as initiated by the Ports build script, and seen in the config.log file) doesn't supply any parameters.

So then I looked even deeper into config.log:

Code:
configure:5202: checking --enable-pythoninterp argument
configure:5211: result: yes
configure:5218: checking for python2
configure:5236: found /usr/local/bin/python2
configure:5248: result: /usr/local/bin/python2
configure:5261: checking Python version
configure:5270: result: 2.7
configure:5273: checking Python is 1.4 or better
configure:5278: result: yep
configure:5281: checking Python's install prefix
configure:5290: result: /usr/local
configure:5293: checking Python's execution prefix
configure:5302: result: /usr/local
configure:5324: checking Python's configuration directory
configure:5341: result: /usr/local/lib/python2.7/config
configure:5400: checking if -pthread should be used
configure:5427: cc -o conftest -O2 -pipe -fno-strict-aliasing  -D_THREAD_SAFE  -
I/usr/local/include    -Wl,-R/usr/local/lib/perl5/5.14.2/mach/CORE   -L/usr/loca
l/lib conftest.c  -pthread >&5
configure:5427: $? = 0
configure:5428: result: yes
configure:5443: checking if compile and link flags for Python are sane
configure:5460: cc -o conftest -O2 -pipe -fno-strict-aliasing  -I/usr/local/incl
ude/python2.7 -DPYTHON_HOME=\"/usr/local\" -D_THREAD_SAFE  -I/usr/local/include
   -Wl,-R/usr/local/lib/perl5/5.14.2/mach/CORE   -L/usr/local/lib conftest.c  -p
thread -L/usr/local/lib/python2.7/config -lpython2.7 -lutil -lm -Wl,--export-dyn
amic >&5
<command-line>: warning: missing terminating " character
configure:5460: $? = 0
configure:5461: result: yes
configure:5502: checking --enable-python3interp argument
configure:5511: result: no
So it seems that Python support is really being added to vim during compilation.

Then I turned my attention to pyeval() itself and found this webpage; here pyeval v0.1.6 is being provided as a separate download.

As such I'm now wondering if it is possible that this function simply isn't part of the Python base system, thus simply not provided together with lang/python27?

Because if that's the case then it would sure explain why vim is unable to use this function. The reason I'm starting to conclude as such is because my vim program does allow commands such as :python import datetime (as seen in my previous post) without giving any errors.

So I think that vim does provide Python support, but Python doesn't seem to include pyeval().
 
ShelLuser said:
So I think that vim does provide Python support, but Python doesn't seem to include pyeval().

It should work regardless of Python version (if its supported by Vim), since it's provided by VIM and not python. Vim landed pyeval() sometimes a year ago or so.

Unfortunately, the FreeBSD port is bugged or otherwise damaged. I hope somebody will fix it, since Vim is one of the most useful pieces of software ever written. I emailed the port maintainer a couple of days ago, but so far I got no reaction from him.
 
Back
Top