oxy-py-sdk
Python 通用工具库,提供 HTTP 请求、配置管理、加解密、日志和数据处理工具。
发行包名为 oxy-py-sdk,Python 导入包名为 oxy。支持 Python 3.15 及以上版本。
按需安装
基础包包含日志、集合、通用语言工具及 MD5/SHA256,无第三方运行时依赖。
未安装 colorama 时日志使用无颜色输出;安装 [all] 会同时安装 colorama,启用彩色日志。
其他功能按需安装:
pip install oxy-py-sdk
pip install "oxy-py-sdk[codec]" # DES、RSA、签名等加解密
pip install "oxy-py-sdk[data]" # DataFrame、Excel 读写及缓存
pip install "oxy-py-sdk[http]" # HTTP 请求
pip install "oxy-py-sdk[setting]" # YAML 配置读写
pip install "oxy-py-sdk[http,setting]" # 自由组合
pip install "oxy-py-sdk[setting,codec]" # 配置文件加解密
pip install "oxy-py-sdk[all]" # 全部功能依赖,含彩色日志
| 分组 | 依赖 | 模块 |
|---|---|---|
| codec | pycryptodome、cryptography | oxy.utils.codec |
| data | pandas、openpyxl | oxy.utils.data、oxy.utils.data.cache |
| http | httpx(含 HTTP/2)、pydantic | oxy.utils.http |
| setting | pyyaml | oxy.utils.setting |
setting 的字典读取和转换不需要 YAML 依赖;配置文件加解密需要同时安装 setting 和 codec。
MD5/SHA256 使用标准库,无需安装 codec。DES 和 MD5 主要用于兼容现有协议。
使用示例
基础工具:
from oxy.utils.lang import gen_uuid_str
from oxy.utils.lang.collection import distinct
print(gen_uuid_str())
print(distinct([1, 1, 2])) # [1, 2]
安装 oxy-py-sdk[http] 后:
import asyncio
from oxy.utils.http import api
@api.get("https://httpbin.org/get")
async def fetch():
return {"q": "python"}
result = asyncio.run(fetch())
URL 也支持无参 callable,返回字符串或 RequestUrl,每次调用接口时重新解析,例如:
@api.get(lambda: f"{settings.api_host}/users")
async def fetch_users():
return {"page": 1}
上例中的 settings 由调用方提供;SDK 不负责监听或固定应用配置。
HTTP 日志通过装饰器的 log 参数控制,需由应用配置日志处理器并启用 DEBUG 级别:
from oxy.utils.http import HttpLogs
@api.get("https://httpbin.org/get", log=HttpLogs.ALL)
async def fetch_with_logs():
return {"q": "python"}
HttpLogs.DEFAULT(默认值)仅记录请求,HttpLogs.ALL 同时记录请求和成功响应,
HttpLogs.NONE 关闭这两类日志。HTTP 状态错误仍记录 ERROR 日志。
设置 HttpRequestExtra(resp_curl=True) 时,只生成适用于 POSIX shell 的 cURL 命令,不发送请求,也不调用业务响应处理器或转换响应模型。命令保留请求的查询参数、Content-Type 和请求体;生成结果不额外启用重定向,二进制请求体通过 printf 管道传递。
安装 oxy-py-sdk[setting] 后:
from pathlib import Path
from oxy.utils.setting import dump_yaml, load_yaml
dump_yaml({"project": {"name": "demo"}}, Path("settings.yaml"))
settings = load_yaml(Path("settings.yaml"))
开发与验证
uv sync --locked --all-extras
uv run --locked --all-extras python -m pytest -q
uv build
uvx twine check --strict dist/*
测试不需要真实外部服务,HTTP 请求使用模拟传输。
只安装指定功能:
uv sync --locked --extra http --extra setting
修改依赖后运行 uv lock 并提交 pyproject.toml 与 uv.lock。
发布
完整配置及操作步骤见 发布说明,版本记录见 CHANGELOG。
发布 GitHub Release 后自动构建并发布到 PyPI。
版本来源为 pyproject.toml,Release 标签必须是 v 加版本号,例如 v1.0.0。
许可证
MIT,Copyright (c) 2026 wangjz。
Metadata
Release files for oxy-py-sdk 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oxy_py_sdk-1.1.1.tar.gz | 62.2 kB | Without provenance | Details for oxy_py_sdk-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oxy_py_sdk-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for oxy_py_sdk-1.1.1-py3-none-any.whl |
Total release size: 90.3 kB
Release files / oxy_py_sdk-1.1.1.tar.gz
| Download URL | oxy_py_sdk-1.1.1.tar.gz |
|---|---|
| Size | 62.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df63d35c250963f4b89d0e0727647796fe4dc1d804ec4e3796bb0c89bcdd26c5
|
|
BLAKE2b-256 checksum How to use checksums |
74631ae834c607c4379e946bd2cbdfd3e53568fd6021acdb5e2ee95d2662aa2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / oxy_py_sdk-1.1.1-py3-none-any.whl
| Download URL | oxy_py_sdk-1.1.1-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37d056f46eb4b2858b17acaa4df30c1c2bcf12c95d6979e2d833685a66fd671b
|
|
BLAKE2b-256 checksum How to use checksums |
ba5cca9178ecd001c4b09e8d5ec0fd4aff249701cc83bdcda40a8ee31b2acc07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for oxy-py-sdk 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.