View Single Post
Old 10-15-2016, 01:32 AM   #1
duxxil
Junior Member
duxxil began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Oct 2016
Device: none
Cool How to update one .pyo file in pylib.zip?

I've made a little patch for calibre, importing book using hardlink instead of copy.

After runnig calibre with my source code by setting CALIBRE_DEVELOP_FROM, I got the .pyo file.
I want to use this .pyo file to update the pylib.zip in the calibre binary directory.

I've tried WinRAR and the zip in Ubuntu, but it can not run well. And also tried the setup.py script in the calibre sources, but stopped at the private QT header problems.

Does anyone know how to repack the .zip file?
I would be very grateful if anyone give me some advice.

Or if you have a good calibre develop environment, just apply my patch and build the zip for me.

Code:
     
    import book using hardlink instead of copy

diff --git a/src/calibre/db/backend.py b/src/calibre/db/backend.py
index 357f690..463f690 100644
--- a/src/calibre/db/backend.py
+++ b/src/calibre/db/backend.py
@@ -1493,11 +1493,9 @@ class DB(object):
                         traceback.print_exc()
 
         if (not getattr(stream, 'name', False) or not samefile(dest, stream.name)):
-            with lopen(dest, 'wb') as f:
-                shutil.copyfileobj(stream, f)
-                size = f.tell()
-            if mtime is not None:
-                os.utime(dest, (mtime, mtime))
+            hardlink_file(stream.name, dest)
+            stream.seek(0, os.SEEK_END)
+            size = stream.tell()
         elif os.path.exists(dest):
             size = os.path.getsize(dest)
             if mtime is not None:
Someone had already talked about a similar question.
Make calibre installer for Window

Last edited by duxxil; 10-15-2016 at 01:36 AM.
duxxil is offline   Reply With Quote