This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 526dd933c fix(c/driver_manager): add `drivers` subdir in search paths
(#3375)
526dd933c is described below
commit 526dd933c2a7fca33486133e05e180a7b1a9d1e2
Author: Matt Topol <[email protected]>
AuthorDate: Mon Sep 1 00:59:20 2025 -0400
fix(c/driver_manager): add `drivers` subdir in search paths (#3375)
resolves #3374
---------
Co-authored-by: Ian Cook <[email protected]>
Co-authored-by: David Li <[email protected]>
---
c/driver_manager/adbc_driver_manager.cc | 13 +++++++------
c/driver_manager/adbc_driver_manager_test.cc | 4 ++--
.../cpp/recipe_driver/driver_example_manifest.py | 4 ++--
docs/source/format/driver_manifests.rst | 18 +++++++++---------
go/adbc/drivermgr/adbc_driver_manager.cc | 17 +++++++++--------
rust/driver_manager/src/lib.rs | 22 +++++++++++++++-------
6 files changed, 44 insertions(+), 34 deletions(-)
diff --git a/c/driver_manager/adbc_driver_manager.cc
b/c/driver_manager/adbc_driver_manager.cc
index 6836e0f1a..e8ef6f01a 100644
--- a/c/driver_manager/adbc_driver_manager.cc
+++ b/c/driver_manager/adbc_driver_manager.cc
@@ -321,12 +321,13 @@ std::vector<std::filesystem::path> GetSearchPaths(const
AdbcLoadFlags levels) {
// only need to check for macOS and fall back to Unix-like behavior as long
// as we're not on Windows
#if defined(__APPLE__)
- const std::filesystem::path system_config_dir("/Library/Application
Support/ADBC");
+ const std::filesystem::path system_config_dir(
+ "/Library/Application Support/ADBC/Drivers");
if (std::filesystem::exists(system_config_dir)) {
paths.push_back(system_config_dir);
}
#elif !defined(_WIN32)
- const std::filesystem::path system_config_dir("/etc/adbc");
+ const std::filesystem::path system_config_dir("/etc/adbc/drivers");
if (std::filesystem::exists(system_config_dir)) {
paths.push_back(system_config_dir);
}
@@ -500,7 +501,7 @@ struct ManagedLibrary {
auto venv = GetEnvPaths(conda_name);
if (!venv.empty()) {
for (const auto& venv_path : venv) {
- search_paths.push_back(venv_path / "etc" / "adbc");
+ search_paths.push_back(venv_path / "etc" / "adbc" / "drivers");
}
}
}
@@ -1073,13 +1074,13 @@ std::filesystem::path InternalAdbcUserConfigDir() {
std::filesystem::path dir(std::move(wpath));
if (!dir.empty()) {
config_dir = std::filesystem::path(dir);
- config_dir /= "ADBC/drivers";
+ config_dir /= "ADBC/Drivers";
}
#elif defined(__APPLE__)
auto dir = std::getenv("HOME");
if (dir) {
config_dir = std::filesystem::path(dir);
- config_dir /= "Library/Application Support/ADBC";
+ config_dir /= "Library/Application Support/ADBC/Drivers";
}
#elif defined(__linux__)
auto dir = std::getenv("XDG_CONFIG_HOME");
@@ -1093,7 +1094,7 @@ std::filesystem::path InternalAdbcUserConfigDir() {
}
if (!config_dir.empty()) {
- config_dir /= "adbc";
+ config_dir = config_dir / "adbc" / "drivers";
}
#endif // defined(_WIN32)
diff --git a/c/driver_manager/adbc_driver_manager_test.cc
b/c/driver_manager/adbc_driver_manager_test.cc
index 7857024fe..aab045dd1 100644
--- a/c/driver_manager/adbc_driver_manager_test.cc
+++ b/c/driver_manager/adbc_driver_manager_test.cc
@@ -678,7 +678,7 @@ TEST_F(DriverManifest, LoadUserLevelManifest) {
}
#endif
-// only build and run test that creates / adds a file to /etc/adbc if
+// only build and run test that creates / adds a file to /etc/adbc/drivers if
// it's been enabled via the build system setting this compile def
#ifdef ADBC_DRIVER_MANAGER_TEST_MANIFEST_SYSTEM_LEVEL
TEST_F(DriverManifest, LoadSystemLevelManifest) {
@@ -686,7 +686,7 @@ TEST_F(DriverManifest, LoadSystemLevelManifest) {
ADBC_LOAD_FLAG_DEFAULT, nullptr, &driver,
&error),
Not(IsOkStatus(&error)));
- auto system_config_dir = std::filesystem::path("/etc/adbc");
+ auto system_config_dir = std::filesystem::path("/etc/adbc/drivers");
bool created = false;
if (!std::filesystem::exists(system_config_dir)) {
ASSERT_TRUE(std::filesystem::create_directories(system_config_dir));
diff --git a/docs/source/cpp/recipe_driver/driver_example_manifest.py
b/docs/source/cpp/recipe_driver/driver_example_manifest.py
index ce01f8920..af4211ad9 100644
--- a/docs/source/cpp/recipe_driver/driver_example_manifest.py
+++ b/docs/source/cpp/recipe_driver/driver_example_manifest.py
@@ -41,8 +41,8 @@ def connect(uri: str):
)
# alternatively, it can look for the manifest file in the user's config
- # directory ($HOME/.config/adbc/driver_example.toml) or the system's
- # config directory (/etc/adbc/driver_example.toml)
+ # directory ($HOME/.config/adbc/drivers/driver_example.toml) or the
system's
+ # config directory (/etc/adbc/drivers/driver_example.toml)
return dbapi.connect(driver="driver_example", db_kwargs={"uri": uri})
diff --git a/docs/source/format/driver_manifests.rst
b/docs/source/format/driver_manifests.rst
index 60d68eea5..107f0852f 100644
--- a/docs/source/format/driver_manifests.rst
+++ b/docs/source/format/driver_manifests.rst
@@ -442,20 +442,20 @@ the given order:
#. If additional search paths have been specified, those will be searched
- * The Python driver manager automatically adds ``$VIRTUAL_ENV/etc/adbc`` to
the search paths when running in a ``venv`` virtual environment
+ * The Python driver manager automatically adds
``$VIRTUAL_ENV/etc/adbc/drivers`` to the search paths when running in a
``venv`` virtual environment
-#. If the driver manager was built or installed with conda and the
``LOAD_FLAG_SEARCH_ENV`` load option is set, ``$CONDA_PREFIX/etc/adbc`` will be
searched
+#. If the driver manager was built or installed with conda and the
``LOAD_FLAG_SEARCH_ENV`` load option is set, ``$CONDA_PREFIX/etc/adbc/drivers``
will be searched
#. If the ``LOAD_FLAG_SEARCH_USER`` load option is set, then a user-level
configuration directory will be searched
- * On macOS, this will be ``~/Library/Application Support/ADBC``
+ * On macOS, this will be ``~/Library/Application Support/ADBC/Drivers``
* On Linux (and other Unix-like platforms), the ``XDG_CONFIG_HOME``
environment variable is checked first. If it is set, the driver manager
- will search ``$XDG_CONFIG_HOME/adbc``, otherwise it will search
``~/.config/adbc``
+ will search ``$XDG_CONFIG_HOME/adbc/drivers``, otherwise it will search
``~/.config/adbc/drivers``
#. If the ``LOAD_FLAG_SEARCH_SYSTEM`` load option is set, then a system-level
configuration directory will be searched
- * On macOS, this will be ``/Library/Application Support/ADBC`` if it exists
- * On Linux (and other Unix-like platforms), this will be ``/etc/adbc`` if
it exists
+ * On macOS, this will be ``/Library/Application Support/ADBC/Drivers`` if
it exists
+ * On Linux (and other Unix-like platforms), this will be
``/etc/adbc/drivers`` if it exists
Windows
^^^^^^^
@@ -469,9 +469,9 @@ would happen for ODBC drivers. The search for a manifest on
Windows would be the
#. If additional search paths have been specified, those will be searched
- * The Python driver manager automatically adds ``$VIRTUAL_ENV\etc\adbc`` to
the search paths when running in a ``venv`` virtual environment
+ * The Python driver manager automatically adds
``$VIRTUAL_ENV\etc\adbc\drivers`` to the search paths when running in a
``venv`` virtual environment
-#. If the driver manager was built or installed with conda and the
``LOAD_FLAG_SEARCH_ENV`` load option is set, ``$CONDA_PREFIX\etc\adbc`` will be
searched
+#. If the driver manager was built or installed with conda and the
``LOAD_FLAG_SEARCH_ENV`` load option is set, ``$CONDA_PREFIX\etc\adbc\drivers``
will be searched
#. If the ``LOAD_FLAG_SEARCH_USER`` load option is set, then a user-level
configuration is searched for
@@ -484,7 +484,7 @@ would happen for ODBC drivers. The search for a manifest on
Windows would be the
* ``entrypoint`` - the entrypoint to use for the driver if a non-default
entrypoint is needed
* ``driver`` - the path to the driver shared library
- * If no registry key is found, then the directory
``%LOCAL_APPDATA%\ADBC\drivers`` is searched
+ * If no registry key is found, then the directory
``%LOCAL_APPDATA%\ADBC\Drivers`` is searched
#. If the ``LOAD_FLAG_SEARCH_SYSTEM`` load option is set, the driver manager
will search for a system-level configuration
diff --git a/go/adbc/drivermgr/adbc_driver_manager.cc
b/go/adbc/drivermgr/adbc_driver_manager.cc
index 5af9643e4..e8ef6f01a 100644
--- a/go/adbc/drivermgr/adbc_driver_manager.cc
+++ b/go/adbc/drivermgr/adbc_driver_manager.cc
@@ -292,7 +292,7 @@ std::vector<std::filesystem::path> GetEnvPaths(const
char_type* env_var) {
return {};
}
std::string path(path_var);
-#endif
+#endif // _WIN32
return InternalAdbcParsePath(path);
}
@@ -303,7 +303,7 @@ std::vector<std::filesystem::path> GetSearchPaths(const
AdbcLoadFlags levels) {
static const wchar_t* env_var = L"ADBC_DRIVER_PATH";
#else
static const char* env_var = "ADBC_DRIVER_PATH";
-#endif
+#endif // _WIN32
// Check the ADBC_DRIVER_PATH environment variable
paths = GetEnvPaths(env_var);
}
@@ -321,12 +321,13 @@ std::vector<std::filesystem::path> GetSearchPaths(const
AdbcLoadFlags levels) {
// only need to check for macOS and fall back to Unix-like behavior as long
// as we're not on Windows
#if defined(__APPLE__)
- const std::filesystem::path system_config_dir("/Library/Application
Support/ADBC");
+ const std::filesystem::path system_config_dir(
+ "/Library/Application Support/ADBC/Drivers");
if (std::filesystem::exists(system_config_dir)) {
paths.push_back(system_config_dir);
}
#elif !defined(_WIN32)
- const std::filesystem::path system_config_dir("/etc/adbc");
+ const std::filesystem::path system_config_dir("/etc/adbc/drivers");
if (std::filesystem::exists(system_config_dir)) {
paths.push_back(system_config_dir);
}
@@ -500,7 +501,7 @@ struct ManagedLibrary {
auto venv = GetEnvPaths(conda_name);
if (!venv.empty()) {
for (const auto& venv_path : venv) {
- search_paths.push_back(venv_path / "etc" / "adbc");
+ search_paths.push_back(venv_path / "etc" / "adbc" / "drivers");
}
}
}
@@ -1073,13 +1074,13 @@ std::filesystem::path InternalAdbcUserConfigDir() {
std::filesystem::path dir(std::move(wpath));
if (!dir.empty()) {
config_dir = std::filesystem::path(dir);
- config_dir /= "ADBC/drivers";
+ config_dir /= "ADBC/Drivers";
}
#elif defined(__APPLE__)
auto dir = std::getenv("HOME");
if (dir) {
config_dir = std::filesystem::path(dir);
- config_dir /= "Library/Application Support/ADBC";
+ config_dir /= "Library/Application Support/ADBC/Drivers";
}
#elif defined(__linux__)
auto dir = std::getenv("XDG_CONFIG_HOME");
@@ -1093,7 +1094,7 @@ std::filesystem::path InternalAdbcUserConfigDir() {
}
if (!config_dir.empty()) {
- config_dir /= "adbc";
+ config_dir = config_dir / "adbc" / "drivers";
}
#endif // defined(_WIN32)
diff --git a/rust/driver_manager/src/lib.rs b/rust/driver_manager/src/lib.rs
index 170550a91..286d7f70e 100644
--- a/rust/driver_manager/src/lib.rs
+++ b/rust/driver_manager/src/lib.rs
@@ -515,7 +515,10 @@ impl ManagedDriver {
#[cfg(conda_build)]
if load_flags & LOAD_FLAG_SEARCH_ENV != 0 {
if let Some(conda_prefix) = env::var_os("CONDA_PREFIX") {
- let conda_path =
PathBuf::from(conda_prefix).join("etc").join("adbc");
+ let conda_path = PathBuf::from(conda_prefix)
+ .join("etc")
+ .join("adbc")
+ .join("drivers");
if let Ok(result) =
Self::search_path_list(driver_path, vec![conda_path],
entrypoint, version)
{
@@ -584,7 +587,10 @@ impl ManagedDriver {
#[cfg(conda_build)]
if load_flags & LOAD_FLAG_SEARCH_ENV != 0 {
if let Some(conda_prefix) = env::var_os("CONDA_PREFIX") {
- let conda_path =
PathBuf::from(conda_prefix).join("etc").join("adbc");
+ let conda_path = PathBuf::from(conda_prefix)
+ .join("etc")
+ .join("adbc")
+ .join("drivers");
path_list.push(conda_path);
}
}
@@ -1762,7 +1768,7 @@ fn user_config_dir() -> Option<PathBuf> {
use target_windows::user_config_dir;
user_config_dir().map(|mut path| {
path.push("ADBC");
- path.push("drivers");
+ path.push("Drivers");
path
})
}
@@ -1773,6 +1779,7 @@ fn user_config_dir() -> Option<PathBuf> {
path.push("Library");
path.push("Application Support");
path.push("ADBC");
+ path.push("Drivers");
path
})
}
@@ -1790,6 +1797,7 @@ fn user_config_dir() -> Option<PathBuf> {
})
.map(|mut path| {
path.push("adbc");
+ path.push("drivers");
path
})
}
@@ -1798,12 +1806,12 @@ fn user_config_dir() -> Option<PathBuf> {
fn system_config_dir() -> Option<PathBuf> {
#[cfg(target_os = "macos")]
{
- Some(PathBuf::from("/Library/Application Support/ADBC"))
+ Some(PathBuf::from("/Library/Application Support/ADBC/Drivers"))
}
#[cfg(all(unix, not(target_os = "macos")))]
{
- Some(PathBuf::from("/etc/adbc"))
+ Some(PathBuf::from("/etc/adbc/drivers"))
}
#[cfg(not(unix))]
@@ -2307,9 +2315,9 @@ mod tests {
#[cfg_attr(not(windows), ignore)]
fn test_get_search_paths() {
#[cfg(target_os = "macos")]
- let system_path = PathBuf::from("/Library/Application Support/ADBC");
+ let system_path = PathBuf::from("/Library/Application
Support/ADBC/Drivers");
#[cfg(not(target_os = "macos"))]
- let system_path = PathBuf::from("/etc/adbc");
+ let system_path = PathBuf::from("/etc/adbc/drivers");
let search_paths = get_search_paths(LOAD_FLAG_SEARCH_SYSTEM);
if system_path.exists() {