5

I need psycopg2 and lxml for my tests, but when I try to install it in a virtualenv through tox it fails due to the missing pg_conf or other dependencies.

I found this explanation of bootstrap scripts: http://www.virtualenv.org/en/latest/index.html#bootstrap-example

How can I add a bootstrap script to tox's virtualenv? Do you know any good examples for my concerns (lxml and psycopg2)?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Jon
  • 11,356
  • 5
  • 40
  • 74
  • I had the exact same problem and tried various ways to solve it reliably. Whether `pg_config` is on `$PATH` or not also depends on the OS and how Postgres was installed. In the end I decided to just put `pg_config` on my $PATH from my `.profile` and be done with it. – Feuermurmel Aug 25 '16 at 07:59

1 Answers1

5

I don’t think you can use bootstrap scripts (as described in the virtualenv docs) with tox. However, you can configure your tox.ini file to install Python dependencies that are not specified in setup.py, and run arbitrary commands before running tests. From the tox home page:

# content of: tox.ini , put in same dir as setup.py
[tox]
envlist = py26,py27
[testenv]
deps=pytest       # install pytest in the venvs
commands=py.test  # or 'nosetests' or ...

deps and commands are actually lists:

deps=
    lxml
    psycopg2
    pytest
commands=
    ./some_other_script.sh
    py.test

But forget about bootstrap scripts and take a step back. What is the original problem with pg_conf?

Simon Sapin
  • 9,790
  • 3
  • 35
  • 44