[ANN] vim patch to support python3 interface

5 views
Skip to first unread message

Roland Puntaier

unread,
May 12, 2009, 12:35:40 PM5/12/09
to vim...@googlegroups.com, vim...@vim.org, pytho...@python.org
Hello,

I have ported vim's python interface (if_python.c) to the python3 C-API.

The changed files are:
- Makefile (for linux)
- Make_mvc.mak (for windows)
- if_python3.c is a new file for the python3 related sources. it is based
on if_python.c.

All of them are in the ``src`` subdirectory.

To build on linux
-----------------
- download vim sources and patch them (possibly with aap:
http://www.a-a-p.org/ports.html)
- apply the attached patch (it was made against vim72 patched up to 166)
- in bash change to the src directory and execute::

make CONF_OPT_PYTHON=--enable-pythoninterp PYTHON_VERSION=3.1

Replace ``3.1`` with your Python version in this format.

This works due to my changes in the Makefile. They assume that python3.x
is installed in /user/local.
If you leave away PYTHON_VERSION, the python interpreter under /usr/bin is
used.

auto/configure has some python2.x scripts integrated.
My patch of Makefile overrides them by providing the python3 script in
environment variables.
Very likely this is not the best or final way to do it, but these things
are up to the maintainer.

To build on windows
-------------------

- download vim sources and patch them
- apply the attached patch
- in the console make sure the path to the compiler is porperly set (e.g.
via vcvarsall.bat) then do ::

nmake -f Make_mvc.mak GUI=yes PYTHON=C:\Python30 PYTHON_VER=30
DYNAMIC_PYTHON=yes

Replace ``30`` with your Python version in this format.


Here I had a problem:
On exiting gvim there was an exception.
Debugging into it showed that this happens in exit() and only if
Py_Finalize() is called.
For now I removed the Py_Finalize() call for Windows, but this is a
TODO item.

Cheers, Roland

vim72_166_python3.patch

Tony Mechelynck

unread,
May 21, 2009, 8:27:13 AM5/21/09
to vim...@googlegroups.com, vim...@vim.org, pytho...@python.org, Vim Developers
On 12/05/09 18:35, Roland Puntaier wrote:
> Hello,
>
> I have ported vim's python interface (if_python.c) to the python3 C-API.
>
> The changed files are:
> - Makefile (for linux)
> - Make_mvc.mak (for windows)
> - if_python3.c is a new file for the python3 related sources. it is based
> on if_python.c.
>
> All of them are in the ``src`` subdirectory.
[...]

Make_mvc.mak is not, and by far, the only makefile used by people who
build Vim on Windows. If you want your port to become the "main" version
some day, patches for the other makefiles should also be available. For
instance, Steve Hall (who maintains the Vim builds, with and without
Cream, but with Python et al., hosted with the Cream project) uses, I
think, the Make_cyg.mak -- and I've seen now and again posts by Windows
users building by means of the Make_ming.mak too. I've used the
make_bc5.mak in the past, but the problems I had with it (when trying to
use Unicode in Vim on Win98) made me switch to Make_cyg.mak even before
moving up to XP and then to Linux-only; but my HowTo "for Windows" still
includes settings for it.


Best regards,
Tony.
--
The greatest dangers to liberty lurk in insidious encroachment by men
of zeal, well-meaning but without understanding.
-- Justice Louis D. Brandeis

Roland Puntaier

unread,
May 25, 2009, 10:43:26 AM5/25/09
to vim...@googlegroups.com, pytho...@python.org, vim...@vim.org, Vim Developers
vim...@googlegroups.com schrieb am 21.05.2009 14:27:13:

>
> On 12/05/09 18:35, Roland Puntaier wrote:
> > Hello,
> >
> > I have ported vim's python interface (if_python.c) to the python3
C-API.
> >
> > The changed files are:
> > - Makefile (for linux)
> > - Make_mvc.mak (for windows)
> > - if_python3.c is a new file for the python3 related sources. it is
based
> > on if_python.c.
> >
> > All of them are in the ``src`` subdirectory.
> [...]
>
> Make_mvc.mak is not, and by far, the only makefile used by people who
> build Vim on Windows.

> [...]

My solution regarding the build process is rather provisionary.
I'll work out a solution that encompasses all makefiles.

I'll send a follow-up.

Best regards,
Roland

Reply all
Reply to author
Forward
0 new messages