Skip to content
Open
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
51 changes: 28 additions & 23 deletions docs/guides/extension_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The basic bare-bone structure of an extension is as follows:
│ ├── __init__.py
│ └── __main__.py
├── secrets.json
└── setup.py
└── pyproject.toml

This structure can be generated by running the :doc:`/cli/create` command
``dt-sdk create my_extension``.
Expand Down Expand Up @@ -243,37 +243,42 @@ This file is by default in ``.gitignore``.
}


Setup.py
--------
pyproject.toml
--------------

``setup.py``
``pyproject.toml``

This is a standard Python setup file that is used to package the extension and
This is a modern Python configuration file that is used to package the extension and
is used by the extension execution controller to install the extension on the
ActiveGate or OneAgent along with the required dependencies.

.. code:: python
.. code:: toml

from setuptools import setup, find_packages
[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"

setup(
name="my_extension",
version="0.0.1",
description="My_extension python EF2 extension",
author="Dynatrace",
packages=find_packages(),
python_requires=">=3.10",
include_package_data=True,
install_requires=["dt-extensions-sdk"],
extras_require={"dev": ["dt-extensions-sdk[cli]"]},
)
[project]
name = "my_extension"
version = "0.0.1"
description = "My_extension python EF2 extension"
authors = [
{name = "Dynatrace"}
]
requires-python = ">=3.10"
dependencies = [
"dt-extensions-sdk"
]

[project.optional-dependencies]
dev = ["dt-extensions-sdk[cli]"]

.. admonition:: Dependencies
:class: important
:class: important

The ``pyproject.toml`` file is the place where any dependencies must be specified
in the ``dependencies`` section.

The ``setup.py`` file is the place where any dependencies must be specified
in the ``install_requires`` section.

The ``dt-extensions-sdk`` package must always be specified as a dependency. However,
theoretically, it is possible to write a Python code that will be capable of
communication with the extension execution controller without using the SDK.
Expand All @@ -285,7 +290,7 @@ ActiveGate or OneAgent along with the required dependencies.
:class: important

When bumping the version of the extension in the ``extension.yaml``,
the ``setup.py`` file must be updated as well. The two versions must match.
the ``pyproject.toml`` file must be updated as well. The two versions must match.

.. admonition:: Extension size
:class: danger
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ structure:
│ ├── __init__.py
│ └── __main__.py
├── secrets.json
└── setup.py
└── pyproject.toml

.. admonition:: What do these files mean?
:class: seealso
Expand Down
2 changes: 1 addition & 1 deletion dynatrace_extension/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# SPDX-License-Identifier: MIT


__version__ = "1.7.2"
__version__ = "1.8.0"
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Contains the python code for the extension

Contains the yaml and activation definitions for the framework v2 extension

### setup.py
### pyproject.toml

Contains dependency and other python metadata
Contains dependency and other python metadata in modern TOML format

### activation.json

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
[build-system]
requires = ["setuptools>=80", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "%extension_name%"
version = "0.0.1"
description = "%Extension_Name% python EF2 extension"
authors = [
{name = "Dynatrace"}
]
requires-python = ">=3.10"
dependencies = [
"dt-extensions-sdk"
]

[project.optional-dependencies]
dev = ["dt-extensions-sdk[cli]"]

[tool.setuptools.packages.find]
include = ["%extension_name%*"]

[tool.setuptools.package-data]
"*" = ["*"]

[tool.ruff]
exclude = [
".bzr",
".direnv",
Expand Down Expand Up @@ -42,7 +68,7 @@ indent-width = 4
# Assume Python 3.10
target-version = "py310"

[lint]
[tool.ruff.lint]
select = ["E", "F", "W", "C90", "I", "N", "UP", "B", "A", "FA", "T20", "Q", "RET", "SIM", "ARG", "PTH", "C"]
ignore = [
"T201", # we allow print because these are logged into the extension logs
Expand All @@ -56,11 +82,11 @@ unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.mccabe]
[tool.ruff.lint.mccabe]
# Flag errors (`C901`) whenever the complexity level exceeds 20.
max-complexity = 20

[format]
[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

Expand All @@ -74,4 +100,4 @@ skip-magic-trailing-comma = false
line-ending = "auto"

docstring-code-format = false
docstring-code-line-length = "dynamic"
docstring-code-line-length = "dynamic"

This file was deleted.

2 changes: 1 addition & 1 deletion tests/cli/test_dt_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_dt_sdk_workflow(self):

# Check that the extension files exist
self.assertTrue((self.temp_dir / "test_extension" / "test_extension" / "__main__.py").exists())
self.assertTrue((self.temp_dir / "test_extension" / "setup.py").exists())
self.assertTrue((self.temp_dir / "test_extension" / "pyproject.toml").exists())
self.assertTrue((self.temp_dir / "test_extension" / "activation.json").exists())
self.assertTrue((self.temp_dir / "test_extension" / "extension" / "extension.yaml").exists())

Expand Down
Loading