Skip to content

Commit

Permalink
Simplify build.py and remove tomllib dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Jan 25, 2025
1 parent 340766d commit c44097b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
6 changes: 0 additions & 6 deletions .github/actions/common-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,6 @@ runs:
python -m pip install --upgrade pip setuptools wheel
poetry install --only dev --no-root
- name: Install tomllib (if Python < 3.11)
shell: bash
run: |
python -c "import sys; sys.exit(0) if sys.version_info >= (3, 11) else sys.exit(1)" || \
python -m pip install tomllib
# > --------------------------------------------------
# > pre-commit
- name: Cached pre-commit
Expand Down
20 changes: 15 additions & 5 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import itertools
import os
import platform
import re
import shutil
import subprocess
import sys
import sysconfig
import tomllib
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -291,6 +291,19 @@ def _copy_rust_dylibs_to_project() -> None:
print(f"Copied {src} to {dst}")


def _get_nautilus_version() -> str:
with open("pyproject.toml", encoding="utf-8") as f:
pyproject_content = f.read().strip()
if not pyproject_content:
raise ValueError("pyproject.toml is empty or not properly formatted")

version_match = re.search(r'version\s*=\s*"(.*?)"', pyproject_content)
if not version_match:
raise ValueError("Version not found in pyproject.toml")

return version_match.group(1)


def _get_clang_version() -> str:
try:
result = subprocess.run(
Expand Down Expand Up @@ -381,12 +394,9 @@ def build() -> None:


if __name__ == "__main__":
with open("pyproject.toml", "rb") as f:
pyproject_data = tomllib.load(f)
nautilus_trader_version = pyproject_data["tool"]["poetry"]["version"]
print("\033[36m")
print("=====================================================================")
print(f"Nautilus Builder {nautilus_trader_version}")
print(f"Nautilus Builder {_get_nautilus_version()}")
print("=====================================================================\033[0m")
print(f"System: {platform.system()} {platform.machine()}")
print(f"Clang: {_get_clang_version()}")
Expand Down

0 comments on commit c44097b

Please sign in to comment.