From 0273b65c201263493d729372810fcd823ca70c31 Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Mon, 27 Oct 2025 12:47:48 -0400 Subject: [PATCH 1/9] hardcode new major version --- .gitignore | 2 -- ddtrace/_version.py | 34 +++++++++++++++++++++++++++++ pyproject.toml | 8 ++++--- scripts/check_suitespec_coverage.py | 1 + 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 ddtrace/_version.py diff --git a/.gitignore b/.gitignore index 1cf2c168a14..025f052e0e3 100644 --- a/.gitignore +++ b/.gitignore @@ -148,8 +148,6 @@ CLAUDE.local.md .riot/venv* .riot/requirements/*.in -# Auto-generated version file -ddtrace/_version.py # Benchmarks artifacts/ diff --git a/ddtrace/_version.py b/ddtrace/_version.py new file mode 100644 index 00000000000..9fc278ef97a --- /dev/null +++ b/ddtrace/_version.py @@ -0,0 +1,34 @@ +# file generated by setuptools-scm +# don't change, don't track in version control + +__all__ = [ + "__version__", + "__version_tuple__", + "version", + "version_tuple", + "__commit_id__", + "commit_id", +] + +TYPE_CHECKING = False +if TYPE_CHECKING: + from typing import Tuple + from typing import Union + + VERSION_TUPLE = Tuple[Union[int, str], ...] + COMMIT_ID = Union[str, None] +else: + VERSION_TUPLE = object + COMMIT_ID = object + +version: str +__version__: str +__version_tuple__: VERSION_TUPLE +version_tuple: VERSION_TUPLE +commit_id: COMMIT_ID +__commit_id__: COMMIT_ID + +__version__ = version = "4.0.0.dev0" +__version_tuple__ = version_tuple = (4, 0, 0, "dev0", "") + +# __commit_id__ = commit_id = 'g5db831a3e' diff --git a/pyproject.toml b/pyproject.toml index bf2080b78d8..962837a4cb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,11 +10,13 @@ build-backend = "setuptools.build_meta" [project] name = "ddtrace" -dynamic = ["version"] +version = "4.0.0dev0" +# XXX don't merge this to main +# dynamic = ["version"] description = "Datadog APM client library" readme = "README.md" license = { text = "LICENSE.BSD3" } -requires-python = ">=3.8" +requires-python = ">=3.9" authors = [ { name = "Datadog, Inc.", email = "dev@datadoghq.com" }, ] @@ -106,7 +108,7 @@ exclude = ''' [tool.black] line-length = 120 -target_version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312'] +target_version = ['py39', 'py310', 'py311', 'py312'] include = '''\.py[ix]?$''' exclude = ''' ( diff --git a/scripts/check_suitespec_coverage.py b/scripts/check_suitespec_coverage.py index b1673cd50c7..51d4a960ba2 100755 --- a/scripts/check_suitespec_coverage.py +++ b/scripts/check_suitespec_coverage.py @@ -26,6 +26,7 @@ IGNORE_PATTERNS.add("**/*.md") # The aioredis integration is deprecated and untested IGNORE_PATTERNS.add("ddtrace/contrib/aioredis/*") +IGNORE_PATTERNS.add("ddtrace/_version.py") def owners(path: str) -> str: From 5ecccf6de7bd59931e4577ff8d109e582e4e45a6 Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Mon, 27 Oct 2025 13:24:20 -0400 Subject: [PATCH 2/9] undo most of the changes and see if it still works --- .gitignore | 2 ++ ddtrace/_version.py | 34 ----------------------------- ddtrace/version.py | 4 +++- pyproject.toml | 11 +++++----- scripts/check_suitespec_coverage.py | 1 - 5 files changed, 11 insertions(+), 41 deletions(-) delete mode 100644 ddtrace/_version.py diff --git a/.gitignore b/.gitignore index 025f052e0e3..1cf2c168a14 100644 --- a/.gitignore +++ b/.gitignore @@ -148,6 +148,8 @@ CLAUDE.local.md .riot/venv* .riot/requirements/*.in +# Auto-generated version file +ddtrace/_version.py # Benchmarks artifacts/ diff --git a/ddtrace/_version.py b/ddtrace/_version.py deleted file mode 100644 index 9fc278ef97a..00000000000 --- a/ddtrace/_version.py +++ /dev/null @@ -1,34 +0,0 @@ -# file generated by setuptools-scm -# don't change, don't track in version control - -__all__ = [ - "__version__", - "__version_tuple__", - "version", - "version_tuple", - "__commit_id__", - "commit_id", -] - -TYPE_CHECKING = False -if TYPE_CHECKING: - from typing import Tuple - from typing import Union - - VERSION_TUPLE = Tuple[Union[int, str], ...] - COMMIT_ID = Union[str, None] -else: - VERSION_TUPLE = object - COMMIT_ID = object - -version: str -__version__: str -__version_tuple__: VERSION_TUPLE -version_tuple: VERSION_TUPLE -commit_id: COMMIT_ID -__commit_id__: COMMIT_ID - -__version__ = version = "4.0.0.dev0" -__version_tuple__ = version_tuple = (4, 0, 0, "dev0", "") - -# __commit_id__ = commit_id = 'g5db831a3e' diff --git a/ddtrace/version.py b/ddtrace/version.py index 016f71773e4..fef7766ce7a 100644 --- a/ddtrace/version.py +++ b/ddtrace/version.py @@ -7,7 +7,9 @@ def get_version() -> str: from importlib.metadata import version as ilm_version try: - return ilm_version("ddtrace") + version = ilm_version("ddtrace") + print(version) + return version except ModuleNotFoundError: # package is not installed return "dev" diff --git a/pyproject.toml b/pyproject.toml index 962837a4cb8..2651bed5627 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,14 @@ build-backend = "setuptools.build_meta" [project] name = "ddtrace" -version = "4.0.0dev0" -# XXX don't merge this to main -# dynamic = ["version"] +# DEV: to directly override the version specifier, comment this... +#dynamic = ["version"] +# uncomment this +version = "4.0.0.dev0" description = "Datadog APM client library" readme = "README.md" license = { text = "LICENSE.BSD3" } -requires-python = ">=3.9" +requires-python = ">=3.8" authors = [ { name = "Datadog, Inc.", email = "dev@datadoghq.com" }, ] @@ -108,7 +109,7 @@ exclude = ''' [tool.black] line-length = 120 -target_version = ['py39', 'py310', 'py311', 'py312'] +target_version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312'] include = '''\.py[ix]?$''' exclude = ''' ( diff --git a/scripts/check_suitespec_coverage.py b/scripts/check_suitespec_coverage.py index 51d4a960ba2..b1673cd50c7 100755 --- a/scripts/check_suitespec_coverage.py +++ b/scripts/check_suitespec_coverage.py @@ -26,7 +26,6 @@ IGNORE_PATTERNS.add("**/*.md") # The aioredis integration is deprecated and untested IGNORE_PATTERNS.add("ddtrace/contrib/aioredis/*") -IGNORE_PATTERNS.add("ddtrace/_version.py") def owners(path: str) -> str: From 24407e36ba4688d2255361a6a86099c66de4c73c Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Mon, 27 Oct 2025 13:25:00 -0400 Subject: [PATCH 3/9] undo most of the changes and see if it still works --- ddtrace/version.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ddtrace/version.py b/ddtrace/version.py index fef7766ce7a..016f71773e4 100644 --- a/ddtrace/version.py +++ b/ddtrace/version.py @@ -7,9 +7,7 @@ def get_version() -> str: from importlib.metadata import version as ilm_version try: - version = ilm_version("ddtrace") - print(version) - return version + return ilm_version("ddtrace") except ModuleNotFoundError: # package is not installed return "dev" From 52be5aa0cfbc0a1621d521824158e740c65fca72 Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Mon, 27 Oct 2025 13:42:15 -0400 Subject: [PATCH 4/9] do not use setuptools-scm on dev branches unless it is specified in the pyproject --- .github/workflows/build_deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml index 03fb56277fb..679cd9c1471 100644 --- a/.github/workflows/build_deploy.yml +++ b/.github/workflows/build_deploy.yml @@ -50,8 +50,9 @@ jobs: "$GITHUB_REF_NAME" =~ ^[0-9]+\.x$ ]]; then LIBRARY_VERSION=$(setuptools-scm --strip-dev) else + pip install . # All else, maintain the dev version - LIBRARY_VERSION=$(setuptools-scm) + LIBRARY_VERSION=$(python -c 'from ddtrace.version import get_version; print(get_version())') fi echo "${LIBRARY_VERSION}" | tee version.txt From 8bff6c605605e1113ad7c1b755d81374ffd18009 Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Mon, 27 Oct 2025 14:09:33 -0400 Subject: [PATCH 5/9] better way to get version --- .github/workflows/build_deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml index 679cd9c1471..4345a511c4c 100644 --- a/.github/workflows/build_deploy.yml +++ b/.github/workflows/build_deploy.yml @@ -50,9 +50,8 @@ jobs: "$GITHUB_REF_NAME" =~ ^[0-9]+\.x$ ]]; then LIBRARY_VERSION=$(setuptools-scm --strip-dev) else - pip install . # All else, maintain the dev version - LIBRARY_VERSION=$(python -c 'from ddtrace.version import get_version; print(get_version())') + LIBRARY_VERSION=$(grep '^version = ' pyproject.toml | tr -d '"' | cut -d' ' -f3) fi echo "${LIBRARY_VERSION}" | tee version.txt From df385abc50c7a04296b61c365f1359a10e30771c Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Mon, 27 Oct 2025 14:21:51 -0400 Subject: [PATCH 6/9] more generic way to get version string --- tests/lib_injection/conftest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/lib_injection/conftest.py b/tests/lib_injection/conftest.py index 4a19953e736..0042f84aaf8 100644 --- a/tests/lib_injection/conftest.py +++ b/tests/lib_injection/conftest.py @@ -13,9 +13,10 @@ import pytest -from ddtrace._version import __version__ as host_ddtrace_version +from ddtrace.version import get_version +HOST_DDTRACE_VERSION = get_version() LIBS_INJECTION_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../lib-injection")) LIBS_INJECTION_SRC_DIR = os.path.join(LIBS_INJECTION_DIR, "sources") PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) @@ -100,7 +101,7 @@ def ddtrace_injection_artifact(): # 5. Write the ddtrace version file version_file_path = os.path.join(sources_dir_in_session_tmp, "version") with open(version_file_path, "w") as f: - f.write(host_ddtrace_version) + f.write(HOST_DDTRACE_VERSION) yield sources_dir_in_session_tmp From c009fb09ba360adf8363e459a2b688f8a42fdc97 Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Mon, 27 Oct 2025 14:46:31 -0400 Subject: [PATCH 7/9] better comment --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2651bed5627..f39eae86416 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta" name = "ddtrace" # DEV: to directly override the version specifier, comment this... #dynamic = ["version"] -# uncomment this +# ...and uncomment this version = "4.0.0.dev0" description = "Datadog APM client library" readme = "README.md" From d29e088dcef52ce8adcc9c1df67ffdcf1ab1ea2d Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Mon, 27 Oct 2025 14:46:48 -0400 Subject: [PATCH 8/9] reset comments --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f39eae86416..89ed9914f25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,9 +11,9 @@ build-backend = "setuptools.build_meta" [project] name = "ddtrace" # DEV: to directly override the version specifier, comment this... -#dynamic = ["version"] +dynamic = ["version"] # ...and uncomment this -version = "4.0.0.dev0" +# version = "4.0.0.dev0" description = "Datadog APM client library" readme = "README.md" license = { text = "LICENSE.BSD3" } From 595064fff76b3c2f3a21ae8804a78d376e15c7bf Mon Sep 17 00:00:00 2001 From: Emmett Butler Date: Tue, 28 Oct 2025 07:54:38 -0400 Subject: [PATCH 9/9] fallback case --- .github/workflows/build_deploy.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml index 4345a511c4c..5202ebd4c41 100644 --- a/.github/workflows/build_deploy.yml +++ b/.github/workflows/build_deploy.yml @@ -50,8 +50,12 @@ jobs: "$GITHUB_REF_NAME" =~ ^[0-9]+\.x$ ]]; then LIBRARY_VERSION=$(setuptools-scm --strip-dev) else - # All else, maintain the dev version + # 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