Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 144 lines 2.8 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 pythonAtLeast, 6 7 # build-system 8 hatchling, 9 hatch-fancy-pypi-readme, 10 11 # dependencies 12 anyio, 13 distro, 14 httpx, 15 jiter, 16 pydantic, 17 sniffio, 18 tqdm, 19 typing-extensions, 20 21 # `httpx_aiohttp` not currently in `nixpkgs` 22 # optional-dependencies (aiohttp) 23 # aiohttp, 24 # httpx_aiohttp, 25 26 # optional-dependencies (datalib) 27 numpy, 28 pandas, 29 pandas-stubs, 30 31 # optional-dependencies (realtime) 32 websockets, 33 34 # optional-dependencies (voice-helpers) 35 sounddevice, 36 37 # check deps 38 pytestCheckHook, 39 dirty-equals, 40 inline-snapshot, 41 nest-asyncio, 42 pytest-asyncio, 43 pytest-mock, 44 pytest-xdist, 45 respx, 46 47 # optional-dependencies toggle 48 withRealtime ? true, 49 withVoiceHelpers ? true, 50}: 51 52buildPythonPackage rec { 53 pname = "openai"; 54 version = "1.97.1"; 55 pyproject = true; 56 57 src = fetchFromGitHub { 58 owner = "openai"; 59 repo = "openai-python"; 60 tag = "v${version}"; 61 hash = "sha256-ANY74P3tM8VVPh9m6hOdZSkMhcQphi72bKNcLrsLEq8="; 62 }; 63 64 postPatch = ''substituteInPlace pyproject.toml --replace-fail "hatchling==1.26.3" "hatchling"''; 65 66 build-system = [ 67 hatchling 68 hatch-fancy-pypi-readme 69 ]; 70 71 dependencies = [ 72 anyio 73 distro 74 httpx 75 jiter 76 pydantic 77 sniffio 78 tqdm 79 typing-extensions 80 ] 81 ++ lib.optionals withRealtime optional-dependencies.realtime 82 ++ lib.optionals withVoiceHelpers optional-dependencies.voice-helpers; 83 84 optional-dependencies = { 85 # `httpx_aiohttp` not currently in `nixpkgs` 86 # aiohttp = [ 87 # aiohttp 88 # httpx_aiohttp 89 # ]; 90 datalib = [ 91 numpy 92 pandas 93 pandas-stubs 94 ]; 95 realtime = [ 96 websockets 97 ]; 98 voice-helpers = [ 99 numpy 100 sounddevice 101 ]; 102 }; 103 104 pythonImportsCheck = [ "openai" ]; 105 106 nativeCheckInputs = [ 107 pytestCheckHook 108 dirty-equals 109 inline-snapshot 110 nest-asyncio 111 pytest-asyncio 112 pytest-mock 113 pytest-xdist 114 respx 115 ]; 116 117 pytestFlags = [ 118 "-Wignore::DeprecationWarning" 119 ]; 120 121 disabledTests = [ 122 # Tests make network requests 123 "test_copy_build_request" 124 "test_basic_attribute_access_works" 125 ] 126 ++ lib.optionals (pythonAtLeast "3.13") [ 127 # RuntimeWarning: coroutine method 'aclose' of 'AsyncStream._iter_events' was never awaited 128 "test_multi_byte_character_multiple_chunks" 129 ]; 130 131 disabledTestPaths = [ 132 # Test makes network requests 133 "tests/api_resources" 134 ]; 135 136 meta = { 137 description = "Python client library for the OpenAI API"; 138 homepage = "https://github.com/openai/openai-python"; 139 changelog = "https://github.com/openai/openai-python/blob/v${version}/CHANGELOG.md"; 140 license = lib.licenses.mit; 141 maintainers = [ lib.maintainers.malo ]; 142 mainProgram = "openai"; 143 }; 144}