Register Guidelines E-Books Search Today's Posts Mark Forums Read

 MobileRead Forums Attn plugin devs: porting to python 3

 12-19-2019, 04:17 PM #61 jackie_w Grand Sorcerer   Posts: 5,615 Karma: 14222222 Join Date: Sep 2009 Location: UK Device: Kobo: H2O, GloHD, KA1, ClaraHD, Forma @GitHub gurus, I need some help please. Windows 10 64bit user. I've tested my plugins for Python3 compatibility as well as I can in the 4.99.2 beta of calibre portable. However one of them does require that I also test it in a Win64 environment. For reasons best known to Microsoft, the MS SAPI functions for text-to-speech don't seem to work the same in Win32 and Win64. To do this I'd like to create a complete new copy of Python3 run from source calibre which doesn't interfere with my normal Python2 run from source calibre. (in case it's relevant, I only ever use run from source as a convenient way of quickly testing not-yet-released features or for having access to python code.) My knowledge and experience of GitHub cloning/pulling is limited to what I read in the calibre user manual "Getting the code", namely, from a CMD window: To clone: Code: "C:\Program Files\Git\cmd\git" clone git://github.com/kovidgoyal/calibre.git To pull: Code: "C:\Program Files\Git\cmd\git" pull --no-edit I read Kovid's post #1 but do not see anything in the above 2 lines that I can change from 'master' to 'py3'. Please can you tell me what I need to change to do what's required? Last edited by jackie_w; 12-19-2019 at 04:20 PM.
 12-19-2019, 05:46 PM #62 DaltonST Deviser     Posts: 1,794 Karma: 428332 Join Date: Aug 2013 Location: Texas Device: 10" Win10 Tablet w/Calibre64, CalibreSpy & Freda+ I always just go to Github for Kovid, go to Calibre, select the Branch of 'py3' (not the default Branch of 'master'), and download the code as a Zip file. DaltonST Last edited by DaltonST; 12-19-2019 at 05:48 PM.
12-19-2019, 05:50 PM   #63
jackie_w
Grand Sorcerer

Posts: 5,615
Karma: 14222222
Join Date: Sep 2009
Location: UK
Device: Kobo: H2O, GloHD, KA1, ClaraHD, Forma
Quote:
 Originally Posted by DaltonST I always just go to Github for Kovid, go to Calibre, select the Tag of 'py3' (not the default Tag of 'master'), and download the code as a Zip file.
Thank you for replying. But would I be able to keep any changed files up-to-date with some sort of PULL if I did this?

 12-19-2019, 05:58 PM #64 DaltonST Deviser     Posts: 1,794 Karma: 428332 Join Date: Aug 2013 Location: Texas Device: 10" Win10 Tablet w/Calibre64, CalibreSpy & Freda+ No, the indicated method is non-Github. To get new files, have to repeat the Zip download.
12-19-2019, 06:21 PM   #65
thiago.eec
Evangelist

Posts: 406
Karma: 155004
Join Date: Dec 2016
Location: Goiânia - Brazil
Quote:
 Originally Posted by jackie_w I read Kovid's post #1 but do not see anything in the above 2 lines that I can change from 'master' to 'py3'. Please can you tell me what I need to change to do what's required?
I use Github Desktop. Its a GUI interface for the most common uses for Git. With it you can change branches just with 2 clicks.

 12-19-2019, 06:48 PM #66 eschwartz Ex-Helpdesk Junkie     Posts: 19,396 Karma: 84711550 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) @jackie_w, Use the command: Code: git checkout py3 to switch to the "py3" branch. Since you don't have a personal branch with that name, it will find it from the remote server instead. You can then switch between checking out master and py3 by repeating the "git checkout" command. ... Github desktop is a very good idea to use if you're not familiar with git.
12-19-2019, 07:07 PM   #67
jackie_w
Grand Sorcerer

