Skip to content

Commit

Permalink
Merge branch 'main' into custom-sw-build
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed May 3, 2024
2 parents e64c0aa + 1ee7261 commit a1fb6ea
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: '6.1.0'
hooks:
- id: flake8
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ An easier way to do so is:
1. Run `.tox/lint-some-package/bin/black .`
2. Run `.tox/lint-some-package/bin/isort .`

Or you can call formatting and linting in one command by [pre-commit](https://pre-commit.com/):

```console
$ pre-commit
```

You can also configure it to run lint tools automatically before committing with:

```console
$ pre-commit install

See
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini)
for more detail on available tox commands.
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ codespell==2.1.0
requests==2.31.0
ruamel.yaml==0.17.21
flaky==3.7.0
pre-commit==3.7.0; python_version >= '3.9'
pre-commit==3.5.0; python_version < '3.9'
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
"opentelemetry-instrumentation-dbapi==0.46b0.dev",
"opentelemetry-instrumentation-logging==0.46b0.dev",
"opentelemetry-instrumentation-sqlite3==0.46b0.dev",
"opentelemetry-instrumentation-threading==0.46b0.dev",
"opentelemetry-instrumentation-urllib==0.46b0.dev",
"opentelemetry-instrumentation-wsgi==0.46b0.dev",
]
41 changes: 26 additions & 15 deletions scripts/otel_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,36 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

import tomli
from tomli import load
from os import path, listdir
from subprocess import check_output, CalledProcessError
from requests import get

scripts_path = os.path.dirname(os.path.abspath(__file__))
root_path = os.path.dirname(scripts_path)
instrumentations_path = os.path.join(root_path, "instrumentation")
scripts_path = path.dirname(path.abspath(__file__))
root_path = path.dirname(scripts_path)
instrumentations_path = path.join(root_path, "instrumentation")


def get_instrumentation_packages():
for pkg in sorted(os.listdir(instrumentations_path)):
pkg_path = os.path.join(instrumentations_path, pkg)
if not os.path.isdir(pkg_path):
for pkg in sorted(listdir(instrumentations_path)):
pkg_path = path.join(instrumentations_path, pkg)
if not path.isdir(pkg_path):
continue

error = f"Could not get version for package {pkg}"

try:
hatch_version = check_output(
"hatch version",
shell=True,
cwd=pkg_path,
universal_newlines=True
)

except CalledProcessError as exc:
print(f"Could not get hatch version from path {pkg_path}")
print(exc.output)

try:
response = get(f"https://pypi.org/pypi/{pkg}/json", timeout=10)

Expand All @@ -40,16 +53,14 @@ def get_instrumentation_packages():
print(error)
continue

version = response.json()["info"]["version"]

pyproject_toml_path = os.path.join(pkg_path, "pyproject.toml")
pyproject_toml_path = path.join(pkg_path, "pyproject.toml")

with open(pyproject_toml_path, "rb") as file:
pyproject_toml = tomli.load(file)
pyproject_toml = load(file)

instrumentation = {
"name": pyproject_toml["project"]["name"],
"version": version.strip(),
"version": hatch_version.strip(),
"instruments": pyproject_toml["project"]["optional-dependencies"][
"instruments"
],
Expand All @@ -64,4 +75,4 @@ def get_instrumentation_packages():


if __name__ == "__main__":
print(list(get_instrumentation_packages()))
print(list(get_instrumentation_packages()))

0 comments on commit a1fb6ea

Please sign in to comment.