Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UV to install all needed packages locally #3124

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

Kludex
Copy link
Contributor

@Kludex Kludex commented Dec 20, 2024

This is specifically to have a single virtual environment with all dependencies to make it easier to develop here.

@Kludex Kludex requested a review from a team as a code owner December 20, 2024 12:38
pyproject.toml Show resolved Hide resolved
Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loved this. I would say other than speed-up local development, this paves the way to adopt uv in opentelemetry-python.

I think it will be necessary to add some instructions on how to use that. But just a note for reviewers:

With a simple command like uv sync you can have all packages from the project installed locally. If you want to install only one package you can run: uv sync --package opentelemetry-instrumentation-sqlalchemy for example.

@xrmx
Copy link
Contributor

xrmx commented Dec 23, 2024

Loved this. I would say other than speed-up local development, this paves the way to adopt uv in opentelemetry-python.

I think it will be necessary to add some instructions on how to use that. But just a note for reviewers:

With a simple command like uv sync you can have all packages from the project installed locally. If you want to install only one package you can run: uv sync --package opentelemetry-instrumentation-sqlalchemy for example.

Sure but aren't we adding another source of dependabot warnings? I'm fine on adding the metadata to the pyproject for people using uv but isn't this duplicating what we use tox for?

@Kludex
Copy link
Contributor Author

Kludex commented Dec 23, 2024

Sure but aren't we adding another source of dependabot warnings?

Unfortunately/Fortunately, Dependabot doesn't see the uv.lock yet.

I'm fine on adding the metadata to the pyproject for people using uv but isn't this duplicating what we use tox for?

Not really. The idea here is to have a single virtual environment that can be used by the IDE, and to simplify local development (running some scripts locally to test some integrations, etc). The tox is used to run the tests with multiple different environments, it doesn't really create this virtual environment.

@idan-rahamim-lendbuzz
Copy link

Is it possible that opentelemetry-bootstrap --action=install would install with UV/Poetry instead of pip?

@Kludex
Copy link
Contributor Author

Kludex commented Dec 29, 2024

Is it possible that opentelemetry-bootstrap --action=install would install with UV/Poetry instead of pip?

This is not related with this PR, please create an issue.

pyproject.toml Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
@emdneto emdneto added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jan 14, 2025
pyproject.toml Show resolved Hide resolved
uv.lock Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may need to regenerate the lockfile, it fails for me unless i regenerate with

      AttributeError: module 'falcon' has no attribute '__version__'

      hint: This usually indicates a problem with the package or the build environment.
  help: `falcon` (v3.1.1) was included because `opentelemetry-python-contrib` (v0.0.0) depends on `opentelemetry-instrumentation-falcon[instruments]`
        (v0.51b0.dev0) which depends on `falcon`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What fails? Which command did you use?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv sync

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That updates the lock file.

I'll write some notes on how to use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd need to do uv sync --frozen, which doesn't update the lockfile.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv sync --frozen is failing for me too

Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kludex could you please write a guide on how people can use this setup? Maybe a small section in CONTRIBUTING.md is enough.

Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to this. I have some awkward instructions on how to install things which I hope uv makes easier. Each time I use uv/uvx it seems quicker and simpler than before, so 👍

@Kludex
Copy link
Contributor Author

Kludex commented Jan 24, 2025

I'm ready.

@xrmx
Copy link
Contributor

xrmx commented Jan 28, 2025

Looks like the uv.lock is confusing ruff? Also curious aws xray propagator test failures.

@Kludex
Copy link
Contributor Author

Kludex commented Feb 6, 2025

Looks like the uv.lock is confusing ruff? Also curious aws xray propagator test failures.

No...

[testenv:ruff]
basepython: python3
deps =
  -c {toxinidir}/dev-requirements.txt
  pre-commit
commands =
  pre-commit run --color=always --all-files {posargs}

Calling the test ruff but running pre-commit doesn't help 👀

@Kludex
Copy link
Contributor Author

Kludex commented Feb 6, 2025

Also curious aws xray propagator test failures.

It seems it's looking to the uv.lock.

@Kludex
Copy link
Contributor Author

Kludex commented Feb 6, 2025

Also curious aws xray propagator test failures.

It seems it's looking to the uv.lock.

@emdneto we talked about this at some point. Do you remember why?

"instrumentation/*",
"exporter/*",
"opentelemetry-instrumentation",
"propagator/*",
Copy link
Member

@emdneto emdneto Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kludex According to documentation:

Within a workspace, dependencies on workspace members are facilitated via tool.uv.sources,

so since we have tests pointing to pinned versions of API (as example 1.16 for awsxray propagator) uv is trying to install it using the source at Git instead of PyPI and this version doesn't exist in ref main. I think this is happening because tox-uv is running based on what is defined at pyproject.toml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same will happen for all packages that are tested using pinned released versions of api/sdk in test requirements (example: gen-ai stuff)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of workspaces maybe we can have this for sources:

opentelemetry-propagator-aws-xray = { path = "./propagator/opentelemetry-propagator-aws-xray", editable = true }
opentelemetry-propagator-ot-trace = { path = "./propagator/opentelemetry-propagator-ot-trace", editable = true  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants