From 64bbcf3cfa11e44c5ef5af5be7970e2ee8c6bd38 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 20 Oct 2018 22:07:25 +0100 Subject: [PATCH] cli: add working `--manpath` --- setup.py | 4 ++-- tqdm/_main.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 22f93feab..a026276d3 100755 --- a/setup.py +++ b/setup.py @@ -182,8 +182,8 @@ def execute_makefile_commands(commands, alias, verbose=False): platforms=['any'], packages=['tqdm'] + ['tqdm.' + i for i in find_packages('tqdm')], entry_points={'console_scripts': ['tqdm=tqdm._main:main'], }, - # data_files=[('man/man1', ['tqdm.1'])], - package_data={'': ['CONTRIBUTING.md', 'LICENCE', 'examples/*.py']}, + package_data={'tqdm': ['CONTRIBUTING.md', 'LICENCE', 'examples/*.py', + 'tqdm.1']}, long_description=README_rst, python_requires='>=2.6, !=3.0.*, !=3.1.*', classifiers=[ diff --git a/tqdm/_main.py b/tqdm/_main.py index 2d32ac593..10a7aeee6 100644 --- a/tqdm/_main.py +++ b/tqdm/_main.py @@ -109,7 +109,7 @@ def posix_pipe(fin, fout, delim='\n', buf_size=256, bytes : bool, optional If true, will count bytes, ignore `delim`, and default `unit_scale` to True, `unit_divisor` to 1024, and `unit` to 'B'. - man_path : str, optional + manpath : str, optional Directory in which to install tqdm man pages. log : str, optional CRITICAL|FATAL|ERROR|WARN(ING)|[default: 'INFO']|DEBUG|NOTSET. @@ -191,13 +191,13 @@ def main(fp=sys.stderr): buf_size = tqdm_args.pop('buf_size', 256) delim = tqdm_args.pop('delim', '\n') delim_per_char = tqdm_args.pop('bytes', False) - man_path = tqdm_args.pop('man_path', None) - if man_path is not None: + manpath = tqdm_args.pop('manpath', None) + if manpath is not None: from os import path from shutil import copyfile - fi = path.dirname(path.dirname(path.abspath(__file__))) - fi = path.join(fi, 'tqdm.1') - fo = path.join(man_path, 'tqdm.1') + from pkg_resources import resource_filename, Requirement + fi = resource_filename(Requirement.parse('tqdm'), 'tqdm/tqdm.1') + fo = path.join(manpath, 'tqdm.1') copyfile(fi, fo) log.info("written:" + fo) sys.exit(0)