Skip to content

How to use with tox #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
graingert opened this issue Jul 8, 2014 · 7 comments
Closed

How to use with tox #30

graingert opened this issue Jul 8, 2014 · 7 comments

Comments

@graingert
Copy link
Contributor

At the moment we use tox to build our virtualenvs before tests.

It doesn't seem possible to call an externally installed pip-accel from within another virtualenv (it installs it to the host virtualenv), nor to install pip-accel into the virtualenv before the install process of tox starts

@xolox
Copy link
Member

xolox commented Jul 8, 2014

It would help your cause (resolving this issue) if you provided more information:

  • I don't know what "the movement" is, nor do I know whether this is relevant to the topic at hand;
  • You're talking about two different virtual environments being involved, which sounds kind of fragile (although I assume you have your reasons);
  • I'm familiar with tox as a user but I haven't seen it from the inside and I kind of don't like how it has its own way of setting up "the test environment", so indeed it could turn out to be tricky to solve this, but really it all depends on where and how and why tox is run.

pip-accel aims to be a drop in replacement to pip but it does have different semantics which sometimes makes the "drop in" part problematic :-). Also it requires both the Python pip package and the pip command to be installed (the second part is an implementation detail which I might try to solve).

Long story short: In order to help you with this issue I need a lot more information. If possible, something I can run myself to avoid remote debugging using GitHub messages as a proxy ;-).

@graingert
Copy link
Contributor Author

Fixed up some of the Typos.

The trouble I'm having is installing pip-accel so that Tox's "install_command" can run it.

here's an example tox.ini

# content of: tox.ini , put in same dir as setup.py
[tox]
install_command = pip-accel install --pre {opts} {packages}
envlist = py26,py27
[testenv]
deps=
    pip-accel     # not installed before install_command is run (to install pip-accel)
    pytest        # install pytest in the venvs
commands=py.test  # or 'nosetests' or ...

@xolox
Copy link
Member

xolox commented Jul 8, 2014

Ah, s/movement/moment/. That makes more sense, thank you :-). I think I found something that works, although it's a bit of a (creative) hack.

First create the shell script ~/bin/pip-accel-for-tox with the following contents (don't forget to make the file executable):

#!/bin/bash

BIN_DIR="$(echo $PATH | tr : '\n' | head -n1)"
export VIRTUAL_ENV="$(dirname "$BIN_DIR")"
if [ ! -x "$VIRTUAL_ENV/bin/pip-accel" ]; then
  "$VIRTUAL_ENV/bin/pip" install pip-accel
fi
"$VIRTUAL_ENV/bin/pip-accel" install --pre "$@"

Then add the following install_command definition to your tox.ini:

install_command = pip-accel-for-tox {opts} {packages}

Tox will print a warning because the install command is located outside the test environment, but it will still execute the install command and this seems to work fine...

Does this help?

@graingert
Copy link
Contributor Author

You can whitelist that command. This looks very useful.

I'll raise a PR with that bash script in the docs that fixes this issue.
On 8 Jul 2014 20:51, "Peter Odding" [email protected] wrote:

Ah, s/movement/moment/. That makes more sense, thank you :-). I think I
found something that works, although it's a bit of a (creative) hack.

First create the shell script ~/bin/pip-accel-for-tox with the following
contents (don't forget to make the file executable):

#!/bin/bash
BIN_DIR="$(echo $PATH | tr : '\n' | head -n1)"export VIRTUAL_ENV="$(dirname "$BIN_DIR")"if [ ! -x "$VIRTUAL_ENV/bin/pip-accel" ]; then
"$VIRTUAL_ENV/bin/pip" install pip-accelfi"$VIRTUAL_ENV/bin/pip-accel" install --pre "$@"

Then add the following install_command definition to your tox.ini:

install_command = pip-accel-for-tox {opts} {packages}

Tox will print a warning because the install command is located outside
the test environment, but it will still execute the install command and
this seems to work fine...

Does this help?

Reply to this email directly or view it on GitHub
#30 (comment).

xolox added a commit that referenced this issue Oct 26, 2014
@xolox
Copy link
Member

xolox commented Oct 26, 2014

I'm closing this issue now because there's nothing more for me to do here. I did add a link to this issue in the readme (which is also the homepage on GitHub and PyPI) so that other users can more easily find how to do this.

@xolox xolox closed this as completed Oct 26, 2014
@bh
Copy link

bh commented Jan 16, 2015

I got the same issue a half year ago.
I fixed it with setting the VIRTUAL_ENV env variable in tox.ini:

[tox]
skipsdist = True
envlist = py34
toxworkdir = {toxinidir}/.tox

[testenv]
# on jenkins we always recreate the whole
# workspace, so tox will be implicitly recreated
recreate = False
whitelist_externals = make
setenv =
    VIRTUAL_ENV={toxworkdir}/{envname}
    DJANGO_CONFIGURATION=Jenkins

# run the commands in a Makefile target to exit if one command failes
# https://bitbucket.org/hpk42/tox/issue/124/ignore-command-exit-codes
commands = make ci_run_tests

@hashar
Copy link

hashar commented Jul 27, 2015

tox 1.8+ should now export VIRTUAL_ENV. At least according to https://bitbucket.org/hpk42/tox/issues/152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants