Nixpkgs: virtualenvwrapper wrapper in a Python environment

Created on 19 Oct 2017  路  5Comments  路  Source: NixOS/nixpkgs

Issue description

I'm not sure how virtualenvwrapper is meant to be used in a Python environment:

  • sourcing with e.g. source $(command -v virtualenvwrapper.sh) (the intended usage) immediately ends the shell
  • running virtualenvwrapper.sh directly does not set the shell commands etc. (as expected)

On a non-environment install sourcing the script behaves as expected. I believe the difference is that as part of the Python buildEnv process the script is wrapped as if it were a more traditional executable:

$ cat $(command -v virtualenvwrapper.sh)
#! /nix/store/h404wfcz8rzzlq8vr4z7plcijwzfci72-bash-4.4-p12/bin/bash -e
export PYTHONHOME="/nix/store/r9k7vl4g45j0vycmx99w8iypvm3646bp-python3-3.6.2-env"
export PYTHONNOUSERSITE="true"
exec "/nix/store/v2771vzbpmflbmgbf06ls8l3sf3z5wal-python3.6-virtualenvwrapper-4.3/bin/virtualenvwrapper.sh"  "${extraFlagsArray[@]}" "$@"

When sourced, that final exec ends the interactive session.

Steps to reproduce

$ nix-shell --command bash --pure -p bashInteractive 'python3.withPackages (ps: with ps; [ virtualenvwrapper ])'
(nix)$ source $(command -v virtualenvwrapper.sh)
$ # nix-shell session ended prematurely

Compare with a non-environment install: nix-shell --command bash --pure -p bashInteractive python3.pkgs.virtualenvwrapper, which does not end the session prematurely.

Technical details

  • System: NixOS 18.03pre118082.00e56fbbee (Impala)
  • Nix version: 1.11.15
  • Nixpkgs version: 18.03pre118082.00e56fbbee
  • Sandboxing enabled: no
question python

Most helpful comment

@alanctkc I source the result of substituting source for exec in the wrapper script:

source <(sed 's/exec/source/' $(command -v virtualenvwrapper.sh))

All 5 comments

I still experience the same about a year later! Find any workaround?

@alanctkc I source the result of substituting source for exec in the wrapper script:

source <(sed 's/exec/source/' $(command -v virtualenvwrapper.sh))

Hi, I just had the same issue. The wiki page at https://nixos.wiki/wiki/Python also suggests installting virtualenvwrapper in the python environment, which leads to the shell exiting when sourcing virtualenvwrapper.sh. Will there be any fix?

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

still important to me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rzetterberg picture rzetterberg  路  3Comments

ob7 picture ob7  路  3Comments

spacekitteh picture spacekitteh  路  3Comments

langston-barrett picture langston-barrett  路  3Comments

lverns picture lverns  路  3Comments