cli: add 'hpi module install' and 'hpi module requires'
ci: use hpi module install; remove explicit module links relevant: - https://github.com/karlicoss/HPI/issues/12 - https://github.com/karlicoss/HPI/issues/79
This commit is contained in:
parent
97650adf3b
commit
0534c5c57d
3 changed files with 86 additions and 24 deletions
|
@ -320,6 +320,40 @@ def doctor(args: Namespace) -> None:
|
||||||
modules_check(args)
|
modules_check(args)
|
||||||
|
|
||||||
|
|
||||||
|
def _requires(module: str) -> Sequence[str]:
|
||||||
|
from .discovery_pure import module_by_name
|
||||||
|
mod = module_by_name(module)
|
||||||
|
# todo handle when module is missing
|
||||||
|
r = mod.requires
|
||||||
|
if r is None:
|
||||||
|
error(f"Module {module} has no REQUIRES specification")
|
||||||
|
sys.exit(1)
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
def module_requires(args: Namespace) -> None:
|
||||||
|
module: str = args.module
|
||||||
|
rs = [f"'{x}'" for x in _requires(module)]
|
||||||
|
eprint(f'dependencies of {module}')
|
||||||
|
for x in rs:
|
||||||
|
print(x)
|
||||||
|
|
||||||
|
|
||||||
|
def module_install(args: Namespace) -> None:
|
||||||
|
# TODO hmm. not sure how it's gonna work -- presumably people use different means of installing...
|
||||||
|
# how do I install into the 'same' environment??
|
||||||
|
user: bool = args.user
|
||||||
|
module: str = args.module
|
||||||
|
import shlex
|
||||||
|
cmd = [
|
||||||
|
sys.executable, '-m', 'pip', 'install',
|
||||||
|
*(['--user'] if user else []), # meh
|
||||||
|
*_requires(module),
|
||||||
|
]
|
||||||
|
eprint('Running: ' + ' '.join(map(shlex.quote, cmd)))
|
||||||
|
check_call(cmd)
|
||||||
|
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
def parser() -> ArgumentParser:
|
def parser() -> ArgumentParser:
|
||||||
p = ArgumentParser('Human Programming Interface', epilog='''
|
p = ArgumentParser('Human Programming Interface', epilog='''
|
||||||
|
@ -336,7 +370,7 @@ Work in progress, will be used for config management, troubleshooting & introspe
|
||||||
dp.set_defaults(func=doctor)
|
dp.set_defaults(func=doctor)
|
||||||
|
|
||||||
cp = sp.add_parser('config', help='Work with configuration')
|
cp = sp.add_parser('config', help='Work with configuration')
|
||||||
scp = cp.add_subparsers(dest='mode')
|
scp = cp.add_subparsers(dest='config_mode')
|
||||||
if True:
|
if True:
|
||||||
ccp = scp.add_parser('check', help='Check config')
|
ccp = scp.add_parser('check', help='Check config')
|
||||||
ccp.set_defaults(func=config_check_cli)
|
ccp.set_defaults(func=config_check_cli)
|
||||||
|
@ -348,6 +382,23 @@ Work in progress, will be used for config management, troubleshooting & introspe
|
||||||
mp.add_argument('--all' , action='store_true', help='List all modules, including disabled')
|
mp.add_argument('--all' , action='store_true', help='List all modules, including disabled')
|
||||||
mp.set_defaults(func=list_modules)
|
mp.set_defaults(func=list_modules)
|
||||||
|
|
||||||
|
op = sp.add_parser('module', help='Module management')
|
||||||
|
ops = op.add_subparsers(dest='module_mode')
|
||||||
|
if True:
|
||||||
|
add_module_arg = lambda x: x.add_argument('module', type=str, help='Module name (e.g. my.reddit)')
|
||||||
|
|
||||||
|
opsr = ops.add_parser('requires', help='Print module requirements')
|
||||||
|
# todo not sure, might be worth exposing outside...
|
||||||
|
add_module_arg(opsr)
|
||||||
|
opsr.set_defaults(func=module_requires)
|
||||||
|
|
||||||
|
# todo support multiple
|
||||||
|
opsi = ops.add_parser('install', help='Install module dependencies')
|
||||||
|
add_module_arg(opsi)
|
||||||
|
opsi.add_argument('--user', action='store_true', help='same as pip --user')
|
||||||
|
opsi.set_defaults(func=module_install)
|
||||||
|
# todo could add functions to check specific module etc..
|
||||||
|
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
'''
|
'''
|
||||||
Programmatic access and queries to org-mode files on the filesystem
|
Programmatic access and queries to org-mode files on the filesystem
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
REQUIRES = [
|
||||||
|
'orgparse',
|
||||||
|
]
|
||||||
|
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Sequence, Iterable, NamedTuple, Optional
|
from typing import List, Sequence, Iterable, NamedTuple, Optional
|
||||||
|
|
52
tox.ini
52
tox.ini
|
@ -4,28 +4,34 @@ minversion = 3.5
|
||||||
[testenv]
|
[testenv]
|
||||||
passenv = CI CI_*
|
passenv = CI CI_*
|
||||||
|
|
||||||
# TODO ugh. unclear how to reuse setup.cfg deps in tox
|
|
||||||
[testenv:tests]
|
# just the very core tests with minimal dependencies
|
||||||
|
[testenv:tests-core]
|
||||||
|
commands =
|
||||||
|
pip install -e .[testing]
|
||||||
|
python3 -m pytest \
|
||||||
|
tests/core.py \
|
||||||
|
tests/get_files.py \
|
||||||
|
{posargs}
|
||||||
|
|
||||||
|
|
||||||
|
# todo maybe also have core tests and misc tests? since ideally want them without dependencies
|
||||||
|
[testenv:tests-all]
|
||||||
# deliberately set to nonexistent path to check the fallback logic
|
# deliberately set to nonexistent path to check the fallback logic
|
||||||
|
# TODO not sure if need it?
|
||||||
setenv = MY_CONFIG = nonexistent
|
setenv = MY_CONFIG = nonexistent
|
||||||
commands =
|
commands =
|
||||||
# TODO core & modules should be tested separately?
|
|
||||||
|
|
||||||
pip install -e .[testing]
|
pip install -e .[testing]
|
||||||
# python -m pytest {posargs}
|
|
||||||
|
|
||||||
# TODO install via helper script..
|
hpi module install my.location.google
|
||||||
# my.location.google deps
|
pip install ijson # optional dependency
|
||||||
pip install geopy ijson
|
|
||||||
|
|
||||||
# my.time.tz.via_location dep
|
hpi module install my.time.tz.via_location
|
||||||
pip install timezonefinder
|
|
||||||
|
|
||||||
# my.calendar.holidays dep
|
hpi module install my.calendar.holidays
|
||||||
pip install workalendar
|
|
||||||
|
|
||||||
# my.body.weight dep
|
# my.body.weight dep
|
||||||
pip install orgparse
|
hpi module install my.orgmode
|
||||||
|
|
||||||
python3 -m pytest tests \
|
python3 -m pytest tests \
|
||||||
# ignore some tests which might take a while to run on ci..
|
# ignore some tests which might take a while to run on ci..
|
||||||
|
@ -45,7 +51,7 @@ commands =
|
||||||
whitelist_externals = cat
|
whitelist_externals = cat
|
||||||
commands =
|
commands =
|
||||||
pip install -e .[testing,optional]
|
pip install -e .[testing,optional]
|
||||||
pip install orgparse # used it core.orgparse?
|
pip install orgparse # used it core.orgmode?
|
||||||
# todo add tests?
|
# todo add tests?
|
||||||
python3 -m mypy -p my.core \
|
python3 -m mypy -p my.core \
|
||||||
--txt-report .coverage.mypy-core \
|
--txt-report .coverage.mypy-core \
|
||||||
|
@ -56,18 +62,18 @@ commands =
|
||||||
|
|
||||||
# specific modules that are known to be mypy compliant (to avoid false negatives)
|
# specific modules that are known to be mypy compliant (to avoid false negatives)
|
||||||
# todo maybe split into separate jobs? need to add comment how to run
|
# todo maybe split into separate jobs? need to add comment how to run
|
||||||
# and install dependencies via AST thing?
|
|
||||||
[testenv:mypy-misc]
|
[testenv:mypy-misc]
|
||||||
commands =
|
commands =
|
||||||
pip install -e .[testing,optional]
|
pip install -e .[testing,optional]
|
||||||
pip install orgparse
|
|
||||||
pip install git+https://github.com/karlicoss/endoexport
|
hpi module install my.orgmode
|
||||||
pip install git+https://github.com/karlicoss/ghexport
|
hpi module install my.endomondo
|
||||||
pip install git+https://github.com/karlicoss/hypexport
|
hpi module install my.github.ghexport
|
||||||
pip install git+https://github.com/karlicoss/instapexport
|
hpi module install my.hypothesis
|
||||||
pip install git+https://github.com/karlicoss/pockexport
|
hpi module install my.instapaper
|
||||||
pip install git+https://github.com/karlicoss/rexport
|
hpi module install my.pocket
|
||||||
pip install git+https://github.com/karlicoss/stexport
|
hpi module install my.reddit
|
||||||
|
hpi module install my.stackexchange.stexport
|
||||||
|
|
||||||
# TODO fuck. -p my.github isn't checking the subpackages?? wtf...
|
# TODO fuck. -p my.github isn't checking the subpackages?? wtf...
|
||||||
python3 -m mypy \
|
python3 -m mypy \
|
||||||
|
|
Loading…
Add table
Reference in a new issue