Skip to content

Commit

Permalink
python: poetry: unset VIRTUAL_ENV
Browse files Browse the repository at this point in the history
This is needed as tools like poetry looks for VIRTUAL_ENV and attempts
to use the python interpreter from this environment.

We want poetry to use the python interpreter from PATH (set by devenv).
We want it to configure the python interpreter for the new venv.
  • Loading branch information
bobvanderlinden committed Apr 25, 2023
1 parent f2898b4 commit d11d8db
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modules/languages/python.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ let
venvPath = "${config.env.DEVENV_STATE}/venv";

initVenvScript = pkgs.writeShellScript "init-venv.sh" ''
# Make sure any tools are not attempting to use the python interpreter from any
# existing virtual environment. For instance if devenv was started within an venv.
unset VIRTUAL_ENV
if [ ! -L ${venvPath}/devenv-profile ] \
|| [ "$(${pkgs.coreutils}/bin/readlink ${venvPath}/devenv-profile)" != "${config.env.DEVENV_PROFILE}" ]
then
Expand All @@ -26,6 +30,10 @@ let
initPoetryScript = pkgs.writeShellScript "init-poetry.sh" ''
function _devenv-init-poetry-venv()
{
# Make sure any tools are not attempting to use the python interpreter from any
# existing virtual environment. For instance if devenv was started within an venv.
unset VIRTUAL_ENV
if [ ! -L ${config.env.DEVENV_ROOT}/.venv ]
then
${pkgs.coreutils}/bin/ln --symbolic --no-target-directory --force ${venvPath} ${config.env.DEVENV_ROOT}/.venv
Expand Down

0 comments on commit d11d8db

Please sign in to comment.