From 19263ec74b536131057b8b97e5049b7bedbb059c Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 20 Dec 2023 20:05:50 -0600 Subject: [PATCH] Refactor bootstrap generation This makes the bootstrap script get the package version directly from pypi instead of from our lists of packages. This makes sure that the packages are actually available for the end user to install. Fixes #2053 --- scripts/otel_packaging.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/otel_packaging.py b/scripts/otel_packaging.py index 2f42e44189..53c263a69b 100644 --- a/scripts/otel_packaging.py +++ b/scripts/otel_packaging.py @@ -13,10 +13,11 @@ # limitations under the License. import os -import subprocess from subprocess import CalledProcessError import tomli +from requests import get + scripts_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.dirname(scripts_path) @@ -29,17 +30,21 @@ def get_instrumentation_packages(): if not os.path.isdir(pkg_path): continue + error = f"Could not get version for package {pkg}" try: - version = subprocess.check_output( - "hatch version", - shell=True, - cwd=pkg_path, - universal_newlines=True, + response = get( + f"https://pypi.org/pypi/{pkg}/json" ) - except CalledProcessError as exc: - print(f"Could not get hatch version from path {pkg_path}") - print(exc.output) - raise exc + + except Exception as exc: + print(error) + continue + + if response.status_code != 200: + print(error) + continue + + version = response.json()["info"]["version"] pyproject_toml_path = os.path.join(pkg_path, "pyproject.toml")