-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug/Feature]: a way to disable Ghostscript requirement & broken plugin_manager option #1379
Comments
It seems that the simplest fix would be to add |
Or alternatively, a |
It should work without source changes if you do plugin_manager = get_plugin_manager(plugins=['ocrmypdf.builtin_plugins.concurrency', ... all builtins except ocrmypdf.builtin_plugins.ghostscript..., 'yourcustomghostscriptreplacer'], builtins=False) yourcustomghostscriptreplacer.py would need to To convince yourself that this works, clone the source and rewrite builtins_plugins/ghostscript.py to use your PDF renderer instead of Ghostscript. The reason fora this is that the builtin ghostscript plugin hooks check_options and tests for the existence of the |
How do you get around the |
Also, am I correct that use_threads=False does not affect rasterize_pdf_page? (That's the impression I get from local tests, and from looking at the code, just wanted to confirm) And there's no way to easily re-use existing Executor logic for this? Context: using pdfium for rendering, which is explicitly not thread-safe. Trying to see if there's a better approach than having a global |
If a plugin can't run under some configuration (including the setting of use_threads) it should hook check_options and raise an exception to say "plugin can't do that". Long term I am considering converting ocrmypdf to rust, although I can't promise any kind of timeline, but moving to rust would mean being able to include libraries like pdfium with safe concurrency. |
Thank you. With regards to the On I thought the comment about "in the case of process the lock is just never contested" above suggested otherwise, though I may be wrong. |
It seems something overrides use_threads. I.e. I'm aware use_threads gets overridden in info.py, but those conditions don't seem to apply. ( I'll try to run it in a debugger when I get a moment, just wanted to post an update. |
The plugin manager error isn't an error. It's misuse of my admittedly underdocumented spec. You can just call It is true that in some cases, the directive to use_threads is overridden in certain cases (info.py), but that's a local decision. |
use_threadsHad a deeper look,
But for
Am I correct that there is currently no way to set disabling the ghostscript check
In that case, am I correct that there is no way to remove the ghostscript plugin, and hence no way to remove the ghostscript requirement? Even if you're not using ghostscript for anything? |
(Happy to make a pr for both of those, if you're open to changing the logic) |
You can use For ghostscript, compare how the test suite replaces ghostscript with test stubs. It is definitely replaceable. |
What were you trying to do?
I made a plugin that overrides rasterize_pdf_page and generate_pdfa, and it works great. However, when I try to remove ghostscript from the system, ocrmypdf tells me
No such file or directory: 'gs'
when validating hooks.Seeing that ghostscript.py is included into default plugins, I tried using
plugin_manager
option withbuiltins=False
instead:plugin_manager=get_plugin_manager(plugins=[my_plugin_path], builtins=False)
. Now it fails onoptions = create_options(
step, because plugin_manager object is not a number, string or path. Am I correct thatplugin_manager
option is no longer functional?Sorry about the 2-in-1 issue, they're quite connected in this case.
Where are you installing/running from?
PyPI (pip, poetry, pipx, etc.)
OCRmyPDF version
15.4.3
What operating system are you working on?
Linux
Operating system details and version
Ubuntu 20.04
Simple sanity checks
Relevant log output
No response
The text was updated successfully, but these errors were encountered: