12

I maintain a custom-compiled Python installation in /opt/python-2.7.6. I expect man pages to be installed in share/man. I have installed several libraries already using pip (numpy, scipy, matplotlib, sympy). I'm not sure if they should come with man pages.

Now, I installed pygments. It comes with a binary called pygmentize, which is correctly installed in bin.

Sidetracking: I looked up the files in the Debian package python-pygments and it comes with a man page:

$ apt-file list python-pygments
...
/usr/share/man/man1/pygmentize.1.gz
...

Back to main topic: I do not want to install python-pygments with apt-get because it will be associated with the system Python. I want to keep using pip to maintain my custom Python installation. It should be easy to add the share/man directory to the MANPATH environment variable using .bashrc

export MANPATH=/opt/python-2.7.6/share/man:$MANPATH

Question: How do I use pip to install man pages together with the Python library?

Kit
  • 30,365
  • 39
  • 105
  • 149
  • 1
    I don't think the `pygmentize(1)` manpage actually comes with the source package; Debian adds manpages to a lot of commands in their `.deb` packages. – Fred Foo Nov 15 '13 at 14:38
  • 5
    @larsmans, do you think this is something I should bring up with the Python community, that man pages be included with `pip`-installed libraries? – Kit Nov 15 '13 at 15:00
  • 2
    There's usually not a lot of man pages with Python libraries, only occasionally do you find someone has actually included a man page for a script. Most Python documentation is found in the code itself, accessible through the shell CLI command 'pydoc' (inside the Python interpreter itself you can use help(obj|module) to get the same basic documentation. Some packages have advanced documentation using Sphinx (I think scipy, numpy and matplotlib all do, thats how their webpage documentations are generated) – synthesizerpatel Nov 15 '13 at 15:10

1 Answers1

7

The package does not have a man page, see here. It's the Debian policy that requires that each program adds a man page. Hence, the package installs one for you.

As a side note

If you maintain your own package, you can use the directive data_files in your setup.py:

setup(
    ...
    data_files = [('man/man1', ['path/to/your/manpage.1/'])],
)

If you would like to create a man page automatically for your program (if you are using argparse, take a look at my package man-utils.

tom
  • 21,844
  • 6
  • 43
  • 36
oz123
  • 27,559
  • 27
  • 125
  • 187
  • 1
    Maybe also point to e.g. https://linux.die.net/man/1/pygmentize which documents that the man page was created specifically for Debian in the *Author* section. – tripleee Jan 22 '18 at 12:37
  • Unfortunately, I can no longer pack a package with it. It does not find the file although it is obviously there and stored in the right place. Do you know what I can change ? error: can't copy 'nuseradd.1': doesn't exist or not a regular file –  May 19 '22 at 13:50
  • Can you please open an issue in the upstream repository with a full stack trace? – oz123 May 19 '22 at 19:36
  • Thanks for the option *data_files*. I would upvote that, but after @synthesizerpatel comment under the question, I think that manual pages should not be distributed with Python packages, because pip has no general way to install them. Another point is that it's always better to install with a system package (not pip), if that is available. So prepare a dedicated package for each system! That would be cleanest, I think. – Yaroslav Nikitenko Jun 23 '22 at 10:58
  • If you want to install the man page from the source directory, instead of `pip install -e .`, use `pip install .` in the root of the source. – Constantin Hong May 21 '23 at 22:03