stlehmann / pdftools

small collection of python scripts for pdf manipulation
MIT License
93 stars 19 forks source link

PyPDF2 dependency error #18

Open sjvrijn opened 1 year ago

sjvrijn commented 1 year ago

pdftools currently errors for me when I did a fresh install with pipx and wanted to split some files:

$ pdftools split some_file.pdf -q 12 9
Traceback (most recent call last):
  File "~/.local/bin/pdftools", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/pdftools/_cli.py", line 286, in main
    pdf_split(ARGS.src, ARGS.output, ARGS.stepsize, ARGS.sequence)
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/pdftools/pdftools.py", line 157, in pdf_split
    reader = PdfFileReader(inputfile)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/PyPDF2/_reader.py", line 1974, in __init__
    deprecation_with_replacement("PdfFileReader", "PdfReader", "3.0.0")
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/PyPDF2/_utils.py", line 369, in deprecation_with_replacement
    deprecation(DEPR_MSG_HAPPENED.format(old_name, removed_in, new_name))
  File "~/.local/pipx/venvs/pdftools/lib/python3.11/site-packages/PyPDF2/_utils.py", line 351, in deprecation
    raise DeprecationError(msg)
PyPDF2.errors.DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead.

This seems related to #17, because while requirements.txt pins PyPDF2 to version 1.25.1, setup.py only lists install_requires=["PyPdf2"],

Are there any plans to update this package to the new usage? Otherwise the simple fix would be to pin the version of PyPDF2 in setup.py,

Manually reinstalling in a fresh environment with the pinned PyPDF2 version still works:

$ pip install pdftools PyPDF2==1.25.1
Collecting pdftools
  Using cached pdftools-2.0.2-py3-none-any.whl
Collecting PyPDF2==1.25.1
  Downloading PyPDF2-1.25.1.tar.gz (194 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 194.2/194.2 kB 3.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Installing collected packages: PyPDF2, pdftools
  DEPRECATION: PyPDF2 is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for PyPDF2 ... done
Successfully installed PyPDF2-1.25.1 pdftools-2.0.2
$ pdftools split some_file.pdf -q 12 9 # Success