pypdfium2-team / pypdfium2

Python bindings to PDFium
https://pypdfium2.readthedocs.io/
425 stars 17 forks source link

pypdfium2 on S390x (ubuntu22.04) #313

Closed sandeepb2013 closed 6 months ago

sandeepb2013 commented 6 months ago

Checklist

Description

Collecting pypdfium2==0.7.0
  Downloading pypdfium2-0.7.0.tar.gz (283 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 283.0/283.0 kB 5.7 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [51 lines of output]
      Cloning into '/tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/depot_tools'...
      Checking patch gclient_scm.py...
      error: while searching for:
            # to stdout
            self.Print('')
          cfg = gclient_utils.DefaultIndexPackConfig(url)
          clone_cmd = cfg + ['clone', '--no-checkout', '--progress']
          if self.cache_dir:
            clone_cmd.append('--shared')
          if options.verbose:

      error: patch failed: gclient_scm.py:1005
      error: gclient_scm.py: patch does not apply
      Errors:
        failed to resolve infra/3pp/tools/git/linux-s390x@version:2@2.41.0.chromium.11 (line 24): no such package: infra/3pp/tools/git/linux-s390x
        failed to resolve infra/3pp/tools/cpython3/linux-s390x@version:2@3.11.8.chromium.35 (line 21): no such package: infra/3pp/tools/cpython3/linux-s390x
      /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/depot_tools/bootstrap_python3: line 32: bootstrap-2@3.11.8.chromium.35_bin/python3/bin/python3: No such file or directory
      Bundled Python 3.11 not found. Use VPYTHON_BYPASS if prebuilt cpython not available on this platform: open /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/depot_tools/.cipd_bin/.cipd/pkgs/0/Q0Cp0RrnNtgKaxaeq4XKs9qiPu1botnPjuw_0EWxduUC/3.11/.versions/cpython3.cipd_version: no such file or directory
      Errors:
        failed to resolve infra/3pp/tools/git/linux-s390x@version:2@2.41.0.chromium.11 (line 24): no such package: infra/3pp/tools/git/linux-s390x
        failed to resolve infra/3pp/tools/cpython3/linux-s390x@version:2@3.11.8.chromium.35 (line 21): no such package: infra/3pp/tools/cpython3/linux-s390x
      /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/depot_tools/bootstrap_python3: line 32: bootstrap-2@3.11.8.chromium.35_bin/python3/bin/python3: No such file or directory
      Bundled Python 3.11 not found. Use VPYTHON_BYPASS if prebuilt cpython not available on this platform: open /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/depot_tools/.cipd_bin/.cipd/pkgs/0/Q0Cp0RrnNtgKaxaeq4XKs9qiPu1botnPjuw_0EWxduUC/3.11/.versions/cpython3.cipd_version: no such file or directory
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/setup.py", line 19, in <module>
          build_pdfium.main(DefaultArgs)
        File "/tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/build_pdfium.py", line 275, in main
          patch_pdfium()
        File "/tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/build_pdfium.py", line 132, in patch_pdfium
          _apply_patchset(PdfiumPatches, PDFiumDir)
        File "/tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/build_pdfium.py", line 126, in _apply_patchset
          run_cmd(f"git apply -v {patch}", cwd=cwd)
        File "/tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/build_pdfium.py", line 75, in run_cmd
          subprocess.run(command, cwd=cwd, shell=True)
        File "/usr/lib/python3.10/subprocess.py", line 503, in run
          with Popen(*popenargs, **kwargs) as process:
        File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
          self._execute_child(args, executable, preexec_fn, close_fds,
        File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
          raise child_exception_type(errno_num, err_msg, err_filename)
      FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/pdfium'
      Using DepotTools-provided binaries.
      DepotTools: Download ...
      git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/depot_tools
      git apply -v /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/patches/gclient_scm.patch
      PDFium: Download ...
      /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/depot_tools/gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
      /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/depot_tools/gclient sync --no-history --shallow
      git apply -v /tmp/pip-install-7pg5yzok/pypdfium2_4b1a7bde13d04c959f78c22011e153e6/sourcebuild/patches/public_headers.patch
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Install Info

Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
Linux-6.6.2-s390x-with-glibc2.35
WARNING: Package(s) not found: pypdfium2

Validity

mara004 commented 6 months ago

That is expected; our binary provider doesn't currently build for S390x. But you can head over to https://github.com/bblanchon/pdfium-binaries/issues and ask the author whether he's willing to add support for S390x, then I could incorporate it in pypdfium2.

AFAIK, S390x is somewhat uncommon in the PyPI world, though. Not even pillow or pikepdf build for it. You might have more luck on Anaconda (S390x is in their default build matrix), but they don't really provide (py)pdfium, aside from a feedstock that repacks the pdfium-binaries.

Otherwise, you could try to build pdfium from source (I don't know whether Google's toolchain supports S390x as build host). But you should use a recent version of pypdfium2 for that, not 0.7.0 (who depends on that old version, I wonder?).

mara004 commented 6 months ago

Another hint: If you have libreoffice, you might be able to simply use the pdfium binary it ships with. For me that is /usr/lib/libreoffice/program/libpdfiumlo.so. Just symlink to /usr/local/lib/libpdfium.so or something, determine the pdfium version, and then install with system-provided binary.

mara004 commented 6 months ago

Regarding the failure of implicit sourcebuild, this seems to be due to outdated patches. I can see it's a bit problematic we're using latest pdfium with potentially non-latest patches.

Newer versions do not trigger an implicit sourcebuild anymore if no binary was found. I think it's better for callers to consciously invoke the build process if desired.

sandeepb2013 commented 6 months ago

Hi @mara004 ,

Thanks for quick response. https://github.com/bblanchon/pdfium-binaries/issues/93. `Possible values

mara004 commented 6 months ago

Yes, these are the architectures listed by the toolchain's help, and s390x is among them. But what do you want to express with that? Again, as for adding a binary package, you'd have to discuss that with upstream. The binaries aren't built here, just repacked with a python wrapper.

mara004 commented 6 months ago

Closing; further actions are up to affected users, pdfium-binaries and pdfium.