Skip to content

feat: Strip setuptools #322

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

Merged
merged 1 commit into from
Apr 27, 2023
Merged

feat: Strip setuptools #322

merged 1 commit into from
Apr 27, 2023

Conversation

astuyve
Copy link
Contributor

@astuyve astuyve commented Apr 12, 2023

What does this PR do?

setuptools contains binaries for every major architecture, but it's already included in the lambda runtime, so we don't need it.

I found this by pulling the python base images and running an interpreter, finding that setuptools is resolved just fine:

✗ docker run -it --entrypoint sh  public.ecr.aws/lambda/python:3.10
sh-4.2# python
Python 3.10.9 (main, Mar 31 2023, 16:38:53) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>>import os.path
>>>import setuptools

>>> print(os.path.abspath(setuptools.__file__))
/var/lang/lib/python3.10/site-packages/setuptools/__init__.py
>>>

TODO - need to verify that the provided version doesn't conflict with our own, need to verify that dd-trace-py source code integration still works with this stripped. But integration tests pass and that's a very good sign.

Should save us 3mb.

Motivation

Testing Guidelines

Additional Notes

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@astuyve astuyve requested a review from a team as a code owner April 12, 2023 17:30
Copy link
Contributor

@duncanista duncanista left a comment

Choose a reason for hiding this comment

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

LGTM

@joeyzhao2018
Copy link
Contributor

Integration tests done:

  • Published the layers to sandbox us-east-1 version3 and used by self-monitoring apps for 12 hours +
  • Also use those layers and ran test lambda functions for following code:
    from ddtrace.vendor.psutil import _psutil_linux
    print(dir(_psutil_linux))
    from ddtrace.vendor.wrapt import _wrappers
    print(dir(_wrappers))
    import ddtrace.sourcecode.setuptools_auto
    import setuptools
    print(setuptools.__spec__) # this will have origin='/var/lang/lib/python3.<X>/site-packages/setuptools/__init__.py'
    print(setuptools.find_packages(where='mypkg', include=['pkg*'],))

this proves that 1. already installed extension modules in ddtrace still work even we removed the setuptools that we used to install ddtrace. 2. when user importing setuptools, it's using the runtime's setuptools anyway.

Based on those testings, this PR is safe to merge

@joeyzhao2018 joeyzhao2018 merged commit 309559b into main Apr 27, 2023
@joeyzhao2018 joeyzhao2018 deleted the aj/strip-sitetools branch April 27, 2023 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants