Skip to content

Commit e905b5a

Browse files
committed
introduce uv
Signed-off-by: emdneto <[email protected]>
1 parent ac7329c commit e905b5a

File tree

6 files changed

+777
-13
lines changed

6 files changed

+777
-13
lines changed

.github/workflows/misc_0.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,21 @@ jobs:
253253

254254
- name: Run tests
255255
run: tox -e ruff
256+
257+
pre-commit:
258+
name: pre-commit
259+
runs-on: ubuntu-latest
260+
steps:
261+
- name: Checkout repo @ SHA - ${{ github.sha }}
262+
uses: actions/checkout@v4
263+
264+
- name: Set up Python 3.11
265+
uses: actions/setup-python@v5
266+
with:
267+
python-version: "3.11"
268+
269+
- name: Install tox
270+
run: pip install tox
271+
272+
- name: Run tests
273+
run: tox -e pre-commit

.pre-commit-config.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
repos:
2-
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
# Ruff version.
4-
rev: v0.6.9
5-
hooks:
6-
# Run the linter.
7-
- id: ruff
8-
args: ["--fix", "--show-fixes"]
9-
# Run the formatter.
10-
- id: ruff-format
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.6.9
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
args: ["--fix", "--show-fixes"]
9+
# Run the formatter.
10+
- id: ruff-format
11+
- repo: https://github.com/astral-sh/uv-pre-commit
12+
# uv version.
13+
rev: 0.6.0
14+
hooks:
15+
- id: uv-lock

CONTRIBUTING.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ some aspects of development, including testing against multiple Python versions.
4545
To install `tox`, run:
4646

4747
```console
48-
$ pip install tox
48+
pip install tox
4949
```
5050

5151
You can run `tox` with the following arguments:
@@ -60,19 +60,36 @@ You can run `tox` with the following arguments:
6060
- `tox -e lint-some-package` to run lint checks on `some-package`
6161
- `tox -e generate-workflows` to run creation of new CI workflows if tox environments have been updated
6262
- `tox -e ruff` to run ruff linter and formatter checks against the entire codebase
63+
- `tox -e pre-commit` to run all `pre-commit` actions
6364

6465
`ruff check` and `ruff format` are executed when `tox -e ruff` is run. We strongly recommend you to configure [pre-commit](https://pre-commit.com/) locally to run `ruff` automatically before each commit by installing it as git hooks. You just need to [install pre-commit](https://pre-commit.com/#install) in your environment:
6566

6667
```console
67-
$ pip install pre-commit -c dev-requirements.txt
68+
pip install pre-commit -c dev-requirements.txt
6869
```
6970

7071
and run this command inside the git repository:
7172

7273
```console
73-
$ pre-commit install
74+
pre-commit install
7475
```
7576

77+
### Virtual Environment
78+
79+
You can also create a single virtual environment to make it easier to run local tests.
80+
81+
For that, you'll need to install [`uv`](https://docs.astral.sh/uv/getting-started/installation/).
82+
83+
After installing `uv`, you can run the following command:
84+
85+
```sh
86+
uv sync
87+
```
88+
89+
This will create a virtual environment in the `.venv` directory and install all the necessary dependencies.
90+
91+
### Public Symbols
92+
7693
We try to keep the amount of _public symbols_ in our code minimal. A public symbol is any Python identifier that does not start with an underscore.
7794
Every public symbol is something that has to be kept in order to maintain backwards compatibility, so we try to have as few as possible.
7895

@@ -107,7 +124,7 @@ See
107124
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python/blob/main/tox.ini)
108125
for more detail on available tox commands.
109126

110-
#### Contrib repo
127+
### Contrib repo
111128

