1# Copyright 2018 Google LLC
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#     https://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
15import warnings
16
17_SLOW_CRC32C_WARNING = (
18    "As the c extension couldn't be imported, `google-crc32c` is using a "
19    "pure python implementation that is significantly slower. If possible, "
20    "please configure a c build environment and compile the extension"
21)
22
23# Default to C exstension Implementation, falling back to pure python.
24try:
25    from google_crc32c import cext as impl
26    implementation = "c"
27except ImportError as exc:
28    from google_crc32c import python as impl
29    warnings.warn(_SLOW_CRC32C_WARNING, RuntimeWarning)
30    implementation = "python"
31
32extend = impl.extend
33value = impl.value
34
35Checksum = impl.Checksum
36
37__all__ = ["extend", "value", "Checksum", "implementation"]
38