From 18fc72a8facbccd12f520e7b1c3deb07172bc395 Mon Sep 17 00:00:00 2001 From: Nils Werner Date: Thu, 19 Nov 2015 12:55:53 +0100 Subject: [PATCH 1/4] Added simple solution of creating frameworkpython alias to OSX virtualenv fixing --- doc/faq/virtualenv_faq.rst | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/faq/virtualenv_faq.rst b/doc/faq/virtualenv_faq.rst index 89cf2736c8de..a51a38fb1681 100644 --- a/doc/faq/virtualenv_faq.rst +++ b/doc/faq/virtualenv_faq.rst @@ -77,7 +77,12 @@ The issue has been reported on the virtualenv bug tracker `here `__ and `here `__ -Until this is fixed, a workaround is needed. The best known workaround, +Until this is fixed, one of the following workarounds. + +``PYTHONHOME`` Script +--------------------- + +The best known workaround, borrowed from the `WX wiki `_, is to use the non virtualenv python along with the PYTHONHOME environment variable. This can be @@ -108,6 +113,21 @@ framework build within the virtualenv. To run a script you can do framework build. To run an interactive ``IPython`` session with the framework build within the virtual environment you can do ``frameworkpython -m IPython`` +``PYTHONHOME`` Alias +-------------------- + +Alternatively you can define an alias in your ``.bashrc`` using + +.. code:: bash + + alias frameworkpython='PYTHONHOME=$VIRTUAL_ENV /usr/local/bin/python' + +This alias can then be used in all of your virtualenvs without having to +fix every single one of them. + +PythonW Compiler +---------------- + In addition `virtualenv-pythonw-osx `_ provides an alternative workaround which may be used to solve the issue. From 47e8e389ede6eb9c76879ffc61991d997d95cfc3 Mon Sep 17 00:00:00 2001 From: Nils Werner Date: Fri, 20 Nov 2015 12:29:02 +0100 Subject: [PATCH 2/4] Check if $VIRTUAL_ENV exists in frameworkpython alias --- doc/faq/virtualenv_faq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/faq/virtualenv_faq.rst b/doc/faq/virtualenv_faq.rst index a51a38fb1681..3e45d14be507 100644 --- a/doc/faq/virtualenv_faq.rst +++ b/doc/faq/virtualenv_faq.rst @@ -120,7 +120,7 @@ Alternatively you can define an alias in your ``.bashrc`` using .. code:: bash - alias frameworkpython='PYTHONHOME=$VIRTUAL_ENV /usr/local/bin/python' + alias frameworkpython='[[ ! -z "$VIRTUAL_ENV" ]] && PYTHONHOME=$VIRTUAL_ENV /usr/local/bin/python || /usr/local/bin/python' This alias can then be used in all of your virtualenvs without having to fix every single one of them. From fae3bca7947c0103f81a00df1132ff3a4548c7f8 Mon Sep 17 00:00:00 2001 From: Nils Werner Date: Fri, 20 Nov 2015 12:34:09 +0100 Subject: [PATCH 3/4] Fixed typo --- doc/faq/virtualenv_faq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/faq/virtualenv_faq.rst b/doc/faq/virtualenv_faq.rst index 3e45d14be507..f3fd8e7558f3 100644 --- a/doc/faq/virtualenv_faq.rst +++ b/doc/faq/virtualenv_faq.rst @@ -77,7 +77,7 @@ The issue has been reported on the virtualenv bug tracker `here `__ and `here `__ -Until this is fixed, one of the following workarounds. +Until this is fixed, one of the following workarounds must be used: ``PYTHONHOME`` Script --------------------- From 22849c38c6b79775429ac9564af62b91a24e515d Mon Sep 17 00:00:00 2001 From: Nils Werner Date: Fri, 20 Nov 2015 16:43:05 +0100 Subject: [PATCH 4/4] Actually we need to use a function, an alias does not allow for proper conditionals --- doc/faq/virtualenv_faq.rst | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/faq/virtualenv_faq.rst b/doc/faq/virtualenv_faq.rst index f3fd8e7558f3..9c385aafd256 100644 --- a/doc/faq/virtualenv_faq.rst +++ b/doc/faq/virtualenv_faq.rst @@ -113,16 +113,22 @@ framework build within the virtualenv. To run a script you can do framework build. To run an interactive ``IPython`` session with the framework build within the virtual environment you can do ``frameworkpython -m IPython`` -``PYTHONHOME`` Alias --------------------- +``PYTHONHOME`` Function +----------------------- -Alternatively you can define an alias in your ``.bashrc`` using +Alternatively you can define a function in your ``.bashrc`` using .. code:: bash - alias frameworkpython='[[ ! -z "$VIRTUAL_ENV" ]] && PYTHONHOME=$VIRTUAL_ENV /usr/local/bin/python || /usr/local/bin/python' + function frameworkpython { + if [[ ! -z "$VIRTUAL_ENV" ]]; then + PYTHONHOME=$VIRTUAL_ENV /usr/local/bin/python "$@" + else + /usr/local/bin/python "$@" + fi + } -This alias can then be used in all of your virtualenvs without having to +This function can then be used in all of your virtualenvs without having to fix every single one of them. PythonW Compiler