Skip to content
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

[Nix] Fix POETRY_HOME environment variable in shell.nix nix expression #131

Closed
1 task done
rszamszur opened this issue Aug 9, 2022 · 1 comment · Fixed by #132
Closed
1 task done

[Nix] Fix POETRY_HOME environment variable in shell.nix nix expression #131

rszamszur opened this issue Aug 9, 2022 · 1 comment · Fixed by #132
Assignees
Labels
bug Something isn't working copier: project Related to copier template

Comments

@rszamszur
Copy link
Member

  • I have searched the issues of this repo and believe that this is not a duplicate.

Describe the bug

Environment variable POETRY_HOME is not the same as overridden pkgs.poetry build. This will cause problems when pkgs.python will be different than the python used by default for pkgs.poetry for specific nixpkgs. Meaning, even though poetry will be installed with correct python version, when using make install target it will use a different abspath to poetry and a different python interpreter. For example with pkgs.python310:

$ poetry env info

Virtualenv
Python:         3.10.4
Implementation: CPython
Path:           NA

System
Platform: linux
OS:       posix
Python:   /nix/store/73jg56dr425ycv9p746arzf13m52q2n3-python3-3.10.4

$ echo $POETRY_HOME
/nix/store/p6n63a3jjcr6kxsyxllh1jqnqk03zbwy-python3.9-poetry-1.1.14

$ readlink -f $(which poetry)
/nix/store/w8nds4z9r8jadj74s5zjp9m28mns8ywv-python3.10-poetry-1.1.14/bin/poetry

$ make install
[install] Begin installing project.
...
...
$ poetry env info

Virtualenv
Python:         3.9.13
Implementation: CPython
Path:           /home/rszamszur/repos/gh/rszamszur/fastapi-mvc/.venv
Valid:          True

System
Platform: linux
OS:       posix
Python:   /nix/store/xpwwghl72bb7f48m51amvqiv1l25pa01-python3-3.9.13

The root cause:
https://github.com/rszamszur/fastapi-mvc/blob/ba351bb8a5e4ee7d8a1188aff301d38e04aeb932/shell.nix#L9-L12

Expected behavior

Environment variable POETRY_HOME should point to overridden pkgs.poetry build.

To Reproduce

Use following nix shell expression:

{ pkgs ? import <nixpkgs> { } }:

pkgs.mkShell {
  buildInputs = [
    pkgs.curl
    pkgs.gnumake
    pkgs.podman
    pkgs.python310
    (pkgs.poetry.override { python = pkgs.python310; })
  ];
  shellHook = ''
    export POETRY_HOME=${pkgs.poetry}
    export POETRY_VIRTUALENVS_IN_PROJECT=true
    unset SOURCE_DATE_EPOCH
  '';
}

Install the project via make install target. And run poetry env info.

Environment

  • Python version: 3.10.4
  • Operating System and version: Linux hades 5.15.56 #1-NixOS SMP Thu Jul 21 19:24:44 UTC 2022 x86_64 GNU/Linux
  • fastapi-mvc version: 0.14.0

Additional context

@rszamszur rszamszur added bug Something isn't working copier: project Related to copier template labels Aug 9, 2022
@rszamszur
Copy link
Member Author

While at it, let's make python configurable via --argstr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working copier: project Related to copier template
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant