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

The poetry in mkPoetryEnv doesn't end up with the correct python version #1076

Closed
MatrixManAtYrService opened this issue Mar 23, 2023 · 3 comments

Comments

@MatrixManAtYrService
Copy link

MatrixManAtYrService commented Mar 23, 2023

Describe the issue

Poetry ends up configured to use python 3.10 even though I've specified python 3.8:

$ nix develop
trace: warning: 'deps' argument to makeSetupHook is deprecated and will be removed in release 23.11., Please use propagatedBuildInputs instead. content of deps: /nix/store/micahg85qjjalavnrjsv6yip8m1m4qds-python3.10-pip-23.0.1 /nix/store/if8hmh5jb452r7xrqdabc83gdazx825n-python3.10-wheel-0.38.4
$ poetry run python --version
Python 3.10.9

I'm not sure what's up with that warning, but I've found that I can work around the above error by running:

$ poetry env use $(which python)

...which I suppose I could do in a shellHook, but it seems like there should be a better way.

Additional context

default.nix/shell.nix/flake.nix:

{
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    poetry2nix = {
      url = "github:nix-community/poetry2nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, flake-utils, poetry2nix, }:
      {
        overlay = nixpkgs.lib.composeManyExtensions [

          poetry2nix.overlay

          (final: prev: 
          let 
            projectDir = ./.;
            python = prev.python38;
          in
          {
            myapp = final.poetry2nix.mkPoetryApplication {
              inherit projectDir;
              inherit python;
              preferWheels = true;
            };
            myenv = final.poetry2nix.mkPoetryEnv {
              inherit projectDir;
              inherit python;
            };
          })
        ];
      } // flake-utils.lib.eachDefaultSystem (system:
      let 
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ self.overlay ];
        };
      in rec {
        packages = {
          myapp = pkgs.myapp;
          default = self.packages.${system}.myapp;
        };

        devShells.default = pkgs.mkShell {
          buildInputs = [
            pkgs.myenv
          ];
          packages = [
            pkgs.poetry
            pkgs.python38
            pkgs.pre-commit
          ];
        };
      });
}

pyproject.toml:

[tool.poetry]
...omitted...

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.dependencies]
python = "^3.8"
@MatrixManAtYrService
Copy link
Author

After some further investigation, I think maybe this is the cause: NixOS/nixpkgs#223275

But I'd love a second opinion about that.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/is-there-a-bsd-equivalent-of-coretools/27257/6

@MatrixManAtYrService
Copy link
Author

I'm pretty sure that the above issue was indeed the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants