|
| 1 | +# Copyright The OpenTelemetry Authors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +# DO NOT EDIT. THIS FILE WAS AUTOGENERATED FROM templates/instrumentation_setup.py.txt. |
| 17 | +# RUN `python scripts/generate_setup.py` TO REGENERATE. |
| 18 | + |
| 19 | + |
| 20 | +import distutils.cmd |
| 21 | +import json |
| 22 | +import os |
| 23 | +from configparser import ConfigParser |
| 24 | + |
| 25 | +import setuptools |
| 26 | + |
| 27 | +config = ConfigParser() |
| 28 | +config.read("setup.cfg") |
| 29 | + |
| 30 | +# We provide extras_require parameter to setuptools.setup later which |
| 31 | +# overwrites the extras_require section from setup.cfg. To support extras_require |
| 32 | +# section in setup.cfg, we load it here and merge it with the extras_require param. |
| 33 | +extras_require = {} |
| 34 | +if "options.extras_require" in config: |
| 35 | + for key, value in config["options.extras_require"].items(): |
| 36 | + extras_require[key] = [v for v in value.split("\n") if v.strip()] |
| 37 | + |
| 38 | +BASE_DIR = os.path.dirname(__file__) |
| 39 | +PACKAGE_INFO = {} |
| 40 | + |
| 41 | +VERSION_FILENAME = os.path.join( |
| 42 | + BASE_DIR, |
| 43 | + "src", |
| 44 | + "opentelemetry", |
| 45 | + "instrumentation", |
| 46 | + "confluent_kafka", |
| 47 | + "version.py", |
| 48 | +) |
| 49 | +with open(VERSION_FILENAME, encoding="utf-8") as f: |
| 50 | + exec(f.read(), PACKAGE_INFO) |
| 51 | + |
| 52 | +PACKAGE_FILENAME = os.path.join( |
| 53 | + BASE_DIR, |
| 54 | + "src", |
| 55 | + "opentelemetry", |
| 56 | + "instrumentation", |
| 57 | + "confluent_kafka", |
| 58 | + "package.py", |
| 59 | +) |
| 60 | +with open(PACKAGE_FILENAME, encoding="utf-8") as f: |
| 61 | + exec(f.read(), PACKAGE_INFO) |
| 62 | + |
| 63 | +# Mark any instruments/runtime dependencies as test dependencies as well. |
| 64 | +extras_require["instruments"] = PACKAGE_INFO["_instruments"] |
| 65 | +test_deps = extras_require.get("test", []) |
| 66 | +for dep in extras_require["instruments"]: |
| 67 | + test_deps.append(dep) |
| 68 | + |
| 69 | +extras_require["test"] = test_deps |
| 70 | + |
| 71 | + |
| 72 | +class JSONMetadataCommand(distutils.cmd.Command): |
| 73 | + |
| 74 | + description = ( |
| 75 | + "print out package metadata as JSON. This is used by OpenTelemetry dev scripts to ", |
| 76 | + "auto-generate code in other places", |
| 77 | + ) |
| 78 | + user_options = [] |
| 79 | + |
| 80 | + def initialize_options(self): |
| 81 | + pass |
| 82 | + |
| 83 | + def finalize_options(self): |
| 84 | + pass |
| 85 | + |
| 86 | + def run(self): |
| 87 | + metadata = { |
| 88 | + "name": config["metadata"]["name"], |
| 89 | + "version": PACKAGE_INFO["__version__"], |
| 90 | + "instruments": PACKAGE_INFO["_instruments"], |
| 91 | + } |
| 92 | + print(json.dumps(metadata)) |
| 93 | + |
| 94 | + |
| 95 | +setuptools.setup( |
| 96 | + cmdclass={"meta": JSONMetadataCommand}, |
| 97 | + version=PACKAGE_INFO["__version__"], |
| 98 | + extras_require=extras_require, |
| 99 | +) |
0 commit comments