You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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.
The text was updated successfully, but these errors were encountered:
Problem
When Paver's
minilib
task runs frompaver-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
extendssdist
to runminilib
, as in the Getting Started example: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 ofpaver-minilib.zip
, but the underlying problem still remains.Solution
I fixed two issues that prevent this from working:
minilib
'sgenerate_zip
relies on direct filesystem access to read the input files. It can usepkgutil.get_data
instead, which transparently supports Zip archives or any other import mechanism used by Python.generate_zip
truncatespaver-minilib.zip
beforeget_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.The text was updated successfully, but these errors were encountered: