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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
_version.py
version.txt

# PyInstaller
Expand Down
15 changes: 6 additions & 9 deletions newrelic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pathlib import Path

VERSION_FILE = Path(__file__).parent / "version.txt"

try:
with VERSION_FILE.open() as f:
version = f.read()
except Exception:
version = "0.0.0"
from newrelic._version import __version__, __version_tuple__, version, version_tuple
except ImportError: # pragma: no cover
__version__ = version = "0.0.0" # pragma: no cover
__version_tuple__ = version_tuple = (0, 0, 0) # pragma: no cover

version_info = list(map(int, version.split(".")))
# Older compatibility attribute
version_info = version_tuple
148 changes: 93 additions & 55 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,96 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# ===========================
# Project Build Configuration
# ===========================

[project]
name="newrelic"
description = "New Relic Python Agent"
authors = [{name = "New Relic", email = "[email protected]"}]
maintainers = [{name = "New Relic", email = "[email protected]"}]
readme = "README.md"
# License requires setuptools>=77.0.3 for pyproject.toml, which is Python 3.9+
# license = "Apache-2.0"
# license-files = [
# "LICENSE",
# "THIRD_PARTY_NOTICES.md",
# ]
requires-python = ">=3.7"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: System :: Monitoring",
]
dynamic = ["version", "license"]

[project.urls]
Homepage = "https://docs.newrelic.com/docs/apm/agents/python-agent/"
GitHub = "https://github.com/newrelic/newrelic-python-agent"
"Release Notes" = "https://docs.newrelic.com/docs/release-notes/agent-release-notes/python-release-notes/"

[project.optional-dependencies]
infinite-tracing = ["grpcio", "protobuf"]

[project.scripts]
newrelic-admin = "newrelic.admin:main"

[build-system]
requires = [
"setuptools>=61.2",
"setuptools_scm>=6.4,<10",
]
build-backend = "setuptools.build_meta"

[tool.setuptools]
zip-safe = false
packages = [
"newrelic",
"newrelic.admin",
"newrelic.api",
"newrelic.bootstrap",
"newrelic.common",
"newrelic.core",
"newrelic.extras",
"newrelic.extras.framework_django",
"newrelic.extras.framework_django.templatetags",
"newrelic.hooks",
"newrelic.network",
"newrelic.packages",
"newrelic.packages.isort",
"newrelic.packages.isort.stdlibs",
"newrelic.packages.urllib3",
"newrelic.packages.urllib3.util",
"newrelic.packages.urllib3.contrib",
"newrelic.packages.urllib3.contrib._securetransport",
"newrelic.packages.urllib3.packages",
"newrelic.packages.urllib3.packages.backports",
"newrelic.packages.wrapt",
"newrelic.packages.opentelemetry_proto",
"newrelic.samplers",
]

[tool.setuptools.package-data]
newrelic = ["newrelic.ini", "version.txt", "packages/urllib3/LICENSE.txt", "common/cacert.pem", "scripts/azure-prebuild.sh"]

[tool.setuptools_scm]
write_to = "newrelic/_version.py"
# Don't convert git_describe_command to an array, it doesn't seem to work properly on any versions of setuptools_scm.
git_describe_command = 'git describe --dirty --tags --long --match "*.*.*"'

# ==================
# Ruff Configuration
# ==================

[tool.ruff]
output-format = "grouped"
line-length = 120
Expand Down Expand Up @@ -159,61 +249,9 @@ ignore = [
"S108", # flake8-bandit (hardcoded log files are never used as input)
]

# Alternate linters and formatters
[tool.black]
line-length = 120
include = '\.pyi?$'

[tool.isort]
profile = "black"

[tool.pylint.messages_control]
disable = [
"C0103",
"C0114",
"C0115",
"C0116",
"C0209",
"C0302",
"C0415",
"E0401",
"E1120",
"R0205",
"R0401",
"R0801",
"R0902",
"R0903",
"R0904",
"R0911",
"R0912",
"R0913",
"R0914",
"R0915",
"R1705",
"R1710",
"R1725",
"W0201",
"W0212",
"W0223",
"W0402",
"W0603",
"W0612",
"W0613",
"W0702",
"W0703",
"W0706",
"line-too-long",
"redefined-outer-name",
]

[tool.pylint.format]
max-line-length = "120"

[tool.pylint.basic]
good-names = "exc,val,tb"

[tool.bandit]
skips = ["B110", "B101", "B404"]
# =========================
# Other Tools Configuration
# =========================

[tool.flynt]
line-length = 999999
Expand Down
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

148 changes: 49 additions & 99 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,7 @@
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError


def newrelic_agent_guess_next_version(tag_version):
if hasattr(tag_version, "tag"): # For setuptools_scm 7.0+
tag_version = tag_version.tag

version, _, _ = str(tag_version).partition("+")
version_info = list(map(int, version.split(".")))
if len(version_info) < 3:
return version
version_info[1] += 1
version_info[2] = 0
return ".".join(map(str, version_info))


def newrelic_agent_next_version(version):
if version.exact:
return version.format_with("{tag}")
else:
return version.format_next_version(newrelic_agent_guess_next_version, fmt="{guessed}")


script_directory = Path(__file__).parent

readme_file = script_directory / "README.md"
with readme_file.open() as f:
readme_file_contents = f.read()

if sys.platform == "win32" and python_version > (2, 6):
if sys.platform == "win32":
build_ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, IOError)
else:
build_ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
Expand All @@ -113,83 +87,59 @@ def build_extension(self, ext):
raise BuildExtFailed()


packages = [
"newrelic",
"newrelic.admin",
"newrelic.api",
"newrelic.bootstrap",
"newrelic.common",
"newrelic.core",
"newrelic.extras",
"newrelic.extras.framework_django",
"newrelic.extras.framework_django.templatetags",
"newrelic.hooks",
"newrelic.network",
"newrelic/packages",
"newrelic/packages/isort",
"newrelic/packages/isort/stdlibs",
"newrelic/packages/urllib3",
"newrelic/packages/urllib3/util",
"newrelic/packages/urllib3/contrib",
"newrelic/packages/urllib3/contrib/_securetransport",
"newrelic/packages/urllib3/packages",
"newrelic/packages/urllib3/packages/backports",
"newrelic/packages/wrapt",
"newrelic/packages/opentelemetry_proto",
"newrelic.samplers",
]

classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: System :: Monitoring",
]

kwargs = dict(
name="newrelic",
use_scm_version={
"version_scheme": newrelic_agent_next_version,
"local_scheme": "no-local-version",
"git_describe_command": "git describe --dirty --tags --long --match *.*.*",
"write_to": "newrelic/version.txt",
},
setup_requires=["setuptools_scm>=3.2,<9"],
description="New Relic Python Agent",
long_description=readme_file_contents,
long_description_content_type="text/markdown",
url="https://docs.newrelic.com/docs/apm/agents/python-agent/",
project_urls={"Source": "https://github.com/newrelic/newrelic-python-agent"},
author="New Relic",
author_email="[email protected]",
maintainer="New Relic",
maintainer_email="[email protected]",
setup_requires=["setuptools>=61.2", "setuptools_scm>=6.4,<10"],
license="Apache-2.0",
zip_safe=False,
classifiers=classifiers,
packages=packages,
python_requires=">=3.7",
package_data={
"newrelic": ["newrelic.ini", "version.txt", "packages/urllib3/LICENSE.txt", "common/cacert.pem", "scripts/azure-prebuild.sh"],
},
extras_require={"infinite-tracing": ["grpcio", "protobuf"]},
)

if with_setuptools:
kwargs["entry_points"] = {
"console_scripts": ["newrelic-admin = newrelic.admin:main"],
}
else:
if not with_setuptools:
script_directory = os.path.dirname(__file__)
if not script_directory:
script_directory = os.getcwd()

readme_file = os.path.join(script_directory, "README.md")

kwargs["scripts"] = ["scripts/newrelic-admin"]

# Old config that now lives in pyproject.toml
# Preserved here for backwards compatibility with distutils
packages = [
"newrelic",
"newrelic.admin",
"newrelic.api",
"newrelic.bootstrap",
"newrelic.common",
"newrelic.core",
"newrelic.extras",
"newrelic.extras.framework_django",
"newrelic.extras.framework_django.templatetags",
"newrelic.hooks",
"newrelic.network",
"newrelic.packages",
"newrelic.packages.isort",
"newrelic.packages.isort.stdlibs",
"newrelic.packages.urllib3",
"newrelic.packages.urllib3.util",
"newrelic.packages.urllib3.contrib",
"newrelic.packages.urllib3.contrib._securetransport",
"newrelic.packages.urllib3.packages",
"newrelic.packages.urllib3.packages.backports",
"newrelic.packages.wrapt",
"newrelic.packages.opentelemetry_proto",
"newrelic.samplers",
]

kwargs.update(dict(
python_requires=">=3.7",
zip_safe=False,
packages=packages,
package_data={
"newrelic": ["newrelic.ini", "version.txt", "packages/urllib3/LICENSE.txt", "common/cacert.pem", "scripts/azure-prebuild.sh"],
},
))



def with_librt():
try:
Expand Down Expand Up @@ -253,9 +203,9 @@ def _run_setup():

with_extensions = os.environ.get("NEW_RELIC_EXTENSIONS", None)
if with_extensions:
if with_extensions.lower() == "true":
if with_extensions.lower() in ["on", "true", "1"]:
with_extensions = True
elif with_extensions.lower() == "false":
elif with_extensions.lower() in ["off", "false", "0"]:
with_extensions = False
else:
with_extensions = None
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ usefixtures =
branch = True
disable_warnings = couldnt-parse
source = newrelic
omit =
**/_version.py

[coverage:paths]
source =
Expand Down