3

我正在尝试openai使用 nix 制作一个包含 pypi 包的 python37 开发环境。

这个问题最初是在 reddit 上,但我找不到答案,而且线程中的活动非常低。

使用我到达那里的提示和语言框架文档,我设法提出了以下表达式:

默认.nix:

with import<nixpkgs>{};
( let
    openai = pkgs.callPackage ./release.nix {
              inherit pkgs; 
              buildPythonPackage = pkgs.python37Packages.buildPythonPackage;
            };
  in pkgs.python37.buildEnv.override rec {
    extraLibs = [ pkgs.python37Packages.requests openai ];
  }
).env

发布.nix

{ pkgs, buildPythonPackage }:

buildPythonPackage rec{
  pname="openai";
  version="0.2.6";

  src=fetchTarball{
    url="https://files.pythonhosted.org/packages/59/2d/b3bc2aa663b2c376f073fd141e128ecfb47f3aff95ccee284a74d85a1ef8/openai-0.2.6.tar.gz";
    sha256="0cplrzfw3i6yxcd35ijfjkx9jbcvkvzn5jn5b8s657a8myhm6kav";
  };

  propagateBuildInputs = [ pkgs.python37Packages.requests ];
  doCheck=false;

  meta = { # only for testing the env right now
    homepage="...";
    description="...";
    license = "...";
    maintainers= [];
  };
}

然而,这给我留下了(我猜它的点子)错误

Processing ./openai-0.2.6-py3-none-any.whl
ERROR: Could not find a version that satisfies the requirement requests>=2.20; python_version >= "3.0" (from openai==0.2.6) (from versions: none)
ERROR: No matching distribution found for requests>=2.20; python_version >= "3.0" (from openai==0.2.6)
builder for '/nix/store/ncnga4fcxl15xyvv3f325f9g0q45mqvr-python3.7-openai-0.2.6.drv' failed with exit code 1

这让我感到惊讶,因为propagateBuildInputs = [ pkgs.python37Packages.requests ];明确指出包requests(nixpkgs 中的版本 2.22.0)应该在构建时存在。

我对buildPythonPackage阻止它工作的功能有什么误解?

4

1 回答 1

1

更改progagatedBuildInputs为另一个名称 likeprogagateBuildInputs会导致它被忽略,因此requests找不到它包含的任何依赖项(即 )。例如:

yubico-client/default.nix

  propagateBuildInputs = [ requests ];

ERROR: Could not find a version that satisfies the requirement requests<3.0,>=2.7 (from yubico-client==1.13.0) (from versions: none)
ERROR: No matching distribution found for requests<3.0,>=2.7 (from yubico-client==1.13.0)

  propagatedBuildInputs = [ requests ];

$ nix-build -I nixpkgs=~/git/nixpkgs '<nixpkgs>' -k -A python37Packages.yubico-client
/nix/store/0yjz8smgmjr0006nmka6wliy01z8av7m-python3.7-yubico-client-1.13.0
于 2020-11-14T14:12:18.393 回答