Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 317693 - dev-python/twisted-10.0.0, dev-python/virtualenv-1.4.7: twistd losing paths set by virtualenv
Summary: dev-python/twisted-10.0.0, dev-python/virtualenv-1.4.7: twistd losing paths s...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-29 02:08 UTC by Max Khardin
Modified: 2014-03-15 20:46 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Max Khardin 2010-04-29 02:08:55 UTC
If you create virtualenv, switch to it, install some packages, required by your twisted application and try to run this app using twistd - you'll get some errors about importing modules. AFAIU this happens because Gentoo has modified version of twistd, which restarts itself and loses PYTHONPATH set while in virtualenv

Reproducible: Always

Steps to Reproduce:
Comment 1 Ewoud Kohl van Wijngaarden 2012-01-19 17:09:29 UTC
I can confirm the Gentoo wrapper scripts cause these problems. It executes /usr/bin/python2.7 instead of $HOME/.virtualenvs/$ENV/bin/python2.7 for me. I notice the same thing with ipython for example.

I think the following line should look in $PATH instead of a fixed path:
python_interpreter_path = "/usr/bin/%s" % python_interpreter
Comment 2 Jan Matějka (RETIRED) gentoo-dev 2013-06-21 14:21:26 UTC
still a problem with twisted-11.0.0 and virtualenv-1.9.1-r1

Workaround:

    python `which twistd-${pyabi}` ${twistd_args}

Note ${pyabi} is the python abi you created the virtualenv with.
Comment 3 Jan Matějka (RETIRED) gentoo-dev 2014-03-15 07:51:30 UTC
reproducer::

    # emerge twisted-core virtualenv
    $ python -c 'import txjsonrpc' 2>&1 | grep 'No module' >/dev/null || (echo "precondition fail" && exit 1)
    $ virtualenv --system-site-packages tx
    $ cd tx
    $ . ./bin/activate
    $ echo "import sys\nprint sys.path\nimport txjsonrpc\nsys.exit()" > a.tac
    $ twistd -y a.tac
    $ python `which twistd` -y a.tac
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-03-15 20:46:23 UTC
Mixing system-installed stuff with virtualenv is plain unsupported. And even then, python-exec is not the place for hacks to support random Python environments.

If you change twistd script to use '/usr/bin/env python...' rather than '/usr/bin/python...', it works as you want it to. Feel free to start encouraging people to use that shebang.