How to install/uninstall manpages with distutils/setuptools?

Santosh Kumar sntshkmr60 at gmail.com
Sat Apr 13 16:25:20 EDT 2013


Hey,

I have an app hosted on PyPi, it actually is a small script which is
in bin/ directory of the project. Here is the part of setup.py file of
my app:

#!/usr/bin/env python
#-*- coding: utf-8 -*-

import sys, os, shutil
try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

__AUTHOR__ = 'Santosh Kumar'
__AUTHOR_EMAIL__ = 'user at domain.com'

setup(
    name='sampleapp',
    version='1.02.02',
    author=__AUTHOR__,
    author_email=__AUTHOR_EMAIL__,
    packages=['sampler'],
    scripts=['bin/sampler'],
    url='https://github.com/sampleapp/sampleapp',
    zip_safe=False,
    include_package_data=True,
    license=open('LICENSE').read(),
    description='A sample application',
    long_description=open('README.rst').read()
)

if 'install' in sys.argv:
    man_path = '/usr/share/man/man1/'
    if os.path.exists(man_path):
        print("Installing man pages")
        man_page = "doc/sampleapp.1.gz"
        shutil.copy2(man_page, man_path)
        os.chmod(man_path + 'sampleapp.1.gz', int('444', 8))

When uploaded on PyPi, this app can be installed either by downloading
the archive form https://pypi.python.org/pypi/ and doing python
setup.py install or by easy_install or pip. pip is my favorite because
it supports uninstall option.

I can install this app (script) with pip with no problem (to
/usr/bin/). But I can't install the manpage to /usr/share/man/man1/.
That is why I created installation of manpages in my setup.py.

So with the installation of manpages my installation is complete. But
the problem is I can't uninstall the manpages with `pip uninstall
sampleapp`, that will only uninstall the script. So my final question
is there any patch to make distutils install and uninstall man pages?

Please don't tell me about any other packages, I want to stick with
Python's own http://guide.python-distribute.org/



More information about the Python-list mailing list