Skip to main content

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())

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 日志。

安装 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.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oxy-py-sdk 1.0.5
File Size Uploaded Provenance Actions
oxy_py_sdk-1.0.5.tar.gz 59.4 kB Without provenance Details for oxy_py_sdk-1.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oxy-py-sdk 1.0.5
File Interpreter ABI Platform Actions
oxy_py_sdk-1.0.5-py3-none-any.whl Python 3 none any Details for oxy_py_sdk-1.0.5-py3-none-any.whl

Total release size: 86.8 kB

Release files / oxy_py_sdk-1.0.5.tar.gz

Download URL oxy_py_sdk-1.0.5.tar.gz
Size 59.4 kB
Tags Source
SHA-256 checksum
How to use checksums
eea64d27946102bba72a7c49eb29d42d632efd80d5fb74d5dda16930af555446
BLAKE2b-256 checksum
How to use checksums
74ed219963255f10f01b611cb2052adea60cb08d33721178c98d275a3952b452
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.0.5-py3-none-any.whl

Download URL oxy_py_sdk-1.0.5-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab19d9e291868ab5ba31ca0837b3f7aba6cba70daa24413b305e911b32db8d2f
BLAKE2b-256 checksum
How to use checksums
c190073573ddb0b7714551db1230d3529288a7dafb4b52b49799758dcc1beeb3
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.0.5

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page