Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
84cac0c
feat(c/driver_manager,rust/driver_manager): handle virtual environmen…
zeroshade Aug 20, 2025
8d87bee
Update docs/source/format/driver_manifests.rst
zeroshade Aug 20, 2025
4062f95
Update docs/source/format/driver_manifests.rst
zeroshade Aug 20, 2025
1df42a1
Update docs/source/format/driver_manifests.rst
zeroshade Aug 20, 2025
c9b48f0
darn you windows
zeroshade Aug 20, 2025
e513570
fix other references to ADBC_CONFIG_PATH
zeroshade Aug 20, 2025
67a18de
fix lint
zeroshade Aug 20, 2025
69cf5b2
fix rust args
zeroshade Aug 21, 2025
2a427ba
avoid bad move
zeroshade Aug 21, 2025
8375be9
make up your damn mind
zeroshade Aug 21, 2025
824292f
remove VIRTUAL_ENV, add additional search paths
zeroshade Aug 21, 2025
5749c49
fix R build
zeroshade Aug 21, 2025
8314ee2
fix R build
zeroshade Aug 21, 2025
f9aec98
fix R docs
zeroshade Aug 21, 2025
06113f8
add docs to R
zeroshade Aug 21, 2025
245728c
fix typo
zeroshade Aug 21, 2025
0d4021c
only check CONDA_PREFIX during CONDA_BUILD
zeroshade Aug 21, 2025
6b23dfd
cargo conda_build
zeroshade Aug 21, 2025
8148485
updates from comments
zeroshade Aug 22, 2025
86944f5
fix R stuff
zeroshade Aug 22, 2025
f8473e9
R is annoying
zeroshade Aug 22, 2025
4152f1f
maybe this time?
zeroshade Aug 22, 2025
b995130
maybe this time
zeroshade Aug 22, 2025
dc51441
Update docs
ianmcook Aug 23, 2025
e32e72a
Fix indentation in RST
ianmcook Aug 24, 2025
59383a5
fix logic for additoinal_paths
zeroshade Aug 25, 2025
db25d63
re-run pre-commit
zeroshade Aug 25, 2025
3013e78
add #endif comments
zeroshade Aug 25, 2025
07eefc1
dedup some logic
zeroshade Aug 25, 2025
908c695
Improve comments
ianmcook Aug 25, 2025
fd8fc8b
fix ADBC_CONFIG_PATH for wchar
zeroshade Aug 27, 2025
c6f45a8
Update c/driver_manager/adbc_driver_manager.cc
zeroshade Aug 27, 2025
6dfb580
Update c/driver_manager/adbc_driver_manager.cc
zeroshade Aug 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions c/driver_manager/adbc_driver_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,31 @@ AdbcStatusCode LoadDriverManifest(const std::filesystem::path& driver_manifest,
return ADBC_STATUS_OK;
}

std::filesystem::path GetEnvAsPath(const char* env_var) {
#ifdef _WIN32
size_t required_size;

_wgetenv_s(&required_size, NULL, 0, env_var);
if (required_size == 0) {
return {};
}

std::wstring path_var;
path_var.resize(required_size);
_wgetenv_s(&required_size, path_var.data(), required_size, env_var);
return std::filesystem::path(path_var);
#else
const char* path = std::getenv(env_var);
if (path) {
std::string_view venv(path);
if (!venv.empty()) {
return std::filesystem::path(venv);
}
}
return {};
#endif
}

