You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jorisvandenbossche (via GitHub)" <gi...@apache.org> on 2023/01/24 10:48:19 UTC
[GitHub] [arrow-adbc] jorisvandenbossche commented on a diff in pull request #375: chore(ci): add Conda package build support
jorisvandenbossche commented on code in PR #375:
URL: https://github.com/apache/arrow-adbc/pull/375#discussion_r1085108331
##########
python/adbc_driver_flightsql/adbc_driver_flightsql/__init__.py:
##########
@@ -38,8 +39,22 @@ def connect(
db_kwargs : dict, optional
Initial database connection parameters.
"""
- root = importlib.resources.files(__package__)
- entrypoint = root.joinpath("libadbc_driver_flightsql.so")
return adbc_driver_manager.AdbcDatabase(
- driver=str(entrypoint), uri=uri, **(db_kwargs or {})
+ driver=_driver_path(), uri=uri, **(db_kwargs or {})
)
+
+
+@functools.cache
+def _driver_path() -> str:
+ root = importlib.resources.files(__package__)
+ entrypoint = root.joinpath("libadbc_driver_flightsql.so")
+ if entrypoint.is_file():
+ return str(entrypoint)
+ is_conda = root.joinpath(".is_conda")
+ if is_conda.is_file():
+ with is_conda.open() as source:
+ return source.read().strip()
+ raise RuntimeError(f"Could not find driver, was {__package__} properly installed?")
Review Comment:
Should we try to make this less conda-specific? I would assume also other package managers will want to do the same as conda (it's actually wheels that's the special case here, I suppose we will only need to look into the package itself in case of wheels?)
The logic that I have (seen) used in other packages with vendored data/libs in wheels: check if the vendored lib file exists, if so use that, otherwise search in a standard location based on sys.prefix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org