You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2025/09/22 00:27:42 UTC
(arrow-adbc) branch main updated: fix(c/driver_manager): ensure CONDA_PREFIX search builds (#3428)
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 4cd05f029 fix(c/driver_manager): ensure CONDA_PREFIX search builds (#3428)
4cd05f029 is described below
commit 4cd05f02986da9addc920d6a02ca6dfe7702791e
Author: David Li <li...@gmail.com>
AuthorDate: Mon Sep 22 09:27:37 2025 +0900
fix(c/driver_manager): ensure CONDA_PREFIX search builds (#3428)
Closes #3427.
---
.github/workflows/native-unix.yml | 2 ++
c/driver_manager/CMakeLists.txt | 6 ++++
c/driver_manager/adbc_driver_manager.cc | 2 +-
c/driver_manager/adbc_driver_manager_test.cc | 41 +++++++++++++++++++++++++---
go/adbc/drivermgr/adbc_driver_manager.cc | 2 +-
5 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/native-unix.yml b/.github/workflows/native-unix.yml
index 7b50d92e8..a2c3864cd 100644
--- a/.github/workflows/native-unix.yml
+++ b/.github/workflows/native-unix.yml
@@ -198,6 +198,8 @@ jobs:
BUILD_DRIVER_SQLITE: "1"
ADBC_DRIVER_MANAGER_USER_CONFIG_TEST: "1"
run: |
+ # Ensure the CONDA_PREFIX searching in driver manager is tested
+ export CONDA_BUILD=1
./ci/scripts/cpp_build.sh "$(pwd)" "$(pwd)/build"
- name: Test
env:
diff --git a/c/driver_manager/CMakeLists.txt b/c/driver_manager/CMakeLists.txt
index 64ba340a3..7057cc78e 100644
--- a/c/driver_manager/CMakeLists.txt
+++ b/c/driver_manager/CMakeLists.txt
@@ -69,6 +69,7 @@ foreach(LIB_TARGET ${ADBC_LIBRARIES})
${REPOSITORY_ROOT}/c/vendor
${REPOSITORY_ROOT}/c/driver)
target_compile_definitions(${LIB_TARGET} PRIVATE ADBC_EXPORTING)
+ # We have to match R Makevars which can only set to 1 or 0 (not define/undefine)
if("$ENV{CONDA_BUILD}" STREQUAL "1")
target_compile_definitions(${LIB_TARGET} PRIVATE ADBC_CONDA_BUILD=1)
else()
@@ -109,6 +110,11 @@ if(ADBC_BUILD_TESTS)
target_compile_definitions(adbc-driver-manager-test
PRIVATE ADBC_DRIVER_MANAGER_TEST_MANIFEST_SYSTEM_LEVEL=1)
endif()
+ if("$ENV{CONDA_BUILD}" STREQUAL "1")
+ target_compile_definitions(adbc-driver-manager-test PRIVATE ADBC_CONDA_BUILD=1)
+ else()
+ target_compile_definitions(adbc-driver-manager-test PRIVATE ADBC_CONDA_BUILD=0)
+ endif()
target_include_directories(adbc-driver-manager-test SYSTEM
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
diff --git a/c/driver_manager/adbc_driver_manager.cc b/c/driver_manager/adbc_driver_manager.cc
index 3169fd480..3943fd81b 100644
--- a/c/driver_manager/adbc_driver_manager.cc
+++ b/c/driver_manager/adbc_driver_manager.cc
@@ -731,7 +731,7 @@ struct ManagedLibrary {
#endif // _WIN32
auto venv = GetEnvPaths(conda_name);
if (!venv.empty()) {
- for (const auto& venv_path : venv) {
+ for (const auto& [_, venv_path] : venv) {
search_paths.emplace_back(SearchPathSource::kConda,
venv_path / "etc" / "adbc" / "drivers");
}
diff --git a/c/driver_manager/adbc_driver_manager_test.cc b/c/driver_manager/adbc_driver_manager_test.cc
index 0fe83ca65..5ce5a406a 100644
--- a/c/driver_manager/adbc_driver_manager_test.cc
+++ b/c/driver_manager/adbc_driver_manager_test.cc
@@ -22,10 +22,10 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
-#include <stdlib.h>
#include <algorithm>
+#include <cstdlib>
#include <filesystem> // NOLINT [build/c++17]
-#include <memory>
+#include <iostream>
#include <string>
#include <toml++/toml.hpp>
#include <vector>
@@ -1000,7 +1000,40 @@ TEST_F(DriverManifest, LoadSystemLevelManifest) {
}
#endif
-// TEST CASES
-// manifest not found on given paths
+TEST_F(DriverManifest, CondaPrefix) {
+#if ADBC_CONDA_BUILD
+ constexpr bool is_conda_build = true;
+#else
+ constexpr bool is_conda_build = false;
+#endif // ADBC_CONDA_BUILD
+
+ std::cerr << "ADBC_CONDA_BUILD: " << (is_conda_build ? "defined" : "not defined")
+ << std::endl;
+
+ auto filepath = temp_dir / "etc" / "adbc" / "drivers" / "sqlite.toml";
+ std::filesystem::create_directories(filepath.parent_path());
+ std::ofstream test_manifest_file(filepath);
+ ASSERT_TRUE(test_manifest_file.is_open());
+ test_manifest_file << simple_manifest;
+ test_manifest_file.close();
+
+#ifdef _WIN32
+ ASSERT_EQ(0, ::_wputenv_s(L"CONDA_PREFIX", temp_dir.native().c_str()));
+#else
+ ASSERT_EQ(0, ::setenv("CONDA_PREFIX", temp_dir.native().c_str(), 1));
+#endif // _WIN32
+
+ AdbcStatusCode result =
+ AdbcFindLoadDriver("sqlite", nullptr, ADBC_VERSION_1_1_0, ADBC_LOAD_FLAG_DEFAULT,
+ nullptr, &driver, &error);
+
+ if constexpr (is_conda_build) {
+ ASSERT_THAT(result, IsOkStatus(&error));
+ } else {
+ ASSERT_THAT(result, IsStatus(ADBC_STATUS_NOT_FOUND, &error));
+ ASSERT_THAT(error.message,
+ ::testing::HasSubstr("not enabled at build time: Conda prefix"));
+ }
+}
} // namespace adbc
diff --git a/go/adbc/drivermgr/adbc_driver_manager.cc b/go/adbc/drivermgr/adbc_driver_manager.cc
index 3169fd480..3943fd81b 100644
--- a/go/adbc/drivermgr/adbc_driver_manager.cc
+++ b/go/adbc/drivermgr/adbc_driver_manager.cc
@@ -731,7 +731,7 @@ struct ManagedLibrary {
#endif // _WIN32
auto venv = GetEnvPaths(conda_name);
if (!venv.empty()) {
- for (const auto& venv_path : venv) {
+ for (const auto& [_, venv_path] : venv) {
search_paths.emplace_back(SearchPathSource::kConda,
venv_path / "etc" / "adbc" / "drivers");
}