Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
99964c6
chore: use static versions instead of setuptools-scm
brettlangdon Nov 13, 2025
d82bdce
add missing ddtrace/internal/dist_computing/__init__.py file
brettlangdon Nov 13, 2025
d84a543
add ddtrace/appsec/_exploit_prevention/__init__.py
brettlangdon Nov 13, 2025
7086fe3
fix missing pyx and namespace packages
brettlangdon Nov 13, 2025
8b796a0
fix ddtrace.__version__
brettlangdon Nov 13, 2025
432a2ca
use static versions internally
brettlangdon Nov 13, 2025
dfed56d
fix formatting
brettlangdon Nov 13, 2025
b709231
fix linting
brettlangdon Nov 13, 2025
6a88edd
include .pxd
brettlangdon Nov 13, 2025
9661bc0
also include src dir
brettlangdon Nov 13, 2025
e46fee7
fix MANIFEST.in?
brettlangdon Nov 13, 2025
9ef9050
Merge branch 'main' into brettlangdon/static.versions
christophe-papazian Nov 13, 2025
bfb96dd
remnants of _version.py going away
brettlangdon Nov 13, 2025
e01460f
replace slotscheck with ruff
brettlangdon Nov 13, 2025
099d2b3
fix new ruff issues
brettlangdon Nov 13, 2025
a66e3ee
remove unused riot requirements.txt
brettlangdon Nov 13, 2025
2949063
get suitespec checks passing
brettlangdon Nov 13, 2025
512cd8f
Merge branch 'main' into brettlangdon/static.versions
brettlangdon Nov 14, 2025
75439a4
add CI check for static version correctness
brettlangdon Nov 14, 2025
f9bb555
Merge branch 'main' into brettlangdon/static.versions
brettlangdon Nov 14, 2025
8464924
fix formatting
brettlangdon Nov 14, 2025
5240091
Merge remote-tracking branch 'origin/main' into brettlangdon/static.v…
brettlangdon Nov 17, 2025
5b5eae9
fix version parsing and drop version specific s3 endpoints
brettlangdon Nov 17, 2025
e176941
fix package version and add verification
brettlangdon Nov 17, 2025
fdf809a
Merge remote-tracking branch 'origin/main' into brettlangdon/static.v…
brettlangdon Nov 17, 2025
af7dc82
fix appsec benchmarks
brettlangdon Nov 17, 2025
85028aa
fix formatting
brettlangdon Nov 17, 2025
db4ae26
use importlib metadata to avoid duplicate locations for version
brettlangdon Nov 17, 2025
fcc1211
use ddtrace.__version__ not ddtrace.version.__version__
brettlangdon Nov 17, 2025
0b88608
don't use ddtrace.__version__ internally
brettlangdon Nov 18, 2025
6cd34dc
Merge remote-tracking branch 'origin/main' into brettlangdon/static.v…
brettlangdon Nov 18, 2025
13ed545
ignore tests and benchmarks
brettlangdon Nov 18, 2025
fdd6101
fix linting
brettlangdon Nov 18, 2025
b6bda49
Update pyproject.toml
brettlangdon Nov 18, 2025
7103d24
Merge branch 'main' into brettlangdon/static.versions
brettlangdon Nov 19, 2025
4cd9dcb
Merge branch 'main' into brettlangdon/static.versions
christophe-papazian Nov 20, 2025
9773c36
Merge branch 'main' into brettlangdon/static.versions
brettlangdon Nov 20, 2025
43a3555
Merge branch 'main' into brettlangdon/static.versions
brettlangdon Nov 20, 2025
14e24d0
Merge remote-tracking branch 'origin/main' into brettlangdon/static.v…
brettlangdon Nov 21, 2025
659766c
add ci release check that wheel version matches tag
brettlangdon Nov 21, 2025
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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ CLAUDE.local.md
.riot/venv*
.riot/requirements/*.in

# Auto-generated version file
ddtrace/_version.py

# Benchmarks
artifacts/

Expand Down
62 changes: 19 additions & 43 deletions .gitlab/package.yml
Original file line number Diff line number Diff line change
@@ -1,33 +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: |
set -eo pipefail

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 @@ -90,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 @@ -107,24 +75,20 @@ 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=$(grep '^version = ' pyproject.toml | head -1 | sed -E 's/version = "(.+)"/\1/')

if [ -z "${VERSION:-}" ]; then
echo "ERROR: VERSION is not defined or library-version/version.txt missing!"
echo "ERROR: VERSION is not defined in pyproject.toml!"
exit 1
fi

- printf 'Detected version %s\n' ${VERSION}

# Upload all wheels to versioned prefix and pipeline-id prefix
- aws s3 cp --recursive --exclude "*" --include "*.whl" pywheels "s3://${BUCKET}/${VERSION}/"
# Upload all wheels to pipeline-id prefix
- aws s3 cp --recursive --exclude "*" --include "*.whl" pywheels "s3://${BUCKET}/${CI_PIPELINE_ID}/"

- |
VERSION_ENC="${VERSION//+/%2B}"
S3_BASE_VER="https://${BUCKET}.s3.amazonaws.com/${VERSION_ENC}"
S3_BASE_PIPE="https://${BUCKET}.s3.amazonaws.com/${CI_PIPELINE_ID}"

generate_index_html() {
Expand All @@ -141,15 +105,27 @@ publish-wheels-to-s3:
}

# Generate both minimal indexes
generate_index_html "index.version.html"
generate_index_html "index.pipeline.html"

# Upload to each S3 prefix
aws s3 cp "index.version.html" "s3://${BUCKET}/${VERSION}/index.html" --content-type text/html
aws s3 cp "index.pipeline.html" "s3://${BUCKET}/${CI_PIPELINE_ID}/index.html" --content-type text/html

# Print the clickable URLs
VER_INDEX_URL="${S3_BASE_VER}/index.html"
PIPE_INDEX_URL="${S3_BASE_PIPE}/index.html"
echo "S3 index (version): ${VER_INDEX_URL}"
echo "S3 index (pipeline): ${PIPE_INDEX_URL}"


# Fail if the downloaded package versions do not match the git tag version
verify_package_version:
image: registry.ddbuild.io/images/mirror/python:3.14.0
tags: [ "arch:amd64" ]
stage: package
needs: [ download_ddtrace_artifacts ]
only:
# v2.10.0
# v2.10.1
# v2.10.0rc0
# v2.10.0rc5
- /^v[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?$/
script:
- .gitlab/verify-package-versions.sh
32 changes: 32 additions & 0 deletions .gitlab/verify-package-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail

WHEEL_FILES=(pywheels/*.whl)
if [ ${#WHEEL_FILES[@]} -eq 0 ]; then
echo "No wheels found in pywheels/"; exit 1
fi

VERSION_TAG="${CI_COMMIT_TAG#v}"
echo "Verifying package version ${VERSION_TAG}"

for wf in "${WHEEL_FILES[@]}"; do
echo "Checking wheel file: ${wf}"
WHEEL_VERSION=$(basename "${wf}" | awk -F '-' '{print $2}')
if [ "${WHEEL_VERSION}" != "${VERSION_TAG}" ]; then
echo "ERROR: Wheel version ${WHEEL_VERSION} does not match tag version ${VERSION_TAG}"
exit 1
fi
done

SDIST_FILES=(pywheels/*.tar.gz)
if [ ${#SDIST_FILES[@]} -eq 0 ]; then
echo "No sdist files found in pywheels/"; exit 1
fi
for sf in "${SDIST_FILES[@]}"; do
echo "Checking sdist file: ${sf}"
SDIST_VERSION=$(basename "${sf}" | awk -F '-' '{print $2}' | sed 's/\.tar\.gz$//')
if [ "${SDIST_VERSION}" != "${VERSION_TAG}" ]; then
echo "ERROR: Sdist version ${SDIST_VERSION} does not match tag version ${VERSION_TAG}"
exit 1
fi
done
50 changes: 50 additions & 0 deletions .sg/rules/ddtrace-version-import.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
id: ddtrace-version-import
message: Import `__version__` from `ddtrace.version` instead of `ddtrace`
severity: error
language: python
ignores:
- "tests/**"
- "benchmarks/**"
rule:
any:
# Match: from ddtrace import __version__ (using variable with constraint)
- pattern: from $MOD import __version__
# Match: from ddtrace import __version__ as $ALIAS
- pattern: from $MOD import __version__ as $ALIAS
# Match: from ddtrace import $$$IMPORTS, __version__
- pattern: from $MOD import $$$IMPORTS, __version__
# Match: from ddtrace import $$$IMPORTS, __version__ as $ALIAS
- pattern: from $MOD import $$$IMPORTS, __version__ as $ALIAS
# Match: from ddtrace import __version__, $$$IMPORTS
- pattern: from $MOD import __version__, $$$IMPORTS
# Match: from ddtrace import __version__ as $ALIAS, $$$IMPORTS
- pattern: from $MOD import __version__ as $ALIAS, $$$IMPORTS
# Match: from ddtrace import $$$IMPORTS, __version__, $$$IMPORTS (middle case)
- pattern: from $MOD import $$$IMPORTS, __version__, $$$IMPORTS
# Match: from ddtrace import $$$IMPORTS, __version__ as $ALIAS, $$$IMPORTS (middle case with alias)
- pattern: from $MOD import $$$IMPORTS, __version__ as $ALIAS, $$$IMPORTS
# Match: ddtrace.__version__ usage
- pattern: ddtrace.__version__
constraints:
MOD:
regex: "^ddtrace$"
ALIAS:
regex: ".*"
note: |
The `__version__` attribute should be imported from `ddtrace.version` to avoid circular dependencies and ensure proper version management.

Change your imports as follows:

**Before:**
```python
from ddtrace import __version__
import ddtrace
version = ddtrace.__version__
```

**After:**
```python
from ddtrace.version import __version__
```

This ensures that `__version__` is accessed from the dedicated version module, preventing circular import issues and making version management more explicit.
Loading
Loading