Remove packaging as a runtime dependency of opentelemetry-instrumentation - #4883
Open
ocelotl wants to merge 2 commits into
Open
Remove packaging as a runtime dependency of opentelemetry-instrumentation#4883ocelotl wants to merge 2 commits into
packaging as a runtime dependency of opentelemetry-instrumentation#4883ocelotl wants to merge 2 commits into
Conversation
ocelotl
force-pushed
the
issue_4882_remove_packaging_dependency
branch
from
July 28, 2026 22:23
d009c76 to
d13f378
Compare
This was referenced Jul 28, 2026
packaging as a runtime dependency of the instrumentation packagespackaging as a runtime dependency of opentelemetry-instrumentation
ocelotl
force-pushed
the
issue_4882_remove_packaging_dependency
branch
3 times, most recently
from
July 28, 2026 23:10
476387a to
6de1be6
Compare
ocelotl
marked this pull request as ready for review
July 28, 2026 23:14
Adds opentelemetry.instrumentation._packaging with PEP 440 Version and PEP 508 Requirement/specifier/marker support, implementing the subset of packaging used by opentelemetry-instrumentation. Behaviour was validated against packaging across a large corpus of version/specifier/marker/requirement inputs.
Points _semconv (version comparison) and dependencies.py/bootstrap.py (requirement parsing) at opentelemetry.instrumentation._packaging, removes packaging from opentelemetry-instrumentation's runtime dependencies and refreshes uv.lock.
ocelotl
force-pushed
the
issue_4882_remove_packaging_dependency
branch
from
July 28, 2026 23:23
6de1be6 to
ebabae2
Compare
ocelotl
added a commit
to dash0hq/opentelemetry-python-distribution
that referenced
this pull request
Aug 5, 2026
…acement The injector bootstrap script (sitecustomize.py) used packaging.Requirement and packaging.Version for its dependency-conflict check, making the distro's own code depend on packaging being importable in the injected process. Vendor the small PEP 440/508 implementation from opentelemetry.instrumentation._packaging (open-telemetry/opentelemetry-python-contrib#4883) as dash0.opentelemetry.injector._packaging and import Requirement/Version from there instead. The copy is verbatim except for rewritten internal import paths. TO BE REMOVED: once the same local implementation is available in opentelemetry-instrumentation (i.e. it ships _packaging in a release this distribution pins), delete the vendored package and its tests and repoint the imports in sitecustomize.py and the tests to opentelemetry.instrumentation._packaging. The note is recorded in the vendored _packaging/__init__.py and at the sitecustomize.py import site. sitecustomize.py uses SpecifierSet.contains() rather than the `in` operator, matching upstream, since the vendored specifiers deliberately do not implement __contains__. The two tests that imported packaging (test_sitecustomize.py, test_instrumentations.py) now import from the vendored module; the vendored upstream tests are included. The vendored code and its tests are excluded from ruff, as with the other vendored packages. The packaging == 26.2 pin in pyproject.toml stays: packaging is still pulled in transitively via opentelemetry-instrumentation, so check_pinned_dependencies still requires it declared. It can be removed once that transitive dependency is gone. Bump the distro version 0.3.1 -> 0.3.2 (packaged files changed). Refs #48
mmanciop
pushed a commit
to dash0hq/opentelemetry-python-distribution
that referenced
this pull request
Aug 6, 2026
…acement (#53) The injector bootstrap script (sitecustomize.py) used packaging.Requirement and packaging.Version for its dependency-conflict check, making the distro's own code depend on packaging being importable in the injected process. Vendor the small PEP 440/508 implementation from opentelemetry.instrumentation._packaging (open-telemetry/opentelemetry-python-contrib#4883) as dash0.opentelemetry.injector._packaging and import Requirement/Version from there instead. The copy is verbatim except for rewritten internal import paths. TO BE REMOVED: once the same local implementation is available in opentelemetry-instrumentation (i.e. it ships _packaging in a release this distribution pins), delete the vendored package and its tests and repoint the imports in sitecustomize.py and the tests to opentelemetry.instrumentation._packaging. The note is recorded in the vendored _packaging/__init__.py and at the sitecustomize.py import site. sitecustomize.py uses SpecifierSet.contains() rather than the `in` operator, matching upstream, since the vendored specifiers deliberately do not implement __contains__. The two tests that imported packaging (test_sitecustomize.py, test_instrumentations.py) now import from the vendored module; the vendored upstream tests are included. The vendored code and its tests are excluded from ruff, as with the other vendored packages. The packaging == 26.2 pin in pyproject.toml stays: packaging is still pulled in transitively via opentelemetry-instrumentation, so check_pinned_dependencies still requires it declared. It can be removed once that transitive dependency is gone. Bump the distro version 0.3.1 -> 0.3.2 (packaged files changed). Refs #48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removes
packagingas a runtime dependency ofopentelemetry-instrumentation,replacing its use with a small internal implementation under
opentelemetry.instrumentation._packaging:Version(parsing, normalization, ordering) for the schema-versioncomparison in
_semconv.py.Requirementparsing plus PEP 440 specifier containment and markerevaluation for the dependency-conflict machinery in
dependencies.pyandbootstrap.py.packagingis dropped fromopentelemetry-instrumentation'sdependencies.Motivation: the auto-instrumentation injector ships instrumentation and its
runtime dependencies onto the target application's
PYTHONPATH, so every runtimedependency (like
packaging) is injected into the user's process and risksversion shadowing/conflicts. See the issue for details.
The same removal for the four instrumentations that depend on
packaging(falcon #4884, flask #4885, pika #4886, sqlalchemy #4887) is handled in separate
PRs that reuse the internal implementation introduced here.
Fixes #4882
Type of change
How Has This Been Tested?
modules (
tests/test_packaging_*.py).packagingacross a broadcorpus of PEP 440 versions and specifiers (parsing, normalization, attributes
and ordering) with no divergence.
test_dependencies.pycontinues to pass against the internalimplementation.
Does This PR Require a Core Repo Change?
Checklist: