Skip to content

Commit c650ec9

Browse files
committed
version gate the patch.py file removing
1 parent 4ef4880 commit c650ec9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,15 @@ RUN rm -rf \
6363
# https://docs.python.org/3/using/cmdline.html#envvar-PYTHONNODEBUGRANGES
6464
RUN PYTHONNODEBUGRANGES=1 python -OO -m compileall -b ./python/lib/$runtime/site-packages
6565
# remove all .py files
66-
# DEV: previously we kept patch.py files, but this is no longer necessary
67-
RUN find ./python/lib/$runtime/site-packages -name \*.py | xargs rm -rf
66+
# DEV: ddtrace>=4.7.0rc4 checks for .pyc files in addition to .py files for instrumentation
67+
# discovery (DataDog/dd-trace-py#17196), so we can safely remove all .py files.
68+
# For older versions, we need to keep patch.py files for instrumentation discovery.
69+
RUN if python -c "from packaging.version import Version; import ddtrace; exit(0 if Version(ddtrace.__version__) >= Version('4.7.0rc4') else 1)"; then \
70+
find ./python/lib/$runtime/site-packages -name \*.py | xargs rm -rf; \
71+
else \
72+
find ./python/lib/$runtime/site-packages -name \*.py | grep -v ddtrace/contrib | xargs rm -rf && \
73+
find ./python/lib/$runtime/site-packages/ddtrace/contrib -name \*.py | grep -v patch.py | xargs rm -rf; \
74+
fi
6875
RUN find ./python/lib/$runtime/site-packages -name __pycache__ -type d -exec rm -r {} \+
6976

7077
# When building ddtrace from branch, remove extra source files. These are

0 commit comments

Comments
 (0)