我正在尝试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
阻止它工作的功能有什么误解?