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

minilib task fails when run from paver-minilib.zip #19

Closed
pi-byteorbit opened this issue Jun 21, 2011 · 3 comments
Closed

minilib task fails when run from paver-minilib.zip #19

pi-byteorbit opened this issue Jun 21, 2011 · 3 comments
Assignees
Milestone

Comments

@pi-byteorbit
Copy link
Contributor

Problem

When Paver's minilib task runs from paver-minilib.zip instead of a full Paver install, it fails pretty badly, truncating the zip file and preventing subsequent runs.

This happens, in particular, when pavement.py extends sdist to run minilib, as in the Getting Started example:

$ python setup.py sdist
---> pavement.sdist
---> paver.misctasks.generate_setup
Write setup.py
---> paver.misctasks.minilib
Generate paver-minilib.zip


Captured Task Output:
---------------------

---> pavement.sdist
---> paver.misctasks.generate_setup
Write setup.py
---> paver.misctasks.minilib
Generate paver-minilib.zip
Traceback (most recent call last):
  File "paver-minilib.zip/paver/tasks.py", line 170, in _run_task
  File "paver-minilib.zip/paver/tasks.py", line 166, in do_task
  File "paver-minilib.zip/paver/tasks.py", line 247, in __call__
  File "paver-minilib.zip/paver/tasks.py", line 187, in _run_task
  File "paver-minilib.zip/paver/tasks.py", line 167, in do_task
  File "paver-minilib.zip/paver/misctasks.py", line 45, in minilib
  File "paver-minilib.zip/paver/easy.py", line 16, in dry
  File "paver-minilib.zip/paver/misctasks.py", line 43, in generate_zip
  File "/usr/lib/python2.7/zipfile.py", line 1031, in write
    st = os.stat(filename)
OSError: [Errno 20] Not a directory: 'paver-minilib.zip/paver/__init__.py'

$ python setup.py sdist
Traceback (most recent call last):
  File "setup.py", line 6, in <module>
    import paver.tasks
ImportError: No module named paver.tasks

$ zipinfo paver-minilib.zip 
Archive:  paver-minilib.zip
Zip file size: 22 bytes, number of entries: 0
Empty zipfile.
$

This is also the cause of the old Google Code Issue 49, and GitHub #3 / #13. The fix for #13 added a partial workaround for when setup.py can use the installed Paver instead of paver-minilib.zip, but the underlying problem still remains.

Solution

I fixed two issues that prevent this from working:

  1. minilib's generate_zip relies on direct filesystem access to read the input files. It can use pkgutil.get_data instead, which transparently supports Zip archives or any other import mechanism used by Python.
  2. generate_zip truncates paver-minilib.zip before get_data has a chance to read the input files from it. This is easy to avoid by building the new Zip file in memory, and writing it to disk only once it's complete.
@Almad
Copy link
Member

Almad commented Jun 21, 2011

Thanks for spotting this and for the awesome bug report!

If you have the patch, would you mind sending pull request? I cannot see the patch in your fork....

@pi-byteorbit
Copy link
Contributor Author

I'm a bit new to using GitHub, sorry. :)

I sent a pull request: #20

@Almad
Copy link
Member

Almad commented Jun 21, 2011

No problem, thanks for the patch!

@Almad Almad closed this as completed Jun 21, 2011
@ghost ghost assigned Almad Jul 15, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants