11import httpx
2+ import platform
3+ import sys
4+ from functools import lru_cache
5+
6+ from ._api_version import __api_version__
27from ._version import __version__
38
49HeaderTypes = dict [str , str ]
@@ -10,6 +15,48 @@ def version():
1015 return f"v{ __version__ } "
1116
1217
18+ def runtime_headers () -> dict [str , str ]:
19+ return dict (_runtime_headers ())
20+
21+
22+ @lru_cache (maxsize = 1 )
23+ def _runtime_headers () -> tuple [tuple [str , str ], ...]:
24+ arch_raw = platform .machine ()
25+ arch = arch_raw .lower () if arch_raw else ""
26+ arch_map = {
27+ "x86_64" : "x86_64" ,
28+ "x64" : "x86_64" ,
29+ "amd64" : "x86_64" ,
30+ "x86" : "x86" ,
31+ "i386" : "x86" ,
32+ "i686" : "x86" ,
33+ "ia32" : "x86" ,
34+ "x32" : "x86" ,
35+ "aarch64" : "arm64" ,
36+ "arm64" : "arm64" ,
37+ "arm" : "arm" ,
38+ }
39+ arch = arch_map .get (arch , "unknown" )
40+
41+ os_name = sys .platform
42+ os_map = {
43+ "win32" : "windows" ,
44+ "linux" : "linux" ,
45+ "darwin" : "darwin" ,
46+ }
47+ os_name = os_map .get (os_name , os_name )
48+
49+ return (
50+ ("X-Sumup-Api-Version" , __api_version__ ),
51+ ("X-Sumup-Lang" , "python" ),
52+ ("X-Sumup-Package-Version" , __version__ ),
53+ ("X-Sumup-Os" , os_name ),
54+ ("X-Sumup-Arch" , arch ),
55+ ("X-Sumup-Runtime" , "python" ),
56+ ("X-Sumup-Runtime-Version" , platform .python_version ()),
57+ )
58+
59+
1360class Resource (BaseResource ):
1461 _client : httpx .Client
1562
0 commit comments