diff --git a/azure-cognitiveservices-vision-computervision/MANIFEST.in b/azure-cognitiveservices-vision-computervision/MANIFEST.in index 9ecaeb15de50..bb37a2723dae 100644 --- a/azure-cognitiveservices-vision-computervision/MANIFEST.in +++ b/azure-cognitiveservices-vision-computervision/MANIFEST.in @@ -1,2 +1 @@ include *.rst -include azure_bdist_wheel.py \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/README.rst b/azure-cognitiveservices-vision-computervision/README.rst index ee1ba86cf7c0..eee101b4fb52 100644 --- a/azure-cognitiveservices-vision-computervision/README.rst +++ b/azure-cognitiveservices-vision-computervision/README.rst @@ -3,7 +3,7 @@ Microsoft Azure SDK for Python This is the Microsoft Azure Cognitive Services Computer Vision Client Library. -This package has been tested with Python 2.7, 3.4, 3.5 and 3.6. +This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. For a more complete set of Azure libraries, see the `azure `__ bundle package. diff --git a/azure-cognitiveservices-vision-computervision/azure/__init__.py b/azure-cognitiveservices-vision-computervision/azure/__init__.py index 849489fca33c..0260537a02bb 100644 --- a/azure-cognitiveservices-vision-computervision/azure/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/__init__.py index 849489fca33c..0260537a02bb 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/__init__.py index 849489fca33c..0260537a02bb 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py index fd2f9fce7750..949f9d69e590 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/computer_vision_client.py @@ -104,13 +104,13 @@ def list_models( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -195,6 +195,7 @@ def analyze_image( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -203,9 +204,8 @@ def analyze_image( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -276,6 +276,7 @@ def generate_thumbnail( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/octet-stream' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -284,9 +285,8 @@ def generate_thumbnail( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=True, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=True, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) @@ -356,6 +356,7 @@ def recognize_printed_text( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -364,9 +365,8 @@ def recognize_printed_text( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -436,6 +436,7 @@ def describe_image( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -444,9 +445,8 @@ def describe_image( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -510,6 +510,7 @@ def tag_image( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -518,9 +519,8 @@ def tag_image( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -587,6 +587,7 @@ def analyze_image_by_domain( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) @@ -595,9 +596,8 @@ def analyze_image_by_domain( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -660,9 +660,8 @@ def recognize_text( body_content = self._serialize.body(image_url, 'ImageUrl') # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [202]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -709,13 +708,13 @@ def get_text_operation_result( # Construct headers header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' + header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send(request, header_parameters, stream=False, **operation_config) + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -800,6 +799,7 @@ def analyze_image_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -808,9 +808,8 @@ def analyze_image_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -879,6 +878,7 @@ def generate_thumbnail_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/octet-stream' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -887,9 +887,8 @@ def generate_thumbnail_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=True, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=True, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) @@ -962,6 +961,7 @@ def recognize_printed_text_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -970,9 +970,8 @@ def recognize_printed_text_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -1045,6 +1044,7 @@ def describe_image_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -1053,9 +1053,8 @@ def describe_image_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -1122,6 +1121,7 @@ def tag_image_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -1130,9 +1130,8 @@ def tag_image_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -1202,6 +1201,7 @@ def analyze_image_by_domain_in_stream( # Construct headers header_parameters = {} + header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/octet-stream' if custom_headers: header_parameters.update(custom_headers) @@ -1210,9 +1210,8 @@ def analyze_image_by_domain_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise models.ComputerVisionErrorException(self._deserialize, response) @@ -1278,9 +1277,8 @@ def recognize_text_in_stream( body_content = self._client.stream_upload(image, callback) # Construct and send request - request = self._client.post(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [202]: raise models.ComputerVisionErrorException(self._deserialize, response) diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py index 8f036444cccf..f487c5eecaad 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/__init__.py @@ -10,10 +10,6 @@ # -------------------------------------------------------------------------- try: - from .word_py3 import Word - from .line_py3 import Line - from .recognition_result_py3 import RecognitionResult - from .text_operation_result_py3 import TextOperationResult from .face_rectangle_py3 import FaceRectangle from .celebrities_model_py3 import CelebritiesModel from .landmarks_model_py3 import LandmarksModel @@ -41,11 +37,11 @@ from .tag_result_py3 import TagResult from .computer_vision_error_py3 import ComputerVisionError, ComputerVisionErrorException from .image_url_py3 import ImageUrl + from .word_py3 import Word + from .line_py3 import Line + from .recognition_result_py3 import RecognitionResult + from .text_operation_result_py3 import TextOperationResult except (SyntaxError, ImportError): - from .word import Word - from .line import Line - from .recognition_result import RecognitionResult - from .text_operation_result import TextOperationResult from .face_rectangle import FaceRectangle from .celebrities_model import CelebritiesModel from .landmarks_model import LandmarksModel @@ -73,10 +69,14 @@ from .tag_result import TagResult from .computer_vision_error import ComputerVisionError, ComputerVisionErrorException from .image_url import ImageUrl + from .word import Word + from .line import Line + from .recognition_result import RecognitionResult + from .text_operation_result import TextOperationResult from .computer_vision_client_enums import ( - TextOperationStatusCodes, Gender, ComputerVisionErrorCodes, + TextOperationStatusCodes, VisualFeatureTypes, OcrLanguages, TextRecognitionMode, @@ -84,10 +84,6 @@ ) __all__ = [ - 'Word', - 'Line', - 'RecognitionResult', - 'TextOperationResult', 'FaceRectangle', 'CelebritiesModel', 'LandmarksModel', @@ -115,9 +111,13 @@ 'TagResult', 'ComputerVisionError', 'ComputerVisionErrorException', 'ImageUrl', - 'TextOperationStatusCodes', + 'Word', + 'Line', + 'RecognitionResult', + 'TextOperationResult', 'Gender', 'ComputerVisionErrorCodes', + 'TextOperationStatusCodes', 'VisualFeatureTypes', 'OcrLanguages', 'TextRecognitionMode', diff --git a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py index c97e56a9787a..3354b6007794 100644 --- a/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py +++ b/azure-cognitiveservices-vision-computervision/azure/cognitiveservices/vision/computervision/models/computer_vision_client_enums.py @@ -12,14 +12,6 @@ from enum import Enum -class TextOperationStatusCodes(str, Enum): - - not_started = "Not Started" - running = "Running" - failed = "Failed" - succeeded = "Succeeded" - - class Gender(str, Enum): male = "Male" @@ -43,6 +35,14 @@ class ComputerVisionErrorCodes(str, Enum): storage_exception = "StorageException" +class TextOperationStatusCodes(str, Enum): + + not_started = "Not Started" + running = "Running" + failed = "Failed" + succeeded = "Succeeded" + + class VisualFeatureTypes(str, Enum): image_type = "ImageType" diff --git a/azure-cognitiveservices-vision-computervision/azure_bdist_wheel.py b/azure-cognitiveservices-vision-computervision/azure_bdist_wheel.py deleted file mode 100644 index 8a81d1b61775..000000000000 --- a/azure-cognitiveservices-vision-computervision/azure_bdist_wheel.py +++ /dev/null @@ -1,54 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- - -from distutils import log as logger -import os.path - -from wheel.bdist_wheel import bdist_wheel -class azure_bdist_wheel(bdist_wheel): - """The purpose of this class is to build wheel a little differently than the sdist, - without requiring to build the wheel from the sdist (i.e. you can build the wheel - directly from source). - """ - - description = "Create an Azure wheel distribution" - - user_options = bdist_wheel.user_options + \ - [('azure-namespace-package=', None, - "Name of the deepest nspkg used")] - - def initialize_options(self): - bdist_wheel.initialize_options(self) - self.azure_namespace_package = None - - def finalize_options(self): - bdist_wheel.finalize_options(self) - if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): - raise ValueError("azure_namespace_package must finish by -nspkg") - - def run(self): - if not self.distribution.install_requires: - self.distribution.install_requires = [] - self.distribution.install_requires.append( - "{}>=2.0.0".format(self.azure_namespace_package)) - bdist_wheel.run(self) - - def write_record(self, bdist_dir, distinfo_dir): - if self.azure_namespace_package: - # Split and remove last part, assuming it's "nspkg" - subparts = self.azure_namespace_package.split('-')[0:-1] - folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] - for azure_sub_package in folder_with_init: - init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') - if os.path.isfile(init_file): - logger.info("manually remove {} while building the wheel".format(init_file)) - os.remove(init_file) - else: - raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) - bdist_wheel.write_record(self, bdist_dir, distinfo_dir) -cmdclass = { - 'bdist_wheel': azure_bdist_wheel, -} diff --git a/azure-cognitiveservices-vision-computervision/setup.cfg b/azure-cognitiveservices-vision-computervision/setup.cfg index 6197b40d106e..3c6e79cf31da 100644 --- a/azure-cognitiveservices-vision-computervision/setup.cfg +++ b/azure-cognitiveservices-vision-computervision/setup.cfg @@ -1,3 +1,2 @@ [bdist_wheel] universal=1 -azure-namespace-package=azure-cognitiveservices-vision-nspkg \ No newline at end of file diff --git a/azure-cognitiveservices-vision-computervision/setup.py b/azure-cognitiveservices-vision-computervision/setup.py index 7402c1967c37..32cce8b8ac31 100644 --- a/azure-cognitiveservices-vision-computervision/setup.py +++ b/azure-cognitiveservices-vision-computervision/setup.py @@ -10,12 +10,6 @@ import os.path from io import open from setuptools import find_packages, setup -try: - from azure_bdist_wheel import cmdclass -except ImportError: - from distutils import log as logger - logger.warn("Wheel is not available, disabling bdist_wheel hook") - cmdclass = {} # Change the PACKAGE_NAME only to change folder and different name PACKAGE_NAME = "azure-cognitiveservices-vision-computervision" @@ -72,13 +66,23 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'License :: OSI Approved :: MIT License', ], zip_safe=False, - packages=find_packages(exclude=["tests"]), + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.cognitiveservices', + 'azure.cognitiveservices.vision', + ]), install_requires=[ - 'msrest>=0.4.29,<2.0.0', + 'msrest>=0.5.0', + 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', ], - cmdclass=cmdclass + extras_require={ + ":python_version<'3.0'": ['azure-cognitiveservices-vision-nspkg'], + } )