112129
Some of the `tox` targets install packages from the [OpenTelemetry Python Contrib Repository](https://github.com/open-telemetry/opentelemetry-python.git) via
113130
pip. The version of the packages installed defaults to the `main` branch in that repository when `tox` is run locally. It is possible to install packages tagged

pyproject.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,49 @@
1+
[project]
2+
name = "opentelemetry-python"
3+
version = "0.0.0" # This is not used.
4+
requires-python = ">=3.8"
5+
dependencies = [
6+
"opentelemetry-api",
7+
"opentelemetry-sdk",
8+
"opentelemetry-semantic-conventions",
9+
"opentelemetry-proto",
10+
"opentelemetry-test-utils",
11+
"opentelemetry-exporter-otlp-proto-grpc",
12+
"opentelemetry-exporter-otlp-proto-http",
13+
"opentelemetry-exporter-otlp-proto-common",
14+
"opentelemetry-exporter-otlp",
15+
"opentelemetry-propagator-jaeger",
16+
"opentelemetry-propagator-b3",
17+
"opentelemetry-exporter-zipkin-json",
18+
"opentelemetry-exporter-prometheus",
19+
]
20+
21+
# https://docs.astral.sh/uv/reference/settings/
22+
[tool.uv]
23+
package = false # https://docs.astral.sh/uv/reference/settings/#package
24+
required-version = ">=0.6.0"
25+
26+
[tool.uv.sources]
27+
opentelemetry-api = { path = "opentelemetry-api", editable = true}
28+
opentelemetry-sdk = { path = "opentelemetry-sdk", editable = true }
29+
opentelemetry-proto = { path = "opentelemetry-proto", editable = true }
30+
opentelemetry-semantic-conventions = { path = "opentelemetry-semantic-conventions", editable = true }
31+
opentelemetry-test-utils = { path = "tests/opentelemetry-test-utils", editable = true }
32+
opentelemetry-exporter-otlp-proto-grpc = { path = "exporter/opentelemetry-exporter-otlp-proto-grpc", editable = true }
33+
opentelemetry-exporter-otlp-proto-http = { path = "exporter/opentelemetry-exporter-otlp-proto-http", editable = true }
34+
opentelemetry-exporter-otlp-proto-common = { path = "exporter/opentelemetry-exporter-otlp-proto-common", editable = true }
35+
# zipkin
36+
# opentelemetry-exporter-zipkin-proto-http = { path = "exporter/opentelemetry-exporter-zipkin-proto-http", editable = true }
37+
opentelemetry-exporter-zipkin-json = { path = "exporter/opentelemetry-exporter-zipkin-json", editable = true }
38+
# opencensus
39+
# opentelemetry-exporter-opencensus = { path = "exporter/opentelemetry-exporter-opencensus", editable = true }
40+
# prometheus
41+
opentelemetry-exporter-prometheus = { path = "exporter/opentelemetry-exporter-prometheus", editable = true }
42+
opentelemetry-exporter-otlp = { path = "exporter/opentelemetry-exporter-otlp", editable = true }
43+
# propagators
44+
opentelemetry-propagator-jaeger = { path = "propagator/opentelemetry-propagator-jaeger", editable = true }
45+
opentelemetry-propagator-b3 = { path = "propagator/opentelemetry-propagator-b3", editable = true }
46+
147
[tool.pytest.ini_options]
248
addopts = "-rs -v"
349
log_cli = true

tox.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ envlist =
9696
shellcheck
9797
generate-workflows
9898
ruff
99+
pre-commit
99100

100101
[testenv]
101102
deps =
@@ -360,6 +361,16 @@ commands =
360361

361362
[testenv:ruff]
362363
basepython: python3
364+
setenv=
365+
SKIP=uv-lock
366+
deps =
367+
-c {toxinidir}/dev-requirements.txt
368+
pre-commit
369+
commands =
370+
pre-commit run --color=always --all-files {posargs}
371+
372+
[testenv:pre-commit]
373+
basepython: python3
363374
deps =
364375
-c {toxinidir}/dev-requirements.txt
365376
pre-commit

0 commit comments

Comments
 (0)