Skip to content
Snippets Groups Projects
Commit d6071d0f7edb authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

packaging: define `poulpe` as both a package and a CLI

This makes it easier for users to just `pip install poulpe` as well as
use `poulpe SUBCOMMAND SUBCOMMAND_ARGS` instead of manipulating $PATH.
parent 560613c17607
No related branches found
No related tags found
1 merge request!22Package poulpe and add a tiny CLI wrapper for utils
from importlib import resources
import subprocess
import click
@click.command(
no_args_is_help=True,
context_settings={
"ignore_unknown_options": True,
"allow_interspersed_args": False,
},
)
@click.argument('subcommand')
@click.argument('subcommand_args', nargs=-1, type=click.UNPROCESSED)
def exec_subcommand(subcommand, subcommand_args):
"""Wrapper around Poulpe binaries for ease of calling"""
subcommand_file = resources.files("poulpe.bin").joinpath(subcommand)
if not subcommand_file.is_file():
raise click.BadParameter(f"Subcommand `{subcommand}` does not exist.")
with resources.as_file(subcommand_file) as f:
cmd = [str(f)] + list(subcommand_args)
exit(subprocess.call(cmd))
if __name__ == '__main__':
exec_subcommand()
......@@ -2,4 +2,12 @@
name = poulpe
version = 0.0.0
[options]
install_requires =
click == 8.1
importlib-resources
toml
packages = find_namespace:
package_dir =
= python-libs
......@@ -5,7 +13,5 @@
[options]
packages=poulpe
package_dir=
=python-libs
[options.package_data]
poulpe.bin = *
[options.packages.find]
......@@ -10,3 +16,7 @@
[options.packages.find]
where=python-libs
where = python-libs
[options.entry_points]
console_scripts =
poulpe = poulpe.cli:exec_subcommand
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment