Download sdk/python/src/openai_codex/_version.py from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 906 Bytes
-
https://huggingface.co/SaylorTwift/codex/resolve/main/sdk/python/src/openai_codex/_version.py
- Command line
-
hf download hf://SaylorTwift/codex/sdk/python/src/openai_codex/_version.py
-
curl -L -o _version.py https://huggingface.co/SaylorTwift/codex/resolve/main/sdk/python/src/openai_codex/_version.py
906 Bytes
| from __future__ import annotations | |
| import re | |
| from importlib.metadata import PackageNotFoundError, version as distribution_version | |
| from pathlib import Path | |
| DISTRIBUTION_NAME = "openai-codex" | |
| UNKNOWN_VERSION = "0+unknown" | |
| def package_version() -> str: | |
| source_version = _source_tree_project_version() | |
| if source_version is not None: | |
| return source_version | |
| try: | |
| return distribution_version(DISTRIBUTION_NAME) | |
| except PackageNotFoundError: | |
| return UNKNOWN_VERSION | |
| def _source_tree_project_version() -> str | None: | |
| pyproject_path = Path(__file__).resolve().parents[2] / "pyproject.toml" | |
| if not pyproject_path.exists(): | |
| return None | |
| match = re.search( | |
| r'(?m)^version = "([^"]+)"$', | |
| pyproject_path.read_text(encoding="utf-8"), | |
| ) | |
| if match is None: | |
| return None | |
| return match.group(1) | |
| __version__ = package_version() | |