Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import inspect
import os
import platform
import subprocess
import shlex
import glob

from hatchling.builders.hooks.plugin.interface import BuildHookInterface

Expand All @@ -14,8 +17,11 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
build_data["infer_tag"] = True
build_data["pure_python"] = False

os.system("conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force")
os.system("conan profile detect --force")
subprocess.run(
["conan", "remote", "add", "osp", "https://osp.jfrog.io/artifactory/api/conan/conan-local", "--force"],
check=True,
)
subprocess.run(["conan", "profile", "detect", "--force"], check=True)

for frame_info in inspect.stack():
frame = frame_info.frame
Expand All @@ -29,14 +35,22 @@ def initialize(self, version: str, build_data: dict[str, Any]) -> None:
else:
build_packages = "-b missing"

assert (
os.system(f"conan install . -u {build_packages} -of build --format json -b b2/* --out-file graph.json") == 0
), "Conan install failed"
install_cmd_str = (
f"conan install . -u {build_packages} -of build --format json -b b2/* -b m4/* --out-file graph.json"
)

install_args = shlex.split(install_cmd_str)
result = subprocess.run(install_args)
assert result.returncode == 0, "Conan install failed"

if "CONAN_UPLOAD_OSP" in os.environ:
print("Uploading packages..")
os.system("conan list --graph=graph.json --format=json > pkglist.json")
os.system("conan upload --confirm --list=pkglist.json --remote osp")
with open("pkglist.json", "w") as pkglist_file:
subprocess.run(
["conan", "list", "--graph=graph.json", "--format=json"], check=True, stdout=pkglist_file
)
subprocess.run(["conan", "upload", "--confirm", "--list=pkglist.json", "--remote", "osp"], check=True)

if system_os == "Linux":
os.system("patchelf --set-rpath '$ORIGIN' build/libcosimc/*")
for libfile in glob.glob("build/libcosimc/*"):
subprocess.run(["patchelf", "--set-rpath", "$ORIGIN", libfile], check=True)
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ classifiers = [

[dependency-groups]
dev = [
"conan~=2.15.1",
"ruff~=0.11.7",
"conan>=2.27.0",
"ruff>=0.15.0",
"pyright>=1.1.400",
"pytest>=8.3.5",
]
Expand All @@ -45,7 +45,7 @@ exclude = ["tests", ".github"]

[tool.hatch.build.targets.wheel.hooks.custom]
dependencies = [
"conan~=2.15.1",
"conan>=2.27.0",
"hatchling~=1.13",
"cmake>=3.10,<4.0",
"patchelf>=0.17.2; platform_system == 'Linux'"
Expand Down
Loading
Loading