Skip to content

Commit a1fb6ea

Browse files
Merge branch 'main' into custom-sw-build
2 parents e64c0aa + 1ee7261 commit a1fb6ea

File tree

5 files changed

+53
-16
lines changed

5 files changed

+53
-16
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/psf/black-pre-commit-mirror
3+
rev: 24.3.0
4+
hooks:
5+
- id: black
6+
language_version: python3.11
7+
- repo: https://github.com/pycqa/isort
8+
rev: 5.12.0
9+
hooks:
10+
- id: isort
11+
- repo: https://github.com/pycqa/flake8
12+
rev: '6.1.0'
13+
hooks:
14+
- id: flake8

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ An easier way to do so is:
7070
1. Run `.tox/lint-some-package/bin/black .`
7171
2. Run `.tox/lint-some-package/bin/isort .`
7272

73+
Or you can call formatting and linting in one command by [pre-commit](https://pre-commit.com/):
74+
75+
```console
76+
$ pre-commit
77+
```
78+
79+
You can also configure it to run lint tools automatically before committing with:
80+
81+
```console
82+
$ pre-commit install
83+
7384
See
7485
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini)
7586
for more detail on available tox commands.

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ codespell==2.1.0
1717
requests==2.31.0
1818
ruamel.yaml==0.17.21
1919
flaky==3.7.0
20+
pre-commit==3.7.0; python_version >= '3.9'
21+
pre-commit==3.5.0; python_version < '3.9'

opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@
187187
"opentelemetry-instrumentation-dbapi==0.46b0.dev",
188188
"opentelemetry-instrumentation-logging==0.46b0.dev",
189189
"opentelemetry-instrumentation-sqlite3==0.46b0.dev",
190-
"opentelemetry-instrumentation-threading==0.46b0.dev",
191190
"opentelemetry-instrumentation-urllib==0.46b0.dev",
192191
"opentelemetry-instrumentation-wsgi==0.46b0.dev",
193192
]

scripts/otel_packaging.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,36 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
16-
17-
import tomli
15+
from tomli import load
16+
from os import path, listdir
17+
from subprocess import check_output, CalledProcessError
1818
from requests import get
1919

20-
scripts_path = os.path.dirname(os.path.abspath(__file__))
21-
root_path = os.path.dirname(scripts_path)
22-
instrumentations_path = os.path.join(root_path, "instrumentation")
20+
scripts_path = path.dirname(path.abspath(__file__))
21+
root_path = path.dirname(scripts_path)
22+
instrumentations_path = path.join(root_path, "instrumentation")
2323

2424

2525
def get_instrumentation_packages():
26-
for pkg in sorted(os.listdir(instrumentations_path)):
27-
pkg_path = os.path.join(instrumentations_path, pkg)
28-
if not os.path.isdir(pkg_path):
26+
for pkg in sorted(listdir(instrumentations_path)):
27+
pkg_path = path.join(instrumentations_path, pkg)
28+
if not path.isdir(pkg_path):
2929
continue
3030

3131
error = f"Could not get version for package {pkg}"
32+
33+
try:
34+
hatch_version = check_output(
35+
"hatch version",
36+
shell=True,
37+
cwd=pkg_path,
38+
universal_newlines=True
39+
)
40+
41+
except CalledProcessError as exc:
42+
print(f"Could not get hatch version from path {pkg_path}")
43+
print(exc.output)
44+
3245
try:
3346
response = get(f"https://pypi.org/pypi/{pkg}/json", timeout=10)
3447

@@ -40,16 +53,14 @@ def get_instrumentation_packages():
4053
print(error)
4154
continue
4255

43-
version = response.json()["info"]["version"]
44-
45-
pyproject_toml_path = os.path.join(pkg_path, "pyproject.toml")
56+
pyproject_toml_path = path.join(pkg_path, "pyproject.toml")
4657

4758
with open(pyproject_toml_path, "rb") as file:
48-
pyproject_toml = tomli.load(file)
59+
pyproject_toml = load(file)
4960

5061
instrumentation = {
5162
"name": pyproject_toml["project"]["name"],
52-
"version": version.strip(),
63+
"version": hatch_version.strip(),
5364
"instruments": pyproject_toml["project"]["optional-dependencies"][
5465
"instruments"
5566
],
@@ -64,4 +75,4 @@ def get_instrumentation_packages():
6475

6576

6677
if __name__ == "__main__":
67-
print(list(get_instrumentation_packages()))
78+
print(list(get_instrumentation_packages()))

0 commit comments

Comments
 (0)