Skip to content

Hardcode version to avoid import of importlib.metadata. #472

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 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions datadog_lambda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@

# The minor version corresponds to the Lambda layer version.
# E.g.,, version 0.5.0 gets packaged into layer version 5.
try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
import importlib_metadata

__version__ = importlib_metadata.version(__name__)


from datadog_lambda.version import __version__ # noqa: E402 F401
from datadog_lambda.logger import initialize_logging # noqa: E402


Expand Down
1 change: 1 addition & 0 deletions datadog_lambda/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "5.92.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Now we have to update this every time we do a release, could we add this to the internal docs?

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ urllib3 = [
{version = "<2.0.0", python = "<3.11", optional = true},
{version = "<2.1.0", python = ">=3.11", optional = true},
]
importlib_metadata = {version = "*", python = "<3.8"}
boto3 = { version = "^1.28.0", optional = true }
typing_extensions = {version = "^4.0", python = "<3.8"}
requests = { version ="^2.22.0", optional = true }
pytest = { version= "^8.0.0", optional = true }
pytest-benchmark = { version = "^4.0", optional = true }
Expand Down
5 changes: 3 additions & 2 deletions scripts/publish_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ if [ "$CONT" != "y" ]; then
echo "Skipping updating package.json version"
else
echo
echo "Replacing version in pyproject.toml"
echo "Replacing version in pyproject.toml and datadog_lambda/version.py"
echo

poetry version ${NEW_VERSION}
echo "__version__ = \"${NEW_VERSION}\"" > datadog_lambda/version.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, nvm, well done here!

Thanks for automating it.

fi

echo
Expand Down Expand Up @@ -110,7 +111,7 @@ if [ "$CONT" != "y" ]; then
else
echo
echo 'Publishing updates to github'
git commit pyproject.toml -m "Bump version to ${NEW_VERSION}"
git commit pyproject.toml datadog_lambda/version.py -m "Bump version to ${NEW_VERSION}"
git push origin main
git tag "v$LAYER_VERSION"
git push origin "refs/tags/v$LAYER_VERSION"
Expand Down
7 changes: 7 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import importlib.metadata
from datadog_lambda import __version__


def test_version():
# test version in __init__ matches version in pyproject.toml
assert importlib.metadata.version("datadog-lambda") == __version__
1 change: 1 addition & 0 deletions tests/test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def lambda_handler(event, context):
lambda_context = get_mock_context()
test_span = tracer.trace("test_span")
trace_ctx = tracer.current_trace_context()
trace_ctx.sampling_priority = 1
test_span.finish()
lambda_handler.inferred_span = test_span
lambda_handler.make_inferred_span = False
Expand Down
Loading