std::vector<std::filesystem::path> GetSearchPaths(const AdbcLoadFlags levels) {
std::vector<std::filesystem::path> paths;
if (levels & ADBC_LOAD_FLAG_SEARCH_ENV) {
Expand All @@ -281,6 +306,16 @@ std::vector<std::filesystem::path> GetSearchPaths(const AdbcLoadFlags levels) {
if (env_path) {
paths = InternalAdbcParsePath(env_path);
}

std::filesystem::path venv = GetEnvAsPath("VIRTUAL_ENV");
if (!venv.empty()) {
paths.push_back(venv / "etc" / "adbc");
}

venv = GetEnvAsPath("CONDA_PREFIX");
if (!venv.empty()) {
paths.push_back(venv / "etc" / "adbc");
}
}

if (levels & ADBC_LOAD_FLAG_SEARCH_USER) {
Expand Down
15 changes: 13 additions & 2 deletions docs/source/format/driver_manifests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,14 @@ Unix-like Platforms
For Unix-like platforms, (e.g. Linux, macOS), the driver manager will search the following directories based on the options provided, in
the given order:

#. If the ``LOAD_FLAG_SEARCH_ENV`` load option is set, then the environment variable ``ADBC_CONFIG_PATH`` will be searched
#. If the ``LOAD_FLAG_SEARCH_ENV`` load option is set, then environment variables will be searched in this order

* ``ADBC_CONFIG_PATH`` is a colon-separated list of directories to search for ``${name}.toml``
* ``VIRTUAL_ENV`` is used by `venv <https://docs.python.org/3/library/venv.html>`__ and if set
``$VIRTUAL_ENV/etc/adbc`` will be searched for ``${name}.toml``
* ``CONDA_PREFIX`` is used by `conda <https://anaconda.org/anaconda/conda>`__ when using a ``conda``
environment (by using ``conda activate env-name``), and if set then ``$CONDA_PREFIX/etc/adbc``
will be searched for ``${name}.toml``

#. If the ``LOAD_FLAG_SEARCH_USER`` load option is set, then a user-level configuration directory will be searched

Expand All @@ -452,9 +457,15 @@ Windows
Things are slightly different on Windows, where the driver manager will also search for driver information in the registry just as
would happen for ODBC drivers. The search for a manifest on Windows would be the following:

#. If the ``LOAD_FLAG_SEARCH_ENV`` load option is set, then the environment variable ``ADBC_CONFIG_PATH`` will be searched
#. If the ``LOAD_FLAG_SEARCH_ENV`` load option is set, then the environment variables will be searched in this order

* ``ADBC_CONFIG_PATH`` is a semicolon-separated list of directories to search for ``${name}.toml``
* ``VIRTUAL_ENV`` is used by `venv <https://docs.python.org/3/library/venv.html>`__ and if set
``$VIRTUAL_ENV/etc/adbc`` will be searched for ``${name}.toml``
* ``CONDA_PREFIX`` is used by `conda <https://anaconda.org/anaconda/conda>`__ when using a ``conda``
environment (by using ``conda activate env-name``), and if set then ``$CONDA_PREFIX/etc/adbc``
will be searched for ``${name}.toml``


#. If the ``LOAD_FLAG_SEARCH_USER`` load option is set, then a user-level configuration is searched for

Expand Down
35 changes: 35 additions & 0 deletions go/adbc/drivermgr/adbc_driver_manager.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions rust/driver_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,14 @@ fn get_search_paths(lvls: LoadFlags) -> Vec<PathBuf> {
result.push(p);
}
}

if let Some(path) = env::var_os("VIRTUAL_ENV") {
result.push(PathBuf::from(path).join("etc").join("adbc"));
}

if let Some(path) = env::var_os("CONDA_PREFIX") {
result.push(PathBuf::from(path).join("etc").join("adbc"));
}
}

if lvls & LOAD_FLAG_SEARCH_USER != 0 {
Expand Down Expand Up @@ -2224,4 +2232,44 @@ mod tests {
assert_eq!(search_paths, Vec::<PathBuf>::new());
}
}

#[test]
fn test_get_search_paths_env() {
let path_list = vec![
Path::new("/foo/bar/baz"),
Path::new("/majestik/møøse"),
Path::new("/super/duper"),
];
unsafe {
std::env::set_var(
"ADBC_CONFIG_PATH",
std::env::join_paths(&path_list).unwrap().as_os_str(),
);
std::env::set_var("VIRTUAL_ENV", Path::new("/home/foo/.venv").as_os_str());
std::env::set_var(
"CONDA_PREFIX",
Path::new("/home/foo/.conda/envs/hi").as_os_str(),
);
}

let search_paths = get_search_paths(LOAD_FLAG_SEARCH_ENV);
assert_eq!(
search_paths,
[
path_list,
[
Path::new("/home/foo/.venv/etc/adbc"),
Path::new("/home/foo/.conda/envs/hi/etc/adbc")
]
.to_vec()
]
.concat()
);

unsafe {
std::env::remove_var("ADBC_CONFIG_PATH");
std::env::remove_var("VIRTUAL_ENV");
std::env::remove_var("CONDA_PREFIX");
}
}
}
Loading