Skip to content
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

Support for nix-darwin #1709

Closed
G3zz opened this issue May 10, 2022 · 6 comments
Closed

Support for nix-darwin #1709

G3zz opened this issue May 10, 2022 · 6 comments

Comments

@G3zz
Copy link

G3zz commented May 10, 2022

Is your feature request related to a problem? Please describe.
It is not possible to use pymupdf installed via pip with a mupdf installed through nix-darwin without creating symlinks to mupdf outside of the nix store.

Describe the solution you'd like
The ability for setup.py on darwin to check for the existence of nix-darwin and scan the nix store for the installed mupdf binaries. I suppose this could be something as simple as using an environment variable.

Describe alternatives you've considered
It is possible to to install pymupdf through nix packages too, but this is not ideal for co-working with colleagues who do not use nix.

@julian-smith-artifex-com
Copy link
Collaborator

I don't use MacOS and i don't know what nix-darwin is, so i might be making some basic mistakes here.

PyMuPDF wheels come with MuPDF already linked in, and MacOS wheels for the latest release, PyMuPDF-1.20.0, are on pypi.org for use by pip. Are these MacOS wheels suitable for your system?

If suitable wheels are not available, pip will install by building from an sdist. As of PyMuPDF-1.20.0, the sdist will contain source for mupdf which will be built into pymupdf automatically. Does this behaviour work for you?

Finally if you install directly from a git checkout of PyMuPDF with setup.py install, it will default to download MuPDF source for building into PyMuPDF.

If you want to prevent the default use of the hard-coded mupdf, you should build with PYMUPDF_SETUP_MUPDF_BUILD set to an empty string. E.g. PYMUPDF_SETUP_MUPDF_BUILD= setup.py install. This will set some defaults for the include paths, library paths and library names, such as looking for headers in /usr/local/include, libraries in /usr/local/lib and linking with libraries called mupdf and mupdf-third; the intention here is to use a system-installed mupdf.

Currently there is no way to override these defaults. But it should be possible to add support for new environmental variables that force particular include path, library path and library names. Alternatively you could modify setup.py around line 596 include_dirs.append("/usr/local/include/mupdf") to get the behaviour you require, and these changes could be incorporated into the PyMuPDF tree in future (note that submitted patches must have a signed contributor license agreement). Please let me know whether either of these options could work for you.

@julian-smith-artifex-com
Copy link
Collaborator

Closing this because no response for 8 weeks.

@G3zz
Copy link
Author

G3zz commented Sep 14, 2022

Sorry for the delay on this - I got sidetracked with other things. Thanks very much for your reply, I tried modifying setup.py to point to the mupdf include directories, but the import fitz would complain that _jpeg_resync_to_restart was not found. It looks like a linking issue to me with libjpeg (which in Nix) is installed in a non-standard location. Presumably I need to add libjpeg to the library_dirs list?

@julian-smith-artifex-com
Copy link
Collaborator

Welcome back.

I think to make progress here, i'll need you to post the following:

  • The full output from pip install mupdfpy.
  • The diff that you have applied to PyMuPDF's setup.py.
  • The exact command you are using to build PyMuPDF.
  • The full output from your build of PyMuPDF.
  • The full output when you attempt to import mupdf from Python.

@tikitong
Copy link

tikitong commented Nov 2, 2022

Hi @julian-smith-artifex-com @G3zz, I give a solution which works for me on macOS Apple Chip (this manner works for Intel too) in #2012 . Hope it helps !

@julian-smith-artifex-com
Copy link
Collaborator

MacOS/ARM wheels have been available since PyMuPDF-1.21.0, released 2022-11-8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants