-4

I was trying to run pip install libarchive in a virtualenv, but it failed:

(.env) $ pip install libarchive
Downloading/unpacking libarchive
  Downloading libarchive-0.4.3.tar.gz
  Running setup.py egg_info for package libarchive
Requirement already satisfied (use --upgrade to upgrade): nose in /var/tmp/.env/lib/python2.6/site-packages (from libarchive)
Installing collected packages: libarchive
  Running setup.py install for libarchive
    Verifying that the library is accessible.
    Library can not be loaded: libarchive.so: cannot open shared object file: No such file or directory
    error: None
    Complete output from command /var/tmp/.env/bin/python -c "import setuptools;
 __file__='/var/tmp/.env/build/libarchive/setup.py'; execfile('/var/tmp/.env/build/libarchive/setup.py')" install --single-version-externally-managed --record /tmp/pip-1hz9vY-record/install-record.txt --install-headers /var/tmp/.env/include/site/python2.6:
    running install

Verifying that the library is accessible.

Library can not be loaded: libarchive.so: cannot open shared object file: No such file or directory

error: None

----------------------------------------
Command /var/tmp/.env/bin/python -c "import setuptools; __file__='/var/tmp/.env/build/libarchive/setup.py'; execfile('/var/tmp/.env/build/libarchive/setup.py')" install --single-version-externally-managed --record /tmp/pip-1hz9vY-record/install-record.txt --install-headers /var/tmp/.env/include/site/python2.6 failed with error code 1
Storing complete log in /home/me/.pip/pip.log

The error message is not very helpful, but I guess the problem is that the binary package libarchive13 (or, for Debian Squeeze, libarchive1) is not installed.

I do not have installation privileges (much less root) on this system, and need to be able to deploy to systems where users are in a similar predicament. Is there a way to do that?

(The libarchive documentation suggests that there is a problem with the .so symlink on Ubuntu, but this is happening on Debian -- and anyway, I was unable to find any public bug report about this dispute. Pertinent, but tangential -- I may need an additional workaround after getting the package installed.)

tripleee
  • 175,061
  • 34
  • 275
  • 318

1 Answers1

0

Not really a proper answer, but the beginnings of a possible workaround.

For each required library, download a local .deb and extract it, then copy necessary files into the virtualenv. I'm taking a shortcut here and simply omitting the manuals, usr/share/doc, etc. (The local stash doesn't really have to be inside the virtualenv tree, of course -- anywhere you have write access is fine, but it makes sense to keep it in the virtualenv.)

vnix$ mkdir -p debs/x

vnix$ fakeroot apt-get install -y --print-uris libarchive13 |
> sed -n "s!.*'\(http://[^' ]*\.deb\)'.*!\1!p" |
> xargs -r wget -nc -P debs

vnix$ for deb in debs/*.deb; do
>  dpkg -x "$deb" debs/x
> done

vnix$ mv debs/x/lib/* debs/x/usr/lib/* virtualenv/lib

# Then finally
vnix$ export LD_LIBRARY_PATH=$PWD/virtualenv/lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}

The last part should probably be added to your activate script, as suggested here: virtualenv that can find relocated libraires (like mysqlclient lib for MySQLdb)

Merely copying libraries into a directory in LD_LIBRARY_PATH is obviously only viable for extremely simple libraries. If the deb package contains a postinst script or some other configuration actions, or contains code which hardcodes locations in the /usr file system, for example, this will obviously fail.

(The fakeroot apt-get install --print-uris business is extremely ugly, but I could not find a better way to recursively download dependencies from a well-defined locally configured Debian mirror. Note that it may download more than one package.)

Community
  • 1
  • 1
tripleee
  • 175,061
  • 34
  • 275
  • 318