Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-11-2022, 01:57 AM   #1
mwgabby-li
Junior Member
mwgabby-li began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Jul 2020
Device: reMarkable v1
Let Calibre Use Locally Built Version of Dependency on Windows?

I wanted to test Calibre with some modifications to the css-parser library. What's the simplest way to have it use a version I have modified locally?

Bonus points if it can use the css-parser source tree directly, though I don't mind running the css-parser installer after modifying it.
mwgabby-li is offline   Reply With Quote
Old 04-11-2022, 02:03 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Just prepend the path to it to sys.path before it is imported.
kovidgoyal is offline   Reply With Quote
Advert
Old 04-15-2022, 01:04 AM   #3
mwgabby-li
Junior Member
mwgabby-li began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Jul 2020
Device: reMarkable v1
Thanks - that was part of the solution, but it wasn't working with just that. Just in case someone else needs to get this working, turns out I also had to modify sys.meta_path.

This is what I saw it as when Calibre is running. I guess the third entry in that list causes it to prioritize the built-in "frozen" libraries?:
Code:
sys.meta_path: [
<calibre.constants.DeVendor object at 0x000002128A2AA3A0>,
<__main__.PydImporter object at 0x000002128A22C310>,
BypyFrozenImporter with data in C:\Program Files\Calibre2\app\bin,
<class '_frozen_importlib.BuiltinImporter'>,
<class '_frozen_importlib.FrozenImporter'>,
<class '_frozen_importlib_external.PathFinder'>,
<calibre.constants.ExtensionsImporter object at 0x000002128A2B11F0>
]
To get it working quickly, in addition to modifying sys.path to have css-parser/src listed first before all imports using that module, I just did this in constants.py after the DeVendor() and ExtensionsImporter() are added:
Code:
sys.meta_path.insert(0, sys.meta_path[5])
I daresay there's probably a more elegant solution to this, but there you are.
mwgabby-li is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
From version 5 on, Calibre won't start on windows 10 mhguda Calibre 17 12-29-2020 05:22 AM
Creating recipes that have same cover page as Calibre built in version duluoz Recipes 1 09-20-2020 10:05 PM
Calibre: Difference between Windows & Mac Version? Inukami Calibre 8 02-14-2018 08:53 AM
New: 64 Bit Version of Calibre for Windows country0129 Calibre 3 12-07-2012 12:48 PM
Windows 7 New Calibre Version problem Pandzilla Calibre 8 10-03-2010 02:15 PM


All times are GMT -4. The time now is 05:09 AM.


MobileRead.com is a privately owned, operated and funded community.