![]() |
#1 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,253
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Fixing python zipimport issues on Windows
There have been several bugs since 5 was released, of the form of imports failing. Either at calibre startup, or during metadata download or with some plugins. I have traced them all down to the zipimport module in python 3 being buggy when importing from multiple threads. On Windows all python code in calibre is placed in a single zip file for performance reasons.
So to fix it, I ended up writing my own replacement for zipimport, which doesn't use a zip file, but instead a single memory-mapped file containing all the python modules, from which individual modules can be imported using a single hash lookup via a perfect hash function generated at build time. This is pretty much the fastest possible implementation for python importing, faster than zipimport and faster than normal filesystem based importing. And it does not rely on the broken zipimport. It was quite a journey into Python's internals to get this working, but as of now I cannot replicate any of the reported import bugs on Windows, or any other platform. This is quite a lot of new code, in a deep, dark place, so I would appreciate a bit more testing from you. If you are using CALIBRE_DEVELOP_FROM please try with it unset as well, as when it is set the importing happens from the source code rather than the new frozen importer. The builds using the new importing framework are available as calibre 5.1.1 at: https://download.calibre-ebook.com/betas/ |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,365
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
It works on Windows 10/64. Things I did, chosen to try to stress importing:
Are there other tests I can do that will stress it? |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
As a start, have tried the portable version. The Kobo/Kepub plugins are all loading with this version. Though I haven't loaded anything else yet.
|
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,253
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Using a copy of my configuration directory, three plugins didn't load. They were Databazeknih, Overdrive Link and Embed Comic Metadata. When I tried to install Overdrive Link, I got this error:
Code:
calibre, version 5.1.1 ERROR: Install plugin failed: A problem occurred while installing this plugin. This plugin will now be uninstalled. Please post the error message in details below into the forum thread for this plugin and restart calibre. Traceback (most recent call last): File "calibre\gui2\dialogs\plugin_updater.py", line 731, in _install_clicked File "calibre\customize\ui.py", line 472, in add_plugin File "calibre\customize\ui.py", line 61, in load_plugin File "calibre\customize\zipplugin.py", line 279, in load File "importlib\__init__.py", line 127, in import_module File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "calibre\customize\zipplugin.py", line 171, in exec_module File "calibre\customize\zipplugin.py", line 167, in get_code File "calibre_plugins.overdrive_link.__init__", line 1 #!/usr/bin/env python ^ SyntaxError: invalid character in identifier |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,253
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That's the UTF-8 BOM. I should have the plugin loader strip that. https://github.com/kovidgoyal/calibr...51d0aa2c8622b5
Quote:
|
|
![]() |
![]() |
![]() |
#7 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,253
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
In fact, this is better: https://github.com/kovidgoyal/calibr...e7fe6ea3bf7d42
|
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,253
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Released 5.1.2 with fixes for the issue with UTF-8 BOM and some plugins reported by davidfor and another issue I discovered where using CALIBRE_DEVELOP_FROM was not working with the content server
|
![]() |
![]() |
![]() |
#9 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,251
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
![]() If it's meant to be the latter then my currently installed calibre v5.0.1 64-bit is only offering "Update found:5.1.0" in the statusbar. |
|
![]() |
![]() |
![]() |
#10 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,610
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Deltas never appear in the statusbar.
|
![]() |
![]() |
![]() |
#11 |
Diligent dilettante
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,661
Karma: 52758936
Join Date: Sep 2019
Location: in my mind
Device: Kobo Sage; Kobo Libra Colour
|
|
![]() |
![]() |
![]() |
#12 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,439
Karma: 168808777
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
|
|
![]() |
![]() |
![]() |
#13 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,253
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Apologies fo rthe confusion, by released I meant released a beta: https://download.calibre-ebook.com/betas/
I want some people running it for a few days before I make a general release as the changes are quite extensive internally. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
KTerm & Python Issues | aBP | Kindle Developer's Corner | 4 | 02-10-2016 05:23 PM |
how to use python script with windows xp | tuufbiz1 | Other formats | 12 | 01-08-2011 08:22 AM |
Python 261 In Windows Problems | jwsheets | Kindle Formats | 3 | 08-14-2009 09:08 AM |
using python with windows xp | tuufbiz1 | Kindle Formats | 10 | 05-05-2009 11:53 PM |
GUI Frontend for python scripts [windows] - seeking mod input first | sherman | Workshop | 7 | 04-27-2009 01:04 AM |