-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy path__init__.py
More file actions
51 lines (42 loc) · 2.44 KB
/
Copy path__init__.py
File metadata and controls
51 lines (42 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Copyright (c) Microsoft Corporation.
Licensed under the MIT license.
mssql_python_odbc — Microsoft ODBC Driver 18 for SQL Server binaries.
Internal implementation package for ``mssql-python``. It ships the
platform-specific ODBC driver binaries (``msodbcsql18``) and their supporting
libraries so that ``mssql-python`` does not have to bundle them in its own
wheel. It is not meant for direct consumption — install ``mssql-python``
instead, which depends on this package.
Driver-path resolution lives entirely in the native
``mssql_python.ddbc_bindings`` extension (``GetOdbcLibsBaseDir`` /
``GetDriverPathCpp``): it imports this package purely for its ``__file__`` and
appends ``libs/<platform>/<arch>/...`` itself. Keeping a single (C++) resolver
avoids a second copy of the arch/distro/filename logic that could silently
drift out of sync — see the drift guard in ``tests/test_000_dependencies.py``.
"""
import os
__all__ = ["get_libs_dir", "__version__"]
# Version tracks the bundled Microsoft ODBC Driver 18 for SQL Server release and
# is the single source of truth for the driver version. ``setup_odbc.py`` reads
# it for the wheel version, and the native build (``mssql_python/pybind/
# CMakeLists.txt``) derives the driver filename version from it and injects it
# into ``GetDriverPathCpp`` -- so the C++ resolver and this package can never
# drift. Bump this one value to move to a new driver release.
#
# The bundled Microsoft ODBC driver is 18.6; the trailing components are
# mssql-python-odbc's own packaging-revision counter. 18.6.2.1 is a metadata-only
# re-release of 18.6.2 (license label corrected MIT -> proprietary; identical
# binaries) -- the trailing ".1" is packaging revision 1. A literal "v1" suffix
# is not a valid PEP 440 version and +local versions are rejected by PyPI, so the
# revision is expressed as a fourth numeric component. ``mssql_python/pybind/
# CMakeLists.txt`` parses only the leading MAJOR.MINOR from this value, so the
# extra component does not affect the resolved driver filename.
__version__ = "18.6.2.1"
def get_libs_dir() -> str:
"""Return the absolute path to this package's ``libs/`` directory.
This is the root under which the platform-specific ODBC binaries live
(``libs/<platform>/<arch>/...``). The parent of this path (the package
directory) is the base the native loader appends ``libs`` to when resolving
the driver.
"""
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "libs")