Posts: 5,615
Karma: 14222222
Join Date: Sep 2009
Location: UK
Device: Kobo: H2O, GloHD, KA1, ClaraHD, Forma
Quote:
 Originally Posted by eschwartz @jackie_w, Use the command: Code: git checkout py3 to switch to the "py3" branch. Since you don't have a personal branch with that name, it will find it from the remote server instead. You can then switch between checking out master and py3 by repeating the "git checkout" command. ... Github desktop is a very good idea to use if you're not familiar with git.
Guys, I know you're trying to help and I truly appreciate it, but I'm going to need more detail.

@eschwartz, Switch to it where? In the .bat file which I double-click when I want to run from source? If so, it currently contains 2 lines:
Code:
set CALIBRE_DEVELOP_FROM=D:\JS_git_devel\cal\src
"c:\program files\calibre2\calibre.exe"
Are you just suggesting I add the following line between the other 2 lines?
Code:
"C:\Program Files\Git\cmd\git" checkout py3
... or something else entirely?

 12-19-2019, 07:14 PM #68 JimmXinu Plugin Developer     Posts: 4,392 Karma: 653916 Join Date: Dec 2011 Location: Midwest USA Device: Kindle Voyage Has there been any discussion yet about volunteers for the orphan plugins? It would be nice to both avoid duplicating work and cover the common ones. In addition to my own plugins, I've already posted py3 test versions for a couple and plan to do a few more, since I use them and did the pyqt5 migration for them. Test version posted in thread:FanFicFare EpubMerge EpubSplit SmartEject Favourites Menu* View Manager* Manage Series* Reading List* Generate Cover* * 'orphan' plugins, IE, not mine. Last edited by JimmXinu; 12-20-2019 at 01:28 PM. Reason: Update list
12-19-2019, 08:21 PM   #69
eschwartz
Ex-Helpdesk Junkie

Posts: 19,396
Karma: 84711550
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
 Originally Posted by jackie_w Guys, I know you're trying to help and I truly appreciate it, but I'm going to need more detail. @eschwartz, Switch to it where? In the .bat file which I double-click when I want to run from source? If so, it currently contains 2 lines:
No, you do it right after you clone.

Code:
# download the calibre project
git clone https://github.com/kovidgoyal/calibre

# make sure you're actually using the correct version of the project by
# changing all the files to point to the right development branch
git checkout py3

## profit

# run calibre
calibre.bat

# this will also update the files on disk according to your currently
# configured branch
git pull --no-edit
Do not continue to run "git checkout py3". If you do, you'll get a status message:

and nothing will happen. It's a total waste of time.

...

To give you a non-git analogy...

git clone is like downloading a zip file and extracting it into a new folder "myproject", then creating a new folder called "current", which is a directory link to a hidden folder called "myproject/.hidden/available-versions/master". You always access the project using "current", though.
RELEVANT: when you git clone, there is an implied "git checkout master", that is run automatically by git, as part of the cloning process. This is what set your initial version to use.

git pull is like downloading a new copy of the zip file, nuking the "myproject" folder, and re-extracting.
(git checkout is *not* implicitly run here. In the analogy of the "current" link, your link still exists, and does not need changing.)

git checkout py3 is like changing the directory link for "current", to "myproject/.hidden/available-versions/py3", and future git pulls will continue to nuke myproject, update all the .hidden/available-versions/, and leave the "current" directory link intact, still pointing to your preferred version.

 12-19-2019, 09:10 PM #70 kovidgoyal creator of calibre     Posts: 38,002 Karma: 16793211 Join Date: Oct 2006 Location: Mumbai, India Device: Various @JimmXinu: That traceback is caused precisely by the code to preserve the clipboard contents on exit, https://bugreports.qt.io/browse/QTBUG-41125 and is now fixed.
12-20-2019, 12:04 AM   #71
davidfor
Grand Sorcerer

Posts: 20,269
Karma: 33549158
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
 Originally Posted by jackie_w Guys, I know you're trying to help and I truly appreciate it, but I'm going to need more detail. @eschwartz, Switch to it where? In the .bat file which I double-click when I want to run from source? If so, it currently contains 2 lines: Code: set CALIBRE_DEVELOP_FROM=D:\JS_git_devel\cal\src "c:\program files\calibre2\calibre.exe" Are you just suggesting I add the following line between the other 2 lines? Code: "C:\Program Files\Git\cmd\git" checkout py3 ... or something else entirely?
The git commands given are to swap between branches. What they are saying is to decide which branch you need and then run the command to update your local repository to that branch. Then you do what you are doing above, except you also need to make sure the calibre binaries match the branch.

What you might want to do is do the checkout for each branch in different directories. Then you can have a startup script that sets CALIBRE_DEVELOP_FROM to the appropriate directory and runs the correct binary. That should work to run the beta version of the portable install, but, I haven't tried it yet.

12-20-2019, 10:16 AM   #72
jackie_w
Grand Sorcerer

Posts: 5,615
Karma: 14222222
Join Date: Sep 2009
Location: UK
Device: Kobo: H2O, GloHD, KA1, ClaraHD, Forma
Quote:
 Originally Posted by davidfor What you might want to do is do the checkout for each branch in different directories. Then you can have a startup script that sets CALIBRE_DEVELOP_FROM to the appropriate directory and runs the correct binary. That should work to run the beta version of the portable install, but, I haven't tried it yet.
I've done the GitHub stuff (thanks @eschwartz). My first mistake after that was not realising that I then needed to run a 4.99.2 beta version of calibre.exe. I can point at the one in beta calibre portable. It runs OK but it doesn't move me forward testing my awkward plugin which has always worked slightly differently in Win32 and Win64 environments.

Running a calibre portable 4.99.2 executable just runs my Win64 PC in Win32 mode, so I still can't test what I need to.

Is there any way, other than installing the Win64 4.99.2 beta over the top of my Win64 4.6 production version, to get these Win64 tests done? Obviously I'm not eager to mess up my production setup.

 12-20-2019, 10:41 AM #73 eschwartz Ex-Helpdesk Junkie     Posts: 19,396 Karma: 84711550 Join Date: Nov 2012 Location: The Beaten Path, USA, Roundworld, This Side of Infinity Device: Kindle Touch fw5.3.7 (Wifi only) There is probably a way to tell the MSI installer service to simply extract the contents of the installer, rather than actually putting it in "C:\Program Files\". If you cannot figure out how to do that, another thing that should work is simply copying the "C:\Program Files\Calibre2\" directory to "C:\Users\Jackie_w\My Documents\", then installing the beta. Run the production version from wherever you copied it to, run the beta by default. Or install the beta, copy that to a secondary location, and then reinstall the production version.
 12-20-2019, 10:54 AM #74 kovidgoyal creator of calibre     Posts: 38,002 Karma: 16793211 Join Date: Oct 2006 Location: Mumbai, India Device: Various Install the beta, copy c:\program files\calibre2 to somewhere else. Uninstall the beta. Install regular calibre. Now run the beta from wherever you copied it.
12-20-2019, 10:57 AM   #75
jackie_w
Grand Sorcerer

Posts: 5,615
Karma: 14222222
Join Date: Sep 2009
Location: UK
Device: Kobo: H2O, GloHD, KA1, ClaraHD, Forma
Quote:
 Originally Posted by eschwartz There is probably a way to tell the MSI installer service to simply extract the contents of the installer, rather than actually putting it in "C:\Program Files\". If you cannot figure out how to do that, another thing that should work is simply copying the "C:\Program Files\Calibre2\" directory to "C:\Users\Jackie_w\My Documents\", then installing the beta. Run the production version from wherever you copied it to, run the beta by default. Or install the beta, copy that to a secondary location, and then reinstall the production version.
What about if I install a new Win32 4.6 production version and then a Win64 4.99.2 beta version over the top of my Win64 4.6 production? They would be sharing the same config directory. Will that trash my config?

Last edited by jackie_w; 12-20-2019 at 11:02 AM.