Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
_has_cy.py41 linesDownload Raw Back to util
1# util/_has_cy.py
2# Copyright (C) 2005-2024 the SQLAlchemy authors and contributors
3# <see AUTHORS file>
4#
5# This module is part of SQLAlchemy and is released under
6# the MIT License: https://www.opensource.org/licenses/mit-license.php
7# mypy: ignore-errors
8
9import os
10import typing
11
12
13def _import_cy_extensions():
14    # all cython extension extension modules are treated as optional by the
15    # setup, so to ensure that all are compiled, all should be imported here
16    from ..cyextension import collections
17    from ..cyextension import immutabledict
18    from ..cyextension import processors
19    from ..cyextension import resultproxy
20    from ..cyextension import util
21
22    return (collections, immutabledict, processors, resultproxy, util)
23
24
25_CYEXTENSION_MSG: str
26if not typing.TYPE_CHECKING:
27    if os.environ.get("DISABLE_SQLALCHEMY_CEXT_RUNTIME"):
28        HAS_CYEXTENSION = False
29        _CYEXTENSION_MSG = "DISABLE_SQLALCHEMY_CEXT_RUNTIME is set"
30    else:
31        try:
32            _import_cy_extensions()
33        except ImportError as err:
34            HAS_CYEXTENSION = False
35            _CYEXTENSION_MSG = str(err)
36        else:
37            _CYEXTENSION_MSG = "Loaded"
38            HAS_CYEXTENSION = True
39else:
40    HAS_CYEXTENSION = False
41 
codekingpro/portable-devtools · Team Ai