Skip to content

Commit 7605220

Browse files
committed
Fix plover_plugins install command
1 parent c585a3d commit 7605220

File tree

5 files changed

+95
-77
lines changed

5 files changed

+95
-77
lines changed

.github/workflows/ci/skiplist_default.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ CONTRIBUTING.md
99
NEWS.md
1010
README.md
1111
doc/*
12-
launch.bat
13-
launch.sh
1412
linux/README.md
1513
linux/packpack.mk
1614
linux/packpack.sh

MANIFEST.in

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ recursive-include doc *.png
99
recursive-include doc *.svg
1010
recursive-include doc *.py
1111
recursive-include doc *.txt
12-
include launch.bat
13-
include launch.sh
1412
include linux/*
1513
include linux/appimage/*
1614
include news.d/api/*
@@ -35,11 +33,4 @@ include test/*.py
3533
include test/gui_qt/*.py
3634
include tox.ini
3735
include windows/*
38-
# Exclude: CI/Git/GitHub specific files,
39-
# as well as generated Python files (UI).
40-
exclude .gitignore
41-
exclude .readthedocs.yml
42-
exclude plover/gui_qt/*_rc.py
4336
exclude plover/gui_qt/*_ui.py
44-
exclude plover/gui_qt/.gitignore
45-
prune .github

plover/gui_qt/plugins_manager.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -21,72 +21,6 @@
2121
from plover.plugins_manager.utils import running_under_virtualenv
2222

2323

24-
def list_plugins(freeze=False):
25-
installed_plugins = local_registry.list_plugins()
26-
if freeze:
27-
available_plugins = {}
28-
else:
29-
available_plugins = global_registry.list_plugins()
30-
for name, installed, available in sorted(
31-
(name,
32-
installed_plugins.get(name, []),
33-
available_plugins.get(name, []))
34-
for name in set(itertools.chain(installed_plugins,
35-
available_plugins))
36-
):
37-
latest = available[-1] if available else None
38-
current = installed[-1] if installed else None
39-
info = latest or current
40-
if freeze:
41-
if current:
42-
print('%s==%s' % (current.name, current.version))
43-
continue
44-
print('%s (%s) - %s' % (info.name, info.version, info.summary))
45-
if current:
46-
print(' INSTALLED: %s' % current.version)
47-
if latest:
48-
print(' LATEST: %s' % latest.version)
49-
50-
51-
def pip(args, stdin=None, stdout=None, stderr=None, **kwargs):
52-
cmd = [sys.executable, '-m',
53-
'plover.plugins_manager.pip_wrapper',
54-
'--disable-pip-version-check']
55-
env = dict(os.environ)
56-
# Make sure user plugins are handled
57-
# even if user site is not enabled.
58-
if not running_under_virtualenv() and not site.ENABLE_USER_SITE:
59-
pypath = env.get('PYTHONPATH')
60-
if pypath is None:
61-
pypath = []
62-
else:
63-
pypath = pypath.split(os.pathsep)
64-
pypath.insert(0, site.USER_SITE)
65-
env['PYTHONPATH'] = os.pathsep.join(pypath)
66-
command = args.pop(0)
67-
if command == 'check':
68-
cmd.append('check')
69-
elif command == 'install':
70-
cmd.extend((
71-
'install',
72-
'--upgrade-strategy=only-if-needed',
73-
))
74-
if not running_under_virtualenv():
75-
cmd.append('--user')
76-
elif command == 'uninstall':
77-
cmd.append('uninstall')
78-
elif command == 'list':
79-
cmd.extend((
80-
'list',
81-
'--format=columns',
82-
))
83-
else:
84-
raise ValueError('invalid command: %s' % command)
85-
cmd.extend(args)
86-
return subprocess.Popen(cmd, env=env, stdin=stdin,
87-
stdout=stdout, stderr=stderr,
88-
**kwargs)
89-
9024
class PluginsManager(Tool, Ui_PluginsManager):
9125

9226
TITLE = 'Plugins Manager'

plover/plugins_manager/__main__.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
import os
3+
import subprocess
4+
import site
5+
import sys
6+
7+
from plover.plugins_manager import global_registry,local_registry
8+
from plover.plugins_manager.utils import running_under_virtualenv
9+
10+
11+
12+
def pip(args, stdin=None, stdout=None, stderr=None, **kwargs):
13+
cmd = [sys.executable, '-m',
14+
'plover.plugins_manager.pip_wrapper',
15+
'--disable-pip-version-check']
16+
env = dict(os.environ)
17+
# Make sure user plugins are handled
18+
# even if user site is not enabled.
19+
if not running_under_virtualenv() and not site.ENABLE_USER_SITE:
20+
pypath = env.get('PYTHONPATH')
21+
if pypath is None:
22+
pypath = []
23+
else:
24+
pypath = pypath.split(os.pathsep)
25+
pypath.insert(0, site.USER_SITE)
26+
env['PYTHONPATH'] = os.pathsep.join(pypath)
27+
command = args.pop(0)
28+
if command == 'check':
29+
cmd.append('check')
30+
elif command == 'install':
31+
cmd.extend((
32+
'install',
33+
'--upgrade-strategy=only-if-needed',
34+
))
35+
if not running_under_virtualenv():
36+
cmd.append('--user')
37+
elif command == 'uninstall':
38+
cmd.append('uninstall')
39+
elif command == 'list':
40+
cmd.extend((
41+
'list',
42+
'--format=columns',
43+
))
44+
else:
45+
raise ValueError('invalid command: %s' % command)
46+
cmd.extend(args)
47+
return subprocess.Popen(cmd, env=env, stdin=stdin,
48+
stdout=stdout, stderr=stderr,
49+
**kwargs)
50+
51+
def list_plugins(freeze=False):
52+
installed_plugins = local_registry.list_plugins()
53+
if freeze:
54+
available_plugins = {}
55+
else:
56+
available_plugins = global_registry.list_plugins()
57+
for name, installed, available in sorted(
58+
(name,
59+
installed_plugins.get(name, []),
60+
available_plugins.get(name, []))
61+
for name in set(itertools.chain(installed_plugins,
62+
available_plugins))
63+
):
64+
latest = available[-1] if available else None
65+
current = installed[-1] if installed else None
66+
info = latest or current
67+
if freeze:
68+
if current:
69+
print('%s==%s' % (current.name, current.version))
70+
continue
71+
print('%s (%s) - %s' % (info.name, info.version, info.summary))
72+
if current:
73+
print(' INSTALLED: %s' % current.version)
74+
if latest:
75+
print(' LATEST: %s' % latest.version)
76+
77+
78+
def main(args=None):
79+
if args is None:
80+
args = sys.argv[1:]
81+
if args[0] == 'list_plugins':
82+
assert len(args) <= 2
83+
if len(args) > 1:
84+
assert args[1] == '--freeze'
85+
freeze = True
86+
else:
87+
freeze = False
88+
sys.exit(list_plugins(freeze=freeze))
89+
proc = pip(args)
90+
sys.exit(proc.wait())
91+
92+
93+
if __name__ == '__main__':
94+
main()

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ packages =
5858
[options.entry_points]
5959
console_scripts =
6060
plover = plover.scripts.main:main
61+
plover_plugins = plover.plugins_manager.__main__:main
6162
plover_send_command = plover.scripts.send_command:main
6263
plover.command =
6364
set_config = plover.command.set_config:set_config

0 commit comments

Comments
 (0)