Skip to content

Commit c0f08aa

Browse files
authored
chore: update tox OTel test deps to 1.40/0.61 and include tox.ini in nightly dependency updates (#693)
*Description of changes:* Currently builds are running with the following warning: ``` opentelemetry-sdk 1.40.0 requires opentelemetry-api==1.40.0, but you have opentelemetry-api 1.39.1 which is incompatible. opentelemetry-semantic-conventions 0.61b0 requires opentelemetry-api==1.40.0, but you have opentelemetry-api 1.39.1 which is incompatible. opentelemetry-test-utils 0.60b1 requires opentelemetry-sdk==1.39.1, but you have opentelemetry-sdk 1.40.0 which is incompatible. ``` Update tox.ini OTel test deps to 1.40/0.61 and auto-update tox repo branches in nightly builds, validated with the following script: ``` python -c " from scripts.update_dependencies import update_file_dependencies import shutil shutil.copy('tox.ini', '/tmp/tox_test.ini') result = update_file_dependencies('/tmp/tox_test.ini', '1.41.0', '0.62b0', {}) print(f'Updated: {result}') with open('/tmp/tox_test.ini') as f: for line in f: if 'CORE_REPO=' in line or 'CONTRIB_REPO=' in line: print(line.strip()) Updated /tmp/tox_test.ini Updated: True CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@release/v1.41.x-0.62bx CONTRIB_REPO=git+https://github.com/open-telemetry/opentelemetry-python-contrib.git@release/v1.41.x-0.62bx ``` By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 831c772 commit c0f08aa

2 files changed

Lines changed: 41 additions & 26 deletions

File tree

scripts/update_dependencies.py

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,33 @@
7878
]
7979

8080

81+
def _replace_dep_versions(content, deps, version):
82+
"""Replace version pins for a list of dependencies in content."""
83+
updated = False
84+
for dep in deps:
85+
pattern = rf'"?{re.escape(dep)}\s*==\s*[^\s,\]"]*"?'
86+
replacement = f'"{dep} == {version}"' if '"' in content else f"{dep}=={version}"
87+
if re.search(pattern, content):
88+
content = re.sub(pattern, replacement, content)
89+
updated = True
90+
return content, updated
91+
92+
93+
def _replace_tox_repo_branches(content, otel_python_version, otel_contrib_version):
94+
"""Replace tox CORE_REPO/CONTRIB_REPO branch references."""
95+
core_match = re.match(r"(\d+\.\d+)", otel_python_version)
96+
contrib_match = re.match(r"(\d+\.\d+b?)", otel_contrib_version)
97+
if not (core_match and contrib_match):
98+
return content, False
99+
new_branch = f"release/v{core_match.group(1)}.x-{contrib_match.group(1)}x"
100+
pattern = (
101+
r"((?:CORE|CONTRIB)_REPO=git\+https://github\.com/open-telemetry/"
102+
r"opentelemetry-python(?:-contrib)?\.git@)release/v[\d.]+x-[\d.b]+x"
103+
)
104+
content, count = re.subn(pattern, rf"\g<1>{new_branch}", content)
105+
return content, bool(count)
106+
107+
81108
def update_file_dependencies(file_path, otel_python_version, otel_contrib_version, aws_versions):
82109
"""Update all Otel dependencies in a given file"""
83110
try:
@@ -86,31 +113,19 @@ def update_file_dependencies(file_path, otel_python_version, otel_contrib_versio
86113

87114
updated = False
88115

89-
# Update opentelemetry-python dependencies
90-
for dep in PYTHON_CORE_DEPS:
91-
# Handle both "package == version" and package==version formats
92-
pattern = rf'"?{re.escape(dep)}\s*==\s*[^\s,\]"]*"?'
93-
replacement = f'"{dep} == {otel_python_version}"' if '"' in content else f"{dep}=={otel_python_version}"
94-
if re.search(pattern, content):
95-
content = re.sub(pattern, replacement, content)
96-
updated = True
97-
98-
# Update opentelemetry-python-contrib dependencies
99-
for dep in CONTRIB_DEPS:
100-
pattern = rf'"?{re.escape(dep)}\s*==\s*[^\s,\]"]*"?'
101-
replacement = f'"{dep} == {otel_contrib_version}"' if '"' in content else f"{dep}=={otel_contrib_version}"
102-
if re.search(pattern, content):
103-
content = re.sub(pattern, replacement, content)
104-
updated = True
105-
106-
# Update independently versioned AWS dependencies
116+
content, changed = _replace_dep_versions(content, PYTHON_CORE_DEPS, otel_python_version)
117+
updated = updated or changed
118+
119+
content, changed = _replace_dep_versions(content, CONTRIB_DEPS, otel_contrib_version)
120+
updated = updated or changed
121+
107122
for dep, version in aws_versions.items():
108123
if version:
109-
pattern = rf'"?{re.escape(dep)}\s*==\s*[^\s,\]"]*"?'
110-
replacement = f'"{dep} == {version}"' if '"' in content else f"{dep}=={version}"
111-
if re.search(pattern, content):
112-
content = re.sub(pattern, replacement, content)
113-
updated = True
124+
content, changed = _replace_dep_versions(content, [dep], version)
125+
updated = updated or changed
126+
127+
content, changed = _replace_tox_repo_branches(content, otel_python_version, otel_contrib_version)
128+
updated = updated or changed
114129

115130
if updated:
116131
with open(file_path, "w", encoding="utf-8") as output_file:
@@ -149,6 +164,7 @@ def main():
149164
"contract-tests/images/mock-collector/requirements.txt",
150165
"contract-tests/tests/pyproject.toml",
151166
"lambda-layer/src/tests/requirements.txt",
167+
"tox.ini",
152168
]
153169

154170
any_updated = False

tox.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ deps =
2727
3.{10,11,12,13}-test-aws-opentelemetry-distro: uvicorn
2828

2929
setenv =
30-
; TODO: The two repos branches need manual updated over time, need to figure out a more sustainable solution.
31-
CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@release/v1.39.x-0.60bx
32-
CONTRIB_REPO=git+https://github.com/open-telemetry/opentelemetry-python-contrib.git@release/v1.39.x-0.60bx
30+
CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@release/v1.40.x-0.61bx
31+
CONTRIB_REPO=git+https://github.com/open-telemetry/opentelemetry-python-contrib.git@release/v1.40.x-0.61bx
3332
; Enable coverage collection in subprocesses spawned during tests.
3433
; Works with parallel=true in .coveragerc so each process writes a separate data file.
3534
COVERAGE_PROCESS_START={toxinidir}/.coveragerc

0 commit comments

Comments
 (0)