pdf2djvu icon indicating copy to clipboard operation
pdf2djvu copied to clipboard

Please port tests to Python 3

Open jelly opened this issue 5 years ago • 4 comments

Please port the tests to Python 3 since Python 2 is up for retirement in a few days https://pythonclock.org/

jelly avatar Dec 20 '19 22:12 jelly

@jwilk what's the rationale behind a "wontfix"? That you don't want to implement this, but would be up for pull requests, or that you don't want to see this being implemented at all?

The alternative is basically having no tests (which is not great) in a distribution context soon (as all major Linux distributions drop their support short or mid term).

dvzrv avatar Dec 22 '19 15:12 dvzrv

Any progress on this issue?

Biswa96 avatar Jul 28 '21 09:07 Biswa96

Given the fact that other packages like didjvu, ocrodjvu and djvusmooth, which use pure Python, share the same wontfix labels and at least for ocrodjvu there actually is an open PR without recent activity (for didjvu there is a Python 3 port as well, although no PR given the circumstances), I am going to assume that there will not really be official support for this in the near future.

From my experience with porting didjvu to Python 3, most of it should be rather straightforward - especially as in the case of pdf2djvu where only the tests are affected where every line is being executed. Nevertheless, some care has to be taken to make the tests compatible with recent Python versions (starting at Python 3.10): The nose package has been deprecated for quite some time and the code requires some custom patching with Python >= 3.10. For the didjvu part, I recently replaced the whole nose stuff with plain stdlib unittest implementations, discovery and runners.

FriedrichFroebel avatar Jul 25 '22 14:07 FriedrichFroebel

I just gave it a try and with some trial-and-error I managed to get the existing tests to work on Python 3.8. Some notes about it:

  • I have mainly used GitHub Actions for fixing, as general installation instructions are rare and it seems like I would have overwrite my local poppler distribution with a custom build including xpdf headers. I might make another personal attempt to let GitHub Actions generate a suitable static build for me. (I have never actually used pdf2djvu before.) - Edit: According to https://groups.io/g/pdf2djvu/message/123, the corresponding headers are indeed available from the Ubuntu package index.
  • There are tons of small commits, which most likely should be squashed into one if ever considered for merging.
  • I had to disable pylint as recent releases seem to emit lots of new warnings. These probably should be addressed.
  • The nose package is officially deprecated and fails with Python 3.10. Some suitable migration path has to be considered, as addressed in https://github.com/FriedrichFroebel/didjvu/issues/6 for example.
  • I assume that the migrated code will not run on Python 2 any more, although I did not test this.

If someone wants to address some of this stuff, feel free to check out my current fork at https://github.com/FriedrichFroebel/pdf2djvu (PRs are enabled).

FriedrichFroebel avatar Jul 26 '22 05:07 FriedrichFroebel