1{
2 # Basic
3 lib,
4 buildPythonPackage,
5 fetchFromGitHub,
6 # Build system
7 setuptools,
8 # Dependencies
9 aiohttp,
10 requests,
11 websocket-client,
12 cryptography,
13 certifi,
14 # Test
15 pytestCheckHook,
16 tiktoken,
17}:
18
19buildPythonPackage rec {
20 pname = "dashscope";
21 version = "1.24.6";
22 pyproject = true;
23
24 src = fetchFromGitHub {
25 owner = "dashscope";
26 repo = "dashscope-sdk-python";
27 tag = "v${version}";
28 hash = "sha256-kHvNg8yPlZyAr7Qgncv+axgG9sOKTjvxYnRojO5ih1g=";
29 };
30
31 build-system = [ setuptools ];
32
33 dependencies = [
34 aiohttp
35 requests
36 websocket-client
37 cryptography
38 certifi
39 ];
40
41 # Specify the version explicitly
42 postPatch = ''
43 substituteInPlace setup.py \
44 --replace-fail "version=get_version()," "version='${version}',"
45 '';
46
47 nativeCheckInputs = [
48 pytestCheckHook
49 tiktoken
50 ];
51
52 pythonImportsCheck = [ "dashscope" ];
53
54 disabledTests = [
55 # Needs network access and/or API key
56 "TestAsyncImageSynthesisRequest"
57 "TestAsyncRequest"
58 "TestAsyncVideoSynthesisRequest"
59 "TestEncryption"
60 "TestSpeechRecognition"
61 "TestSpeechTranscribe"
62 "TestSynthesis"
63 "TestWebSocketAsyncRequest"
64 "TestWebSocketSyncRequest"
65 ];
66
67 meta = {
68 description = "Python SDK for dashscope";
69 homepage = "https://github.com/dashscope/dashscope-sdk-python";
70 license = lib.licenses.asl20;
71 maintainers = with lib.maintainers; [ thattemperature ];
72 };
73}