From 746ce90774fdeb9eeb054d1000d84999bff82fe2 Mon Sep 17 00:00:00 2001 From: Reiley Yang Date: Wed, 26 Jun 2019 08:55:28 -0700 Subject: [PATCH] Improve package layout (#26) Auto discover namespace packages. --- opentelemetry-api/opentelemetry/__init__.py | 1 - .../opentelemetry/context/__init__.py | 14 ++++++++++++- .../distributedcontext/__init__.py | 14 ++++++++++++- .../opentelemetry/internal/version.py | 2 +- .../opentelemetry/logs/__init__.py | 14 ++++++++++++- .../opentelemetry/metrics/__init__.py | 14 ++++++++++++- .../opentelemetry/resources/__init__.py | 14 ++++++++++++- opentelemetry-api/setup.py | 20 +++++++++++-------- 8 files changed, 78 insertions(+), 15 deletions(-) delete mode 100644 opentelemetry-api/opentelemetry/__init__.py diff --git a/opentelemetry-api/opentelemetry/__init__.py b/opentelemetry-api/opentelemetry/__init__.py deleted file mode 100644 index 8db66d3d0f..0000000000 --- a/opentelemetry-api/opentelemetry/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/opentelemetry-api/opentelemetry/context/__init__.py b/opentelemetry-api/opentelemetry/context/__init__.py index 8db66d3d0f..d853a7bcf6 100644 --- a/opentelemetry-api/opentelemetry/context/__init__.py +++ b/opentelemetry-api/opentelemetry/context/__init__.py @@ -1 +1,13 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +# Copyright 2019, 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. diff --git a/opentelemetry-api/opentelemetry/distributedcontext/__init__.py b/opentelemetry-api/opentelemetry/distributedcontext/__init__.py index 8db66d3d0f..d853a7bcf6 100644 --- a/opentelemetry-api/opentelemetry/distributedcontext/__init__.py +++ b/opentelemetry-api/opentelemetry/distributedcontext/__init__.py @@ -1 +1,13 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +# Copyright 2019, 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. diff --git a/opentelemetry-api/opentelemetry/internal/version.py b/opentelemetry-api/opentelemetry/internal/version.py index 34f10b31ef..a457c2b665 100644 --- a/opentelemetry-api/opentelemetry/internal/version.py +++ b/opentelemetry-api/opentelemetry/internal/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.1.0" +__version__ = "0.1.dev0" diff --git a/opentelemetry-api/opentelemetry/logs/__init__.py b/opentelemetry-api/opentelemetry/logs/__init__.py index 8db66d3d0f..d853a7bcf6 100644 --- a/opentelemetry-api/opentelemetry/logs/__init__.py +++ b/opentelemetry-api/opentelemetry/logs/__init__.py @@ -1 +1,13 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +# Copyright 2019, 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. diff --git a/opentelemetry-api/opentelemetry/metrics/__init__.py b/opentelemetry-api/opentelemetry/metrics/__init__.py index 8db66d3d0f..d853a7bcf6 100644 --- a/opentelemetry-api/opentelemetry/metrics/__init__.py +++ b/opentelemetry-api/opentelemetry/metrics/__init__.py @@ -1 +1,13 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +# Copyright 2019, 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. diff --git a/opentelemetry-api/opentelemetry/resources/__init__.py b/opentelemetry-api/opentelemetry/resources/__init__.py index 8db66d3d0f..d853a7bcf6 100644 --- a/opentelemetry-api/opentelemetry/resources/__init__.py +++ b/opentelemetry-api/opentelemetry/resources/__init__.py @@ -1 +1,13 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +# Copyright 2019, 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. diff --git a/opentelemetry-api/setup.py b/opentelemetry-api/setup.py index b03e118f0d..2e405905aa 100644 --- a/opentelemetry-api/setup.py +++ b/opentelemetry-api/setup.py @@ -12,13 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from setuptools import find_packages -from setuptools import setup -from opentelemetry.internal import __version__ +import os +import setuptools -setup( +base_dir = os.path.dirname(__file__) + +package_info = {} +with open(os.path.join(base_dir, "opentelemetry", "internal", "version.py")) as f: + exec(f.read(), package_info) + +setuptools.setup( name="opentelemetry-api", - version=__version__, # noqa + version=package_info["__version__"], # noqa author="OpenTelemetry Authors", author_email="cncf-opentelemetry-contributors@lists.cncf.io", classifiers=[ @@ -39,8 +44,7 @@ ], extras_require={}, license="Apache-2.0", - packages=find_packages(exclude=("examples", "tests",)), - namespace_packages=[], - url="https://github.com/open-telemetry/opentelemetry-python/opentelemetry-api", + packages=setuptools.find_namespace_packages(include=["opentelemetry.*"]), + url="https://github.com/open-telemetry/opentelemetry-python/tree/master/opentelemetry-api", zip_safe=False, )