Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
Metadata-Version: 2.1
Name: pynvim
Version: 0.4.2
Summary: Python client to neovim
Version: 0.5.2
Summary: Python client for Neovim
Home-page: http://github.com/neovim/pynvim
Author: Thiago de Arruda
Author-email: tpadilha84@gmail.com
Download-URL: https://github.com/neovim/pynvim/archive/0.5.2.tar.gz
Author: Neovim Authors
License: Apache
Download-URL: https://github.com/neovim/pynvim/archive/0.4.2.tar.gz
Description: UNKNOWN
Platform: UNKNOWN
Provides-Extra: pyuv
Requires-Python: >=3.7
License-File: LICENSE
Requires-Dist: msgpack>=0.5.0
Requires-Dist: greenlet>=3.0; platform_python_implementation != "PyPy"
Requires-Dist: typing-extensions>=4.5; python_version < "3.12"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest_timeout; extra == "test"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
81 changes: 40 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Pynvim: Python client to [Neovim](https://github.com/neovim/neovim)
===================================================================

[![Build Status](https://travis-ci.org/neovim/pynvim.svg?branch=master)](https://travis-ci.org/neovim/pynvim)
[![Documentation Status](https://readthedocs.org/projects/pynvim/badge/?version=latest)](http://pynvim.readthedocs.io/en/latest/?badge=latest)
[![Documentation Status](https://readthedocs.org/projects/pynvim/badge/?version=latest)](https://readthedocs.org/projects/pynvim/builds/)
[![Code coverage](https://codecov.io/gh/neovim/pynvim/branch/master/graph/badge.svg)](https://codecov.io/gh/neovim/pynvim)

Pynvim implements support for python plugins in Nvim. It also works as a library for
Expand All @@ -11,40 +10,30 @@ connecting to and scripting Nvim processes through its msgpack-rpc API.
Install
-------

Supports python 2.7, and 3.4 or later.
Supports python 3.7 or later.

```sh
pip2 install pynvim
pip3 install pynvim
```

If you only use one of python2 or python3, it is enough to install that
version. You can install the package without being root by adding the `--user`
flag.
pip3 install pynvim

You can install the package without being root by adding the `--user` flag.
Anytime you upgrade Neovim, make sure to upgrade pynvim as well:
```sh
pip2 install --upgrade pynvim
pip3 install --upgrade pynvim
```

Alternatively, the master version could be installed by executing the following
in the root of this repository:
```sh
pip2 install .
pip3 install .
```
pip3 install --upgrade pynvim

Alternatively, you can install the development version by cloning this
repository and executing the following at the top level:

pip3 install .

Python Plugin API
-----------------

Pynvim supports python _remote plugins_ (via the language-agnostic Nvim rplugin
interface), as well as _Vim plugins_ (via the `:python[3]` interface). Thus when
pynvim is installed Neovim will report support for the `+python[3]` Vim feature.
interface), as well as _Vim plugins_ (via the `:python3` interface). Thus when
pynvim is installed Neovim will report support for the `+python3` Vim feature.

The rplugin interface allows plugins to handle vimL function calls as well as
defining commands and autocommands, and such plugins can operate asynchronously
without blocking nvim. For details on the new rplugin interface,
without blocking nvim. For details on the new rplugin interface,
see the [Remote Plugin](http://pynvim.readthedocs.io/en/latest/usage/remote-plugins.html) documentation.

Pynvim defines some extensions over the vim python API:
Expand All @@ -56,13 +45,16 @@ Pynvim defines some extensions over the vim python API:

See the [Python Plugin API](http://pynvim.readthedocs.io/en/latest/usage/python-plugin-api.html) documentation for usage of this new functionality.

### Known Issues
- Vim evaluates `'v:<bool>'` to `<class 'bool'>`, whereas neovim evaluates to `<class 'str'>`. This is expected behaviour due to the way booleans are implemented in python as explained [here](https://github.com/neovim/pynvim/issues/523#issuecomment-1495502011).

Development
-----------

Use (and activate) a local virtualenv.
Use (and activate) a local virtualenv, for example:

python3 -m venv env36
source env36/bin/activate
python3 -m virtualenv venv
source venv/bin/activate

If you change the code, you must reinstall for the changes to take effect:

Expand All @@ -80,22 +72,23 @@ documentation.
### Usage from the Python REPL

A number of different transports are supported, but the simplest way to get
started is with the python REPL. First, start Nvim with a known address (or use
the `$NVIM_LISTEN_ADDRESS` of a running instance):
started is with the python REPL. First, start Nvim with a known address:

```sh
$ NVIM_LISTEN_ADDRESS=/tmp/nvim nvim
$ nvim --listen /tmp/nvim.sock
```

Or alternatively, note the `v:servername` address of a running Nvim instance.

In another terminal, connect a python REPL to Nvim (note that the API is similar
to the one exposed by the [python-vim
bridge](http://vimdoc.sourceforge.net/htmldoc/if_pyth.html#python-vim)):

```python
>>> from pynvim import attach
# Create a python API session attached to unix domain socket created above:
>>> nvim = attach('socket', path='/tmp/nvim')
# Now do some work.
>>> import pynvim
# Create a session attached to Nvim's address (`v:servername`).
>>> nvim = pynvim.attach('socket', path='/tmp/nvim.sock')
# Now do some work.
>>> buffer = nvim.current.buffer # Get the current buffer
>>> buffer[0] = 'replace first line'
>>> buffer[:] = ['replace whole buffer']
Expand All @@ -110,27 +103,33 @@ You can embed Neovim into your python application instead of connecting to
a running Neovim instance.

```python
>>> from pynvim import attach
>>> nvim = attach('child', argv=["/bin/env", "nvim", "--embed", "--headless"])
>>> import pynvim
>>> nvim = pynvim.attach('child', argv=["/usr/bin/env", "nvim", "--embed", "--headless"])
```

- The ` --headless` argument tells `nvim` not to wait for a UI to connect.
- The `--headless` argument tells `nvim` not to wait for a UI to connect.
- Alternatively, use `--embed` _without_ `--headless` if your client is a UI
and you want `nvim` to wait for your client to `nvim_ui_attach` before
continuing startup.

See the tests for more examples.
See the [tests](https://github.com/neovim/pynvim/tree/master/test) for more examples.

Release
-------

1. Create a release commit with title `Pynvim x.y.z`
- list significant changes in the commit message
- bump the version in `pynvim/util.py` and `setup.py` (3 places in total)
- bump the version in `pynvim/_version.py`
2. Make a release on GitHub with the same commit/version tag and copy the message.
3. Run `scripts/disable_log_statements.sh`
4. Run `python setup.py sdist`
4. Run `python -m build`
- diff the release tarball `dist/pynvim-x.y.z.tar.gz` against the previous one.
5. Run `twine upload -r pypi dist/pynvim-x.y.z.tar.gz`
5. Run `twine upload -r pypi dist/*`
- Assumes you have a pypi account with permissions.
6. Run `scripts/enable_log_statements.sh` or `git reset --hard` to restore the working dir.
7. Bump up to the next development version in `pynvim/_version.py`, with `prerelease` suffix `dev0`.

License
-------

[Apache License 2.0](https://github.com/neovim/pynvim/blob/master/LICENSE)
46 changes: 46 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
python-pynvim (0.5.2-2) unstable; urgency=medium

* Add python3-greenlet to Depends since dh_python3 did not detect it
* test_attach: Increase timeout for jobwait to fix test on riscv64
* Use "Testsuite: autopkgtest-pkg-pybuild" instead of manually defining autopkgtests

-- James McCoy <jamessan@debian.org> Mon, 17 Mar 2025 22:28:42 -0400

python-pynvim (0.5.2-1) unstable; urgency=medium

* New upstream release
+ Replace test use of provider#python3#Prog with neovim's new Lua function
(Closes: #1100281)
* Add python3-greenlet, python3-pytest-timeout, and
python3-typing-extensions to test (Build-)Depends
* Backport upstream patch to skip test_broadcast for neovim < 0.11
* Bump neovim Build-Depends / test Depends to >= 0.10
* Backport upstream patch to invoke python3 instead of python in test_connect_stdio

-- James McCoy <jamessan@debian.org> Thu, 13 Mar 2025 13:15:58 -0400

python-pynvim (0.5.0-2) unstable; urgency=medium

* Backport upstream fix for test failure with Python 3.13 (Closes: #1082401)
* Update all URLs to reference pynvim
* Declare compliance with Policy 4.7.0, no changes needed
* Mark test Build-Depends with <!nocheck> profile

-- James McCoy <jamessan@debian.org> Sun, 03 Nov 2024 00:20:57 -0400

python-pynvim (0.5.0-1) unstable; urgency=medium

[ Debian Janitor ]
* Update standards version to 4.6.2, no changes needed.

[ James McCoy ]
* Remove obsolete transitional package and Breaks/Replaces for
python3-neovim (Closes: #1038308)
* Remove obsolete Breaks on neovim < 0.2.1
* Remove mention of non-existent python2 package in long description
* New upstream release
+ Python 3.12 support (Closes: #1056498)
* Add pybuild-plugin-pyproject to Build-Depends

-- James McCoy <jamessan@debian.org> Wed, 06 Dec 2023 11:03:30 -0500

python-pynvim (0.4.2-2) unstable; urgency=medium

* Bump debhelper from old 12 to 13.
Expand Down
31 changes: 11 additions & 20 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,36 @@ Rules-Requires-Root: no
Build-Depends:
debhelper-compat (= 13),
dh-python,
pybuild-plugin-pyproject,
python3-all,
python3-setuptools,
# dependencies for python3:
python3-msgpack (>= 0.5.0),
python3-greenlet,
python3-greenlet (>= 3.0),
python3-typing-extensions | python3 (>= 3.12),
# dependencies for tests:
neovim (>= 0.2.1),
python3-pytest (>= 3.4.0),
neovim (>= 0.10) <!nocheck>,
python3-pytest (>= 3.4.0) <!nocheck>,
python3-pytest-timeout <!nocheck>,
# dependencies for setup:
python3-pytest-runner,
Standards-Version: 4.5.1
Homepage: https://github.com/neovim/python-client
Standards-Version: 4.7.0
Testsuite: autopkgtest-pkg-pybuild
Homepage: https://github.com/neovim/pynvim
Vcs-Git: https://salsa.debian.org/python-team/packages/python-pynvim.git
Vcs-Browser: https://salsa.debian.org/python-team/packages/python-pynvim

Package: python3-neovim
Architecture: all
Depends:
python3-pynvim,
${misc:Depends}
Section: oldlibs
Description: transitional dummy package
This is a transitional dummy package. It can safely be removed.

Package: python3-pynvim
Architecture: all
Depends:
${misc:Depends},
${python3:Depends}
${python3:Depends},
python3-greenlet (>= 3.0),
Provides:
python3-neovim (= ${source:Version}),
${python3:Provides},
vim-python3,
Breaks: neovim (<< 0.2.1), python3-neovim (<< 0.4.0~)
Replaces: python3-neovim (<< 0.4.0~)
Recommends: neovim
Description: Python3 library for scripting Neovim processes through its msgpack-rpc API
Neovim is a Vim fork that focuses on refactoring, extensibility and
simplification of the original code base.
.
This is the Python3 version of the package (If you only use one of python2 or
python3, it is enough to install that version.)
6 changes: 4 additions & 2 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: pynvim
Source: https://github.com/neovim/python-client
Source: https://github.com/neovim/pynvim
Upstream-Contact: Thiago de Arruda <tpadilha84@gmail.com>


Expand All @@ -18,7 +18,9 @@ License: Apache-2.0


Files: debian/*
Copyright: 2015-2016 Víctor Cuadrado Juan <me@viccuad.me>
Copyright:
2015-2016 Víctor Cuadrado Juan <me@viccuad.me>
2019-2024 James McCoy <jamessan@debian.org>
License: Apache-2.0


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From e94d68acb888daed31f79c61fb9bca052727e537 Mon Sep 17 00:00:00 2001
From: James McCoy <jamessan@jamessan.com>
Date: Wed, 12 Mar 2025 17:18:57 -0400
Subject: [PATCH] fix(test_connect_stdio): invoke python3 instead of python

"python" is the name for Python 2's interpreter. Since pynvim is now
Python 3 only, there's no reason to expect the legacy interpreter to be
available.
---
test/test_attach.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test_attach.py b/test/test_attach.py
index c1588ca..25d0822 100644
--- a/test/test_attach.py
+++ b/test/test_attach.py
@@ -125,7 +125,7 @@ def test_connect_stdio(vim: Nvim) -> None:
])
# see :help jobstart(), *jobstart-options* |msgpack-rpc|
jobid = vim.funcs.jobstart([
- 'python', '-c', remote_py_code,
+ 'python3', '-c', remote_py_code,
], {'rpc': True, 'on_stderr': 'OutputHandler'})
assert jobid > 0
exitcode = vim.funcs.jobwait([jobid], 500)[0]
--
2.47.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From c3fe99344d1c3f788b160fffc9e019f6b7bf3eca Mon Sep 17 00:00:00 2001
From: Jongwook Choi <wookayin@gmail.com>
Date: Sun, 5 Jan 2025 22:20:38 -0500
Subject: [PATCH] fix(tests): skip failing test_broadcast on neovim < 0.11

The fix made in #570 actually works for Nvim 0.11+, depending on the
behavior change neovim/neovim#28487.

We should just skip test_broadcast on older Nvim versions (see #585).
---
test/test_events.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/test/test_events.py b/test/test_events.py
index c978293..ee481d9 100644
--- a/test/test_events.py
+++ b/test/test_events.py
@@ -1,4 +1,5 @@
-# -*- coding: utf-8 -*-
+import pytest
+
from pynvim.api import Nvim


@@ -37,6 +38,10 @@ def test_async_error(vim: Nvim) -> None:


def test_broadcast(vim: Nvim) -> None:
+ if (vim.version.major, vim.version.minor) < (0, 11):
+ # see #570, neovim/neovim#28487
+ pytest.skip("neovim/neovim#28487")
+
vim.command('call rpcnotify(0, "event1", 1, 2, 3)')
vim.command('call rpcnotify(0, "event2", 4, 5, 6)')
vim.command('call rpcnotify(0, "event2", 7, 8, 9)')
--
2.47.2

18 changes: 18 additions & 0 deletions debian/patches/increase-jobwait-timeout.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Description: test_attach: Increase jobwait timeout
Slower architectures, like riscv64, aren't completing the job
in 500ms and therefore the test fails.
Author: James McCoy <jamessan@debian.org>
---
diff --git i/test/test_attach.py w/test/test_attach.py
index 25d0822..e64fc81 100644
--- i/test/test_attach.py
+++ w/test/test_attach.py
@@ -128,7 +128,7 @@ def test_connect_stdio(vim: Nvim) -> None:
'python3', '-c', remote_py_code,
], {'rpc': True, 'on_stderr': 'OutputHandler'})
assert jobid > 0
- exitcode = vim.funcs.jobwait([jobid], 500)[0]
+ exitcode = vim.funcs.jobwait([jobid], 5000)[0]
messages = vim.command_output('messages')
assert exitcode == 0, ("the python process failed, :messages =>\n\n" +
messages)
3 changes: 3 additions & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fix-tests-skip-failing-test_broadcast-on-neovim-0.11.patch
fix-test_connect_stdio-invoke-python3-instead-of-pyt.patch
increase-jobwait-timeout.patch
Loading
Loading