Skip to content

Commit

Permalink
Refactor bootstrap generation
Browse files Browse the repository at this point in the history
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 open-telemetry#2053
  • Loading branch information
ocelotl committed Feb 29, 2024
1 parent 8daa8ad commit 19263ec
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions scripts/otel_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")

Expand Down

0 comments on commit 19263ec

Please sign in to comment.