-
-
Notifications
You must be signed in to change notification settings - Fork 122
Add paths for homebrew on Apple silicon #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #531 +/- ##
==========================================
+ Coverage 96.25% 96.29% +0.03%
==========================================
Files 6 6
Lines 2671 2671
==========================================
+ Hits 2571 2572 +1
+ Misses 100 99 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. โ View full report in Codecov by Sentry. |
| # load spatialite from expected locations and initialize metadata | ||
| if init_spatialite: | ||
| db.init_spatialite() | ||
| db.init_spatialite(find_spatialite() or load_extension) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this pattern.
The init_spatialite() function already calls find_spatialite() if necessary:
sqlite-utils/sqlite_utils/db.py
Lines 1161 to 1165 in fc221f9
| if path is None: | |
| path = find_spatialite() | |
| self.conn.enable_load_extension(True) | |
| self.conn.load_extension(path) |
The load_extension option is a bit different: It's actually a list of extensions passed using --load-extension path on the command-line, which is used by this code:
sqlite-utils/sqlite_utils/cli.py
Lines 3037 to 3047 in fc221f9
| def _load_extensions(db, load_extension): | |
| if load_extension: | |
| db.conn.enable_load_extension(True) | |
| for ext in load_extension: | |
| if ext == "spatialite" and not os.path.exists(ext): | |
| ext = find_spatialite() | |
| if ":" in ext: | |
| path, _, entrypoint = ext.partition(":") | |
| db.conn.execute("SELECT load_extension(?, ?)", [path, entrypoint]) | |
| else: | |
| db.conn.load_extension(ext) |
|
Aah, I think I see why you wrote it like that. The problem is that sqlite-utils/sqlite_utils/db.py Lines 1161 to 1171 in fc221f9
So it needs to be able to load the SpatiaLite extension from the correct place, and THEN run So the problem you're trying to solve here is to let people optionally pass in the path to SpatiaLite if it's not one of the ones that are searched by default. |
|
Exactly, that's what I was running into. On my M2 MacBook, SpatiaLite ends up in what is -- for the moment -- a non-standard location, so even when I passed in the location with What I learned doing this originally is that SQLite needs to load the extension for each connection, even if all the SpatiaLite stuff is already in the database. So that's why Here's the code where I hit the error: https://github.com/eyeseast/boston-parcels/blob/main/Makefile#L30 It works using this branch. I'm not attached to this solution if you can think of something better. And I'm not sure, TBH, my test would actually catch what I'm after here. |
|
I'm going to close this in favor of #536. Will try a cleaner approach to custom paths once that one is merge. |
This also passes in the extension path when specified in GIS methods. Wherever we know an extension path, we use
db.init_spatialite(find_spatialite() or load_extension).๐ Documentation preview ๐: https://sqlite-utils--531.org.readthedocs.build/en/531/