Skip to content
Open
Changes from 3 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
40 changes: 27 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,41 @@
CARGO_TARGET_DIR = NATIVE_CRATE.absolute() / f"target{sys.version_info.major}.{sys.version_info.minor}"
DD_CARGO_ARGS = shlex.split(os.getenv("DD_CARGO_ARGS", ""))

BUILD_PROFILING_NATIVE_TESTS = os.getenv("DD_PROFILING_NATIVE_TESTS", "0").lower() in ("1", "yes", "on", "true")

def _env_truthy(name: str, default: str = "0") -> bool:
return os.getenv(name, default).lower() in ("1", "yes", "on", "true")
Comment thread
vlad-scherbich marked this conversation as resolved.


BUILD_PROFILING_NATIVE_TESTS = _env_truthy("DD_PROFILING_NATIVE_TESTS")


def is_musl_libc() -> bool:
"""True when this interpreter is a musl (Alpine / musllinux) build.

The heap-gotter cdylib is built and tested only on manylinux (glibc) in CI;
skip building on musllinux because cargo builds fail there.
"""
return any(
"musl" in (sysconfig.get_config_var(k) or "")
for k in ("SOABI", "EXT_SUFFIX", "BUILD_GNU_TYPE", "HOST_GNU_TYPE", "MULTIARCH")
)


# Opt-in build of the native heap-gotter cdylib.
# Off by default so normal builds don't pay the extra cargo fetch/compile and
# mainline wheels don't ship the artifact until it GA's.
# Same env var as runtime arming (ProfilingConfigNativeHeap.enabled); setup.py
# reads it via os.getenv during the package build, independent of DDConfig.
BUILD_NATIVE_HEAP_GOTTER: bool = os.getenv("DD_PROFILING_NATIVE_HEAP_ENABLED", "0").lower() in (
"1",
"yes",
"on",
"true",
)
# Musl is always a no-op even when the env is set (see is_musl_libc).
if _env_truthy("DD_PROFILING_NATIVE_HEAP_ENABLED") and is_musl_libc():
print(
"WARNING: DD_PROFILING_NATIVE_HEAP_ENABLED is set but the native heap-gotter "
"cdylib is only built on manylinux (glibc); skipping on musllinux."
)
BUILD_NATIVE_HEAP_GOTTER: bool = _env_truthy("DD_PROFILING_NATIVE_HEAP_ENABLED") and not is_musl_libc()
Comment thread
vlad-scherbich marked this conversation as resolved.
# Keep the staged cdylib unstripped when building with the upstream test-support
# feature (hook-hit counter for e2e / integration tests).
BUILD_NATIVE_HEAP_GOTTER_TEST_SUPPORT: bool = os.getenv("DD_PROFILING_NATIVE_HEAP_TEST_SUPPORT", "0").lower() in (
"1",
"yes",
"on",
"true",
)
BUILD_NATIVE_HEAP_GOTTER_TEST_SUPPORT = _env_truthy("DD_PROFILING_NATIVE_HEAP_TEST_SUPPORT")

CURRENT_OS = platform.system()
SERVERLESS_BUILD = os.getenv("DD_SERVERLESS_BUILD", "0").lower() in ("1", "yes", "on", "true")
Expand Down
Loading