Question

I have created a simple Python module and want to distribute it with pip. I also want to install a Bash completion file together with the module. I'm installing the module with Python 2.7.1+ and pip 0.8.2.

I have this setup.py:

setup(
    name='jenkinsmon',
    version='0.0.1',
    description='Jenkins Job Monitor',
    long_description=open('README.txt').read(),
    scripts=['bin/jenkinsmon'],
    data_files=[
        ('/etc/bash_completion.d', ['extras/jenkinsmon.completion']),
    ],
    install_requires = [
        'autojenkins',
        'argparse'
    ],
)

Now if I try to install the package with pip install -e ., the Bash completion file never gets installed together with the package. I also tried workarounds by specifying a MANIFEST.in, like described here:

MANIFEST.in:

include extras/jenkinsmon.completion

But this also doesn't help - the completion files won't get installed. What can I do to install the Bash completion files?

Was it helpful?

Solution 2

My error (besides not reading the pip-documentation in general) was just to add -e to the pip install parameters, which means to install in "editable" mode. To quote the documentation

Using the --editable or -e option, pip has the capability to install directly from a version control repository (it currently supports Subversion, Mercurial, Git, and Bazaar):

pip install -e svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev

This option shells out to the commandline client for each respective VCS, so you must have the VCS installed on your system. The repo URL must begin with svn+ (or hg+, git+, or bzr+) and end with #egg=packagename; otherwise, pip supports the same URL formats and wire protocols supported by the VCS itself.

Pip will checkout the source repo into a src/ directory inside the virtualenv (i.e. pip_test_env/src/initools-dev), and then run python setup.py develop in that source repo. This “links” the code directly from the repo into the virtualenv’s site-packages directory (by adding the repo directory into easy-install.pth), so changes you make in the source checkout are effective immediately.

If you already have a local VCS checkout you want to keep using, you can just use pip install -e path/to/repo to install it “editable” in the same way.

So to install the package permanently into the System, I have to remove -r, then the Bash-completion files are installed as expected.

OTHER TIPS

MANIFEST.in only describes additional files to be included in source distributions; it has nothing to do with installing.

Does the file get installed if you run python setup.py install? pip relies on setuptools, so maybe it inherits its behavior of installing everything in only one “egg” directory/zipfile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top