From cb35cc40abdfe2558aa915c182b9ac89a15731c8 Mon Sep 17 00:00:00 2001 From: Owais Lone Date: Fri, 30 Apr 2021 05:46:41 +0530 Subject: [PATCH] Generate instrumentation packages setup.py files (#474) All instrumentations packages have almost exactly same setup.py files. This commit adds a python script that generates it from a source template. This dramatically reduces the time and effort required to update all instrumentation setup.py files, and also reduces chances of making manual mistakes. --- .../setup.py | 8 +- .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 26 +++---- .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.cfg | 4 + .../setup.py | 15 ++-- .../setup.py | 5 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 7 +- .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.py | 6 ++ .../setup.cfg | 4 + .../setup.py | 15 ++-- .../setup.py | 13 ++-- .../setup.py | 6 ++ .../setup.py | 6 ++ scripts/generate_setup.py | 77 +++++++++++++++++++ templates/instrumentation_setup.py.txt | 36 +++++++++ 36 files changed, 323 insertions(+), 37 deletions(-) create mode 100644 scripts/generate_setup.py create mode 100644 templates/instrumentation_setup.py.txt diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.py index fe74e23235..f43f103d27 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/setup.py @@ -1,4 +1,4 @@ -# Copyright 2020, OpenTelemetry Authors +# Copyright The OpenTelemetry Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/setup.py b/instrumentation/opentelemetry-instrumentation-aiopg/setup.py index dfd463e5ab..882d311bbd 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/setup.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-asgi/setup.py b/instrumentation/opentelemetry-instrumentation-asgi/setup.py index 3369352fe1..baef565156 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/setup.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/setup.py b/instrumentation/opentelemetry-instrumentation-asyncpg/setup.py index 2ad47ac9d9..73ea9171ed 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/setup.py +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-boto/setup.py b/instrumentation/opentelemetry-instrumentation-boto/setup.py index 2bd68894f3..fd58c052d0 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/setup.py +++ b/instrumentation/opentelemetry-instrumentation-boto/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-botocore/setup.py b/instrumentation/opentelemetry-instrumentation-botocore/setup.py index fd5045efaa..ae361301ee 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/setup.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-celery/setup.py b/instrumentation/opentelemetry-instrumentation-celery/setup.py index ca67930660..4c86fe4d16 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/setup.py +++ b/instrumentation/opentelemetry-instrumentation-celery/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/setup.py b/instrumentation/opentelemetry-instrumentation-dbapi/setup.py index cfe98f3895..9c0a175c57 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/setup.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-django/setup.py b/instrumentation/opentelemetry-instrumentation-django/setup.py index fb9d615ce3..71984838d4 100644 --- a/instrumentation/opentelemetry-instrumentation-django/setup.py +++ b/instrumentation/opentelemetry-instrumentation-django/setup.py @@ -12,21 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os.path import dirname, join -from setuptools import setup +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + +import os + +import setuptools + +BASE_DIR = os.path.dirname(__file__) +VERSION_FILENAME = os.path.join( + BASE_DIR, "src", "opentelemetry", "instrumentation", "django", "version.py" +) PACKAGE_INFO = {} -with open( - join( - dirname(__file__), - "src", - "opentelemetry", - "instrumentation", - "django", - "version.py", - ) -) as f: +with open(VERSION_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setup(version=PACKAGE_INFO["__version__"]) +setuptools.setup(version=PACKAGE_INFO["__version__"]) diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.py index cd7a7f1012..90e3144fbe 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-falcon/setup.py b/instrumentation/opentelemetry-instrumentation-falcon/setup.py index eb61edde62..5be5b53de7 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/setup.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/setup.py b/instrumentation/opentelemetry-instrumentation-fastapi/setup.py index 13c7c5a99c..fbeb3bcc37 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/setup.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-flask/setup.cfg b/instrumentation/opentelemetry-instrumentation-flask/setup.cfg index 93f88db738..6b6fe2bd69 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-flask/setup.cfg @@ -50,5 +50,9 @@ test = flask~=1.0 opentelemetry-test == 0.21.dev0 +[options.entry_points] +opentelemetry_instrumentor = + flask = opentelemetry.instrumentation.flask:FlaskInstrumentor + [options.packages.find] where = src diff --git a/instrumentation/opentelemetry-instrumentation-flask/setup.py b/instrumentation/opentelemetry-instrumentation-flask/setup.py index 587b697a7b..6aa448f33e 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/setup.py +++ b/instrumentation/opentelemetry-instrumentation-flask/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools @@ -23,11 +29,4 @@ with open(VERSION_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup( - version=PACKAGE_INFO["__version__"], - entry_points={ - "opentelemetry_instrumentor": [ - "flask = opentelemetry.instrumentation.flask:FlaskInstrumentor" - ] - }, -) +setuptools.setup(version=PACKAGE_INFO["__version__"]) diff --git a/instrumentation/opentelemetry-instrumentation-grpc/setup.py b/instrumentation/opentelemetry-instrumentation-grpc/setup.py index 87c720aea2..4002e4ac1b 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/setup.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/setup.py @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/setup.py b/instrumentation/opentelemetry-instrumentation-jinja2/setup.py index e9d484e1eb..34d5af44e0 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/setup.py +++ b/instrumentation/opentelemetry-instrumentation-jinja2/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-logging/setup.py b/instrumentation/opentelemetry-instrumentation-logging/setup.py index 3bebc496ef..7521827f27 100644 --- a/instrumentation/opentelemetry-instrumentation-logging/setup.py +++ b/instrumentation/opentelemetry-instrumentation-logging/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-mysql/setup.py b/instrumentation/opentelemetry-instrumentation-mysql/setup.py index 955f75d71e..f133f24b42 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/setup.py +++ b/instrumentation/opentelemetry-instrumentation-mysql/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/setup.py b/instrumentation/opentelemetry-instrumentation-psycopg2/setup.py index 4bd0e16be5..c2cf7dbb62 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/setup.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/setup.py b/instrumentation/opentelemetry-instrumentation-pymemcache/setup.py index 46bf607933..d1b5d39fb1 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/setup.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/setup.py @@ -11,7 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/setup.py b/instrumentation/opentelemetry-instrumentation-pymongo/setup.py index 7b862ae2aa..aed252425c 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/setup.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/setup.py b/instrumentation/opentelemetry-instrumentation-pymysql/setup.py index 74cd948fee..9b739bc4a3 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/setup.py +++ b/instrumentation/opentelemetry-instrumentation-pymysql/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/setup.py b/instrumentation/opentelemetry-instrumentation-pyramid/setup.py index 7141a89813..ba4a44f1fb 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/setup.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-redis/setup.py b/instrumentation/opentelemetry-instrumentation-redis/setup.py index df80a8fd1a..f8cb327d35 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/setup.py +++ b/instrumentation/opentelemetry-instrumentation-redis/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-requests/setup.py b/instrumentation/opentelemetry-instrumentation-requests/setup.py index 237fef583b..8cecfc9f9f 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/setup.py +++ b/instrumentation/opentelemetry-instrumentation-requests/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-sklearn/setup.py b/instrumentation/opentelemetry-instrumentation-sklearn/setup.py index 92f53925e0..c3ac3f30c0 100644 --- a/instrumentation/opentelemetry-instrumentation-sklearn/setup.py +++ b/instrumentation/opentelemetry-instrumentation-sklearn/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.py index 26d3ef4fc9..943a8347f9 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/setup.py b/instrumentation/opentelemetry-instrumentation-sqlite3/setup.py index 67ce350fab..177a75a639 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/setup.py +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-starlette/setup.py b/instrumentation/opentelemetry-instrumentation-starlette/setup.py index 0232a6f448..97895bb975 100644 --- a/instrumentation/opentelemetry-instrumentation-starlette/setup.py +++ b/instrumentation/opentelemetry-instrumentation-starlette/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-tornado/setup.cfg b/instrumentation/opentelemetry-instrumentation-tornado/setup.cfg index 071eabdb10..217aa6cf7c 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/setup.cfg +++ b/instrumentation/opentelemetry-instrumentation-tornado/setup.cfg @@ -48,5 +48,9 @@ test = tornado >= 6.0 opentelemetry-test == 0.21.dev0 +[options.entry_points] +opentelemetry_instrumentor = + tornado = opentelemetry.instrumentation.tornado:TornadoInstrumentor + [options.packages.find] where = src diff --git a/instrumentation/opentelemetry-instrumentation-tornado/setup.py b/instrumentation/opentelemetry-instrumentation-tornado/setup.py index bd6814b50e..6cbbe447f3 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/setup.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools @@ -28,11 +34,4 @@ with open(VERSION_FILENAME) as f: exec(f.read(), PACKAGE_INFO) -setuptools.setup( - version=PACKAGE_INFO["__version__"], - entry_points={ - "opentelemetry_instrumentor": [ - "tornado = opentelemetry.instrumentation.tornado:TornadoInstrumentor" - ] - }, -) +setuptools.setup(version=PACKAGE_INFO["__version__"]) diff --git a/instrumentation/opentelemetry-instrumentation-urllib/setup.py b/instrumentation/opentelemetry-instrumentation-urllib/setup.py index 33c068c69a..7fb18f1340 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/setup.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/setup.py @@ -11,18 +11,19 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools BASE_DIR = os.path.dirname(__file__) VERSION_FILENAME = os.path.join( - BASE_DIR, - "src", - "opentelemetry", - "instrumentation", - "urllib", - "version.py", + BASE_DIR, "src", "opentelemetry", "instrumentation", "urllib", "version.py" ) PACKAGE_INFO = {} with open(VERSION_FILENAME) as f: diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/setup.py b/instrumentation/opentelemetry-instrumentation-urllib3/setup.py index fe391cb46e..d0bc82257c 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/setup.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/setup.py b/instrumentation/opentelemetry-instrumentation-wsgi/setup.py index fb4ffa7437..ac2077cbe0 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/setup.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/setup.py @@ -11,6 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. +# RUN `python scripts/generate_setup.py` TO REGENERATE. + + import os import setuptools diff --git a/scripts/generate_setup.py b/scripts/generate_setup.py new file mode 100644 index 0000000000..8890fac67d --- /dev/null +++ b/scripts/generate_setup.py @@ -0,0 +1,77 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import os +import subprocess + +from jinja2 import Template + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger("setupy_generator") + +_auto_generation_msg = """ +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/{source}. +# RUN `python scripts/generate_setup.py` TO REGENERATE. +""" +_template_dir = "templates" +_template_name = "instrumentation_setup.py.txt" +_prefix = "opentelemetry-instrumentation-" + + +def main(): + root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + setuppy_tmpl = Template( + open( + os.path.join(root_path, _template_dir, _template_name), "r" + ).read() + ) + base_instrumentation_path = os.path.join(root_path, "instrumentation") + + for instrumentation in os.listdir(base_instrumentation_path): + instrumentation_path = os.path.join( + base_instrumentation_path, instrumentation + ) + if not os.path.isdir( + instrumentation_path + ) or not instrumentation.startswith(_prefix): + continue + + src_dir = os.path.join( + instrumentation_path, "src", "opentelemetry", "instrumentation" + ) + src_pkgs = [ + f + for f in os.listdir(src_dir) + if os.path.isdir(os.path.join(src_dir, f)) + ] + assert len(src_pkgs) == 1 + name = src_pkgs[0] + generated = setuppy_tmpl.render( + name=name, + auto_generation_msg=_auto_generation_msg.format( + source=_template_name + ), + ) + + generated_file = os.path.join(instrumentation_path, "setup.py") + logger.info("generated %s", generated_file) + with open(generated_file, "w") as fh: + fh.write(generated) + fh.flush() + subprocess.run(["black", "-q", generated_file], check=True) + + +if __name__ == "__main__": + main() diff --git a/templates/instrumentation_setup.py.txt b/templates/instrumentation_setup.py.txt new file mode 100644 index 0000000000..b619c49b56 --- /dev/null +++ b/templates/instrumentation_setup.py.txt @@ -0,0 +1,36 @@ + + +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{{ auto_generation_msg }} + +import os + +import setuptools + +BASE_DIR = os.path.dirname(__file__) +VERSION_FILENAME = os.path.join( + BASE_DIR, + "src", + "opentelemetry", + "instrumentation", + "{{ name }}", + "version.py" +) +PACKAGE_INFO = {} +with open(VERSION_FILENAME) as f: + exec(f.read(), PACKAGE_INFO) + +setuptools.setup(version=PACKAGE_INFO["__version__"]) \ No newline at end of file