metaist / pdfmerge

Command-line utility for merging, splicing, and rotating PDF documents.
http://metaist.github.io/pdfmerge/
Other
121 stars 24 forks source link

pip install dependencies #10

Closed patricktokeeffe closed 10 years ago

patricktokeeffe commented 10 years ago

I experienced some hang-ups installing pdfmerge on a win32 XP box with 2.7 (winpython 2.7.6.2). Initially it was a pyPdf dependency (fixed in #7?):

Z:\Desktop>pip install pdfmerge
Downloading/unpacking pdfmerge
  Downloading pdfmerge-0.0.3.zip
  Running setup.py egg_info for package pdfmerge
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "c:\docume~1\pokeeffe.cee\locals~1\temp\pip_build_pokeeffe\pdfmerge\setup.py", line 7, in <module>
        import pdfmerge
      File "pdfmerge.py", line 14, in <module>
        from pyPdf import PdfFileWriter, PdfFileReader
    ImportError: No module named pyPdf
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "c:\docume~1\pokeeffe.cee\locals~1\temp\pip_build_pokeeffe\pdfmerge\setup.py", line 7, in <module>

    import pdfmerge

  File "pdfmerge.py", line 14, in <module>

    from pyPdf import PdfFileWriter, PdfFileReader

ImportError: No module named pyPdf

After manually running pip install pyPdf it got hung up on py2exe and that module wasn't found by pip:

Z:\Desktop>pip install pdfmerge
Downloading/unpacking pdfmerge
  Downloading pdfmerge-0.0.3.zip
  Running setup.py egg_info for package pdfmerge
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "c:\docume~1\pokeeffe.cee\locals~1\temp\pip_build_pokeeffe\pdfmerge\setup.py", line 45, in <module>
        import py2exe
    ImportError: No module named py2exe
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "c:\docume~1\pokeeffe.cee\locals~1\temp\pip_build_pokeeffe\pdfmerge\setup.py", line 45, in <module>

    import py2exe

ImportError: No module named py2exe

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in c:\docume~1\pokeeffe.cee\locals~1\temp\pip_build_pokeeffe\pdfmerge
Storing complete log in Z:\pip\pip.log

Z:\Desktop>pip install py2exe
Downloading/unpacking py2exe
  Could not find any downloads that satisfy the requirement py2exe
Cleaning up...
No distributions at all found for py2exe
Storing complete log in Z:\pip\pip.log

Failed with easy_install too:

Z:\Desktop>easy_install pdfmerge
Searching for pdfmerge
Reading https://pypi.python.org/simple/pdfmerge/
Best match: pdfmerge 0.0.3
Downloading https://pypi.python.org/packages/source/p/pdfmerge/pdfmerge-0.0.3.zip#md5=8992564d56e3afd87792f25d73218433
Processing pdfmerge-0.0.3.zip
Writing c:\docume~1\pokeeffe.cee\locals~1\temp\easy_install-scn6eh\pdfmerge-0.0.3\setup.cfg
Running pdfmerge-0.0.3\setup.py -q bdist_egg --dist-dir c:\docume~1\pokeeffe.cee\locals~1\temp\easy_install-scn6eh\pdfmerge-0.0.3\egg-dist-t
mp-j7y_oi
Traceback (most recent call last):
     ...
    <snip>
     ...
  File "setup.py", line 45, in <module>
    version = open('VERSION').read().strip()
ImportError: No module named py2exe

Z:\Desktop>easy_install py2exe
Searching for py2exe
Reading https://pypi.python.org/simple/py2exe/
Reading http://sourceforge.net/project/showfiles.php?group_id=15583
Reading http://starship.python.net/crew/theller/py2exe/
Reading http://www.py2exe.org/
No local packages or download links found for py2exe
error: Could not find suitable distribution for Requirement.parse('py2exe')

After downloading py2exe from the sourceforge page http://sourceforge.net/projects/py2exe and installing it, I was able to successfully install pdfmerge via pip.

It would be nice to have this dependency resolved automatically but I don't expect that to be easy since neither pip nor easy_install could find py2exe. How about an explicit check during setup with an error message pointing to the sourceforge project page?

patricktokeeffe commented 10 years ago

I see that requirements.txt does mention py2exe but it needs to be uncommented on Windows machines. It is not mentioned in setup.py. Is it pythonic enough to do something like:

OPTS = {
      ...
    'install_requires': ['pyPdf', 'py2exe'] if sys.platform.startswith('win') else ['pyPdf'],
      ...
}
metaist commented 10 years ago

I should really read in all the dependencies from requirements.txt into setup.py and make py2exe conditional like you showed.