Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
54 changes: 6 additions & 48 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,61 +24,17 @@ on:
- cron: 0 2 * * 2-6

jobs:
compute_version:
name: Compute Library Version
runs-on: ubuntu-latest
outputs:
library_version: ${{ steps.compute-version.outputs.library_version }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# Include all history and tags
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
name: Install Python
with:
python-version: '3.12'
- name: Compute Version
id: compute-version
run: |
pip install "setuptools_scm[toml]>=4"

# If we are on the main or release branch, strip away the dev version
if [[ "$GITHUB_REF_NAME" == "main" || \
"$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+$ || \
"$GITHUB_REF_NAME" =~ ^[0-9]+\.x$ ]]; then
LIBRARY_VERSION=$(setuptools-scm --strip-dev)
else
# use version string explicitly set in the project metadata, if exists
LIBRARY_VERSION=$(grep '^version = ' pyproject.toml | tr -d '"' | cut -d' ' -f3)
if [[ -z $LIBRARY_VERSION ]]; then
# All else, maintain the dev version
LIBRARY_VERSION=$(setuptools-scm)
fi
fi

echo "${LIBRARY_VERSION}" | tee version.txt
echo "library_version=${LIBRARY_VERSION}" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: library-version
path: version.txt

build_wheels:
needs: [ "compute_version" ]
needs: [ ]
uses: ./.github/workflows/build_python_3.yml
with:
cibw_build: 'cp39* cp310* cp311* cp312* cp313* cp314*'
cibw_skip: 'cp39-win_arm64 cp310-win_arm64 cp314t*'
library_version: ${{ needs.compute_version.outputs.library_version }}

build_sdist:
needs: [ "compute_version" ]
needs: [ ]
name: Build source distribution
runs-on: ubuntu-latest
env:
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE: ${{ needs.compute_version.outputs.library_version }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# Include all history and tags
Expand All @@ -92,8 +48,9 @@ jobs:
python-version: '3.12'
- name: Build sdist
run: |
pip install "setuptools_scm[toml]>=4" "cython" "cmake>=3.24.2,<3.28" "setuptools-rust"
python setup.py sdist
pip install "cython" "cmake>=3.24.2,<3.28" "setuptools-rust"
# Do not Cythonize during sdist to avoid generating .c files
DD_CYTHONIZE=0 python setup.py sdist
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: source-dist
Expand Down Expand Up @@ -127,6 +84,7 @@ jobs:
- name: Install source package
env:
CMAKE_BUILD_PARALLEL_LEVEL: 12
CARGO_BUILD_JOBS: 12
run: pip install dist/*.tar.gz

- name: Test the source package
Expand Down
39 changes: 3 additions & 36 deletions .github/workflows/build_python_3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,8 @@ on:
cibw_prerelease_pythons:
required: false
type: string
library_version:
required: false
type: string

jobs:
compute_version:
name: Compute Library Version
runs-on: ubuntu-latest
outputs:
library_version: ${{ steps.compute-version.outputs.library_version }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# Include all history and tags
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
name: Install Python
with:
python-version: '3.12'
- name: Compute Version
id: compute-version
run: |
if [ -n "${{ inputs.library_version}}" ]; then
LIBRARY_VERSION="${{ inputs.library_version}}"
else
pip install "setuptools_scm[toml]>=4"
LIBRARY_VERSION=$(setuptools-scm)
fi

echo "${LIBRARY_VERSION}"
echo "library_version=${LIBRARY_VERSION}" >> $GITHUB_OUTPUT

build-wheels-matrix:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -76,15 +45,14 @@ jobs:
echo "include=${MATRIX_INCLUDE}" >> $GITHUB_OUTPUT

build:
needs: ["compute_version", "build-wheels-matrix" ]
needs: [ "build-wheels-matrix" ]
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.only }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.build-wheels-matrix.outputs.include) }}
env:
SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE: ${{ needs.compute_version.outputs.library_version }}
CIBW_SKIP: ${{ inputs.cibw_skip }}
CIBW_PRERELEASE_PYTHONS: ${{ inputs.cibw_prerelease_pythons }}
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
Expand All @@ -96,12 +64,11 @@ jobs:
if [[ "$(uname -m)-$(uname -i)-$(uname -o | tr '[:upper:]' '[:lower:]')-$(ldd --version 2>&1 | head -n 1 | awk '{print $1}')" != "i686-unknown-linux-musl" ]]; then
curl -sSf https://sh.rustup.rs | sh -s -- -y;
fi
CIBW_ENVIRONMENT_LINUX: PATH=$HOME/.cargo/bin:$PATH CMAKE_BUILD_PARALLEL_LEVEL=24 CMAKE_ARGS="-DNATIVE_TESTING=OFF" SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
CIBW_ENVIRONMENT_LINUX: PATH=$HOME/.cargo/bin:$PATH CMAKE_BUILD_PARALLEL_LEVEL=24 CMAKE_ARGS="-DNATIVE_TESTING=OFF"
# SYSTEM_VERSION_COMPAT is a workaround for versioning issue, a.k.a.
# `platform.mac_ver()` reports incorrect MacOS version at 11.0
# See: https://stackoverflow.com/a/65402241
CIBW_ENVIRONMENT_MACOS: CMAKE_BUILD_PARALLEL_LEVEL=24 SYSTEM_VERSION_COMPAT=0 CMAKE_ARGS="-DNATIVE_TESTING=OFF" SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
CIBW_ENVIRONMENT_WINDOWS: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=${{ needs.compute_version.outputs.library_version }}
CIBW_ENVIRONMENT_MACOS: CMAKE_BUILD_PARALLEL_LEVEL=24 SYSTEM_VERSION_COMPAT=0 CMAKE_ARGS="-DNATIVE_TESTING=OFF"
# cibuildwheel repair will copy anything's under /output directory from the
# build container to the host machine. This is a bit hacky way, but seems
# to be the only way getting debug symbols out from the container while
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ CLAUDE.local.md
.riot/venv*
.riot/requirements/*.in

# Auto-generated version file
ddtrace/_version.py

# Benchmarks
artifacts/

Expand Down
34 changes: 1 addition & 33 deletions .gitlab/package.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
compute_library_version:
image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.06-1
tags: [ "arch:amd64" ]
stage: package
id_tokens:
DDOCTOSTS_ID_TOKEN:
aud: dd-octo-sts
script: |
if [ -z ${GH_TOKEN} ]
then
# Use dd-octo-sts to get GitHub token
dd-octo-sts token --scope DataDog/dd-trace-py --policy gitlab.github-access.read > token
gh auth login --with-token < token
rm token
fi
# Prevent git operation errors:
# failed to determine base repo: failed to run git: fatal: detected dubious ownership in repository at ...
git config --global --add safe.directory "${CI_PROJECT_DIR}"
.gitlab/download-library-version-from-gh-actions.sh

echo "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DDTRACE=$(cat library-version/version.txt)" | tee library_version.env
echo "DDTRACE_VERSION=$(cat library-version/version.txt)" | tee -a library_version.env
artifacts:
reports:
dotenv: library_version.env
paths:
- "library-version/version.txt"

download_ddtrace_artifacts:
image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.06-1
tags: [ "arch:amd64" ]
Expand Down Expand Up @@ -88,8 +60,6 @@ publish-wheels-to-s3:
needs:
- job: download_ddtrace_artifacts
artifacts: true
- job: compute_library_version
artifacts: true
variables:
BUCKET: dd-trace-py-builds
script:
Expand All @@ -105,9 +75,7 @@ publish-wheels-to-s3:
- printf ' - %s\n' "${WHEELS[@]}"

- |
if [ -f library-version/version.txt ]; then
VERSION="$(tr -d '\r\n' < library-version/version.txt)"
fi
VERSION=$(unzip -p $(ls ./pywheels/*.whl | head -n 1) '*.dist-info/METADATA' | awk -F': ' '/^Version:/ { print $2; exit }')

if [ -z "${VERSION:-}" ]; then
echo "ERROR: VERSION is not defined or library-version/version.txt missing!"
Expand Down
24 changes: 0 additions & 24 deletions .riot/requirements/16ebde6.txt

This file was deleted.

5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
graft ddtrace
graft src

recursive-exclude * **/__pycache__/*
prune .riot/
prune benchmarks/
prune releasenotes/
prune src/native/target*
10 changes: 8 additions & 2 deletions benchmarks/appsec_iast_aspects_split/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
import os
import re

from ddtrace import get_version

try:
from ddtrace import __version__
except ImportError:
from ddtrace.version import get_version

__version__ = get_version()


version = get_version()
Expand Down Expand Up @@ -31,7 +37,7 @@
# print(f"Warning: {symbol} not found in the current version")

if notfound_symbols:
print("Warning: symbols not found in the tested version [%s]: %s" % (version.version, str(notfound_symbols)))
print("Warning: symbols not found in the tested version [%s]: %s" % (__version__, str(notfound_symbols)))


def iast_add_aspect():
Expand Down
6 changes: 2 additions & 4 deletions ddtrace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@
from .internal.compat import PYTHON_VERSION_INFO # noqa: E402
from .internal.settings._config import config
from .internal.utils.deprecations import DDTraceDeprecationWarning # noqa: E402
from .version import get_version # noqa: E402


__version__ = get_version()
from .version import __version__

# TODO: Deprecate accessing tracer from ddtrace.__init__ module in v4.0
if os.environ.get("_DD_GLOBAL_TRACER_INIT", "true").lower() in ("1", "true"):
from ddtrace.trace import tracer # noqa: F401

__all__ = [
"__version__",
"patch",
"patch_all",
"config",
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/_trace/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
from ddtrace.internal.utils.formats import format_trace_id
from ddtrace.internal.writer import AgentWriterInterface
from ddtrace.internal.writer import HTTPWriter
from ddtrace.version import get_version
from ddtrace.version import __version__


log = get_logger(__name__)
Expand Down Expand Up @@ -165,7 +165,7 @@ def __init__(self) -> None:

metadata = PyTracerMetadata(
runtime_id=get_runtime_id(),
tracer_version=get_version(),
tracer_version=__version__,
hostname=get_hostname(),
service_name=config.service or None,
service_env=config.env or None,
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions ddtrace/internal/core/crashtracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _get_tags(additional_tags: Optional[Dict[str, str]]) -> Dict[str, str]:
runtime_version = platform.python_version()
if runtime_version:
tags["runtime_version"] = runtime_version
library_version = version.get_version()
library_version = version.__version__
if library_version:
tags["library_version"] = library_version

Expand Down Expand Up @@ -127,7 +127,7 @@ def _get_args(additional_tags: Optional[Dict[str, str]]):

tags = _get_tags(additional_tags)

metadata = CrashtrackerMetadata("dd-trace-py", version.get_version(), "python", tags)
metadata = CrashtrackerMetadata("dd-trace-py", version.__version__, "python", tags)

return config, receiver_config, metadata

Expand Down
Empty file.
4 changes: 2 additions & 2 deletions ddtrace/internal/datastreams/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ddtrace.internal.settings._agent import config as agent_config
from ddtrace.internal.settings._config import config
from ddtrace.internal.utils.retry import fibonacci_backoff_with_jitter
from ddtrace.version import get_version
from ddtrace.version import __version__

from .._encoding import packb
from ..agent import get_connection
Expand Down Expand Up @@ -115,7 +115,7 @@ def __init__(
self._buckets = defaultdict(
lambda: Bucket(defaultdict(PathwayStats), defaultdict(int), defaultdict(int))
) # type: DefaultDict[int, Bucket]
self._version = get_version()
self._version = __version__
self._headers = {
"Datadog-Meta-Lang": "python",
"Datadog-Meta-Tracer-Version": self._version,
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions ddtrace/internal/processor/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ddtrace.internal.native import DDSketch
from ddtrace.internal.settings._config import config
from ddtrace.internal.utils.retry import fibonacci_backoff_with_jitter
from ddtrace.version import get_version
from ddtrace.version import __version__

from ...constants import _SPAN_MEASURED_KEY
from .. import agent
Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(
)
self._headers: Dict[str, str] = {
"Datadog-Meta-Lang": "python",
"Datadog-Meta-Tracer-Version": get_version(),
"Datadog-Meta-Tracer-Version": __version__,
"Content-Type": "application/msgpack",
}
self._hostname = ""
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/internal/settings/dynamic_instrumentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ddtrace.internal.settings._agent import config as agent_config
from ddtrace.internal.settings._core import DDConfig
from ddtrace.internal.utils.config import get_application_name
from ddtrace.version import get_version
from ddtrace.version import __version__


DEFAULT_MAX_PROBES = 100
Expand All @@ -17,7 +17,7 @@

def _derive_tags(c):
# type: (DDConfig) -> str
_tags = dict(env=ddconfig.env, version=ddconfig.version, debugger_version=get_version())
_tags = dict(env=ddconfig.env, version=ddconfig.version, debugger_version=__version__)
_tags.update(ddconfig.tags)

# Add git metadata tags, if available
Expand Down
Loading
Loading