diff --git a/setup.py b/setup.py index 10dfee0d..027e3e27 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,6 @@ keywords="functions-framework", packages=find_packages(where="src"), package_data={"functions_framework": ["py.typed"]}, - namespace_packages=["google", "google.cloud"], package_dir={"": "src"}, python_requires=">=3.5, <4", install_requires=[ diff --git a/src/functions_framework/__init__.py b/src/functions_framework/__init__.py index 31169f4c..73179a7d 100644 --- a/src/functions_framework/__init__.py +++ b/src/functions_framework/__init__.py @@ -41,12 +41,12 @@ execution_id, ) from functions_framework.background_event import BackgroundEvent +from functions_framework.context import Context from functions_framework.exceptions import ( EventConversionException, FunctionsFrameworkException, MissingSourceException, ) -from google.cloud.functions.context import Context _FUNCTION_STATUS_HEADER_FIELD = "X-Google-Status" _CRASH = "crash" diff --git a/src/google/cloud/functions_v1/context.py b/src/functions_framework/context.py similarity index 100% rename from src/google/cloud/functions_v1/context.py rename to src/functions_framework/context.py diff --git a/src/functions_framework/event_conversion.py b/src/functions_framework/event_conversion.py index 0e67cdaa..7662e348 100644 --- a/src/functions_framework/event_conversion.py +++ b/src/functions_framework/event_conversion.py @@ -20,8 +20,8 @@ from cloudevents.http import CloudEvent, from_http, is_binary from functions_framework.background_event import BackgroundEvent +from functions_framework.context import Context from functions_framework.exceptions import EventConversionException -from google.cloud.functions.context import Context _CLOUD_EVENT_SPEC_VERSION = "1.0" diff --git a/src/google/__init__.py b/src/google/__init__.py deleted file mode 100644 index 72a55585..00000000 --- a/src/google/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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. - -try: - import pkg_resources - - pkg_resources.declare_namespace(__name__) -except ImportError: - import pkgutil - - __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/src/google/cloud/__init__.py b/src/google/cloud/__init__.py deleted file mode 100644 index 72a55585..00000000 --- a/src/google/cloud/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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. - -try: - import pkg_resources - - pkg_resources.declare_namespace(__name__) -except ImportError: - import pkgutil - - __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/src/google/cloud/functions/__init__.py b/src/google/cloud/functions/__init__.py deleted file mode 100644 index 6913f02e..00000000 --- a/src/google/cloud/functions/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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/src/google/cloud/functions/context.py b/src/google/cloud/functions/context.py deleted file mode 100644 index 665d8b29..00000000 --- a/src/google/cloud/functions/context.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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. - -"""Definition of types used by Cloud Functions in Python..""" - -from google.cloud.functions_v1.context import Context - -__all__ = ["Context"] diff --git a/src/google/cloud/functions_v1/__init__.py b/src/google/cloud/functions_v1/__init__.py deleted file mode 100644 index 6913f02e..00000000 --- a/src/google/cloud/functions_v1/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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/src/google/cloud/functions_v1beta2/__init__.py b/src/google/cloud/functions_v1beta2/__init__.py deleted file mode 100644 index 6913f02e..00000000 --- a/src/google/cloud/functions_v1beta2/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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/src/google/cloud/functions_v1beta2/context.py b/src/google/cloud/functions_v1beta2/context.py deleted file mode 100644 index 12670867..00000000 --- a/src/google/cloud/functions_v1beta2/context.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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. - -"""Definition of the context type used by Cloud Functions in Python.""" - - -class Context(object): - """Context passed to background functions.""" - - def __init__(self, eventId="", timestamp="", eventType="", resource=""): - self.event_id = eventId - self.timestamp = timestamp - self.event_type = eventType - self.resource = resource - - def __str__(self): - return "{event_id: %s, timestamp: %s, event_type: %s, resource: %s}" % ( - self.event_id, - self.timestamp, - self.event_type, - self.resource, - ) diff --git a/tests/test_convert.py b/tests/test_convert.py index 592681e7..e3a5f6bd 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -21,8 +21,8 @@ from cloudevents.http import from_json, to_binary from functions_framework import event_conversion +from functions_framework.context import Context from functions_framework.exceptions import EventConversionException -from google.cloud.functions.context import Context TEST_DATA_DIR = pathlib.Path(__file__).resolve().parent / "test_data"