[Python-Dev] PEP 376 and PEP 302 - allowing import hooks to provide distribution metadata

Paul Moore p.f.moore at gmail.com
Sat Jul 4 14:48:13 CEST 2009


2009/7/3 Tarek Ziadé <ziade.tarek at gmail.com>:
> You can give me a bitbucket account so I can give you write access to the repo,
> There are tests as long as you install Nose.

How do I get the tests to work? Just running nosetests gives an error
(probably because pkgutil is being imported from the stdlib, rather
than from this directory).

If I set PYTHONPATH=. then I get errors. I suspect path normalisation
(for backslashes) in the zipfile handling.

Yes, it appears to be caused by the fact that Distribution uses
os.path.join to construct self.pkg_info_path (and self.record_path)
and yet zipfiles expect '/' separated pathnames.

Paul.

Error log:

>\Apps\Python26\Scripts\nosetests-2.6.exe -v
test_pkgutil.test_distributions ... ok
test_pkgutil.test_distribution ... FAIL
test_pkgutil.test_directory ... ok
test_pkgutil.test_get_file_users ... ok
test_pkgutil.test_egginfo_dirname ... ok
test_pkgutil.test_zipped_directory ... ERROR
test_pkgutil.test_zipped_distribution ... ERROR

======================================================================
ERROR: test_pkgutil.test_zipped_directory
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Apps\Python26\Lib\site-packages\nose\case.py", line 183, in runTest
    self.test(*self.arg)
  File "C:\Users\Gustav\Data\pep376\test_pkgutil.py", line 80, in
test_zipped_directory
    dir = ZippedDistributionDir(SITE_PKG+'.zip')
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 324, in __init__
    self.add(ZippedDistribution(self._zip_file, paths[0]))
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 259, in __init__
    super(ZippedDistribution, self).__init__(path)
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 154, in __init__
    pkginfo = self._open_pkginfo()
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 264, in _open_pkginfo
    return self.zipfile.open(self.pkg_info_path)
  File "C:\Apps\Python26\lib\zipfile.py", line 859, in open
    zinfo = self.getinfo(name)
  File "C:\Apps\Python26\lib\zipfile.py", line 826, in getinfo
    'There is no item named %r in the archive' % name)
KeyError: "There is no item named
'mercurial-1.0.1.egg-info\\\\PKG-INFO' in the archive"

======================================================================
ERROR: test_pkgutil.test_zipped_distribution
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Apps\Python26\Lib\site-packages\nose\case.py", line 253, in setUp
    try_run(self.test, names)
  File "C:\Apps\Python26\Lib\site-packages\nose\util.py", line 487, in try_run
    return func()
  File "C:\Users\Gustav\Data\pep376\test_pkgutil.py", line 90, in setup_zip
    pkgutil._dist_dirs.load(SITE_PKG+'.zip')
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 380, in load
    dist_dir = ZippedDistributionDir(path)
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 324, in __init__
    self.add(ZippedDistribution(self._zip_file, paths[0]))
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 259, in __init__
    super(ZippedDistribution, self).__init__(path)
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 154, in __init__
    pkginfo = self._open_pkginfo()
  File "C:\Users\Gustav\Data\pep376\pkgutil.py", line 264, in _open_pkginfo
    return self.zipfile.open(self.pkg_info_path)
  File "C:\Apps\Python26\lib\zipfile.py", line 859, in open
    zinfo = self.getinfo(name)
  File "C:\Apps\Python26\lib\zipfile.py", line 826, in getinfo
    'There is no item named %r in the archive' % name)
KeyError: "There is no item named
'mercurial-1.0.1.egg-info\\\\PKG-INFO' in the archive"

======================================================================
FAIL: test_pkgutil.test_distribution
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Apps\Python26\Lib\site-packages\nose\case.py", line 183, in runTest
    self.test(*self.arg)
  File "C:\Users\Gustav\Data\pep376\test_pkgutil.py", line 60, in
test_distribution
    os.path.join(SITE_PKG, 'mercurial-1.0.1.egg-info/RECORD')])
AssertionError:
['C:\\Users\\Gustav\\Data\\pep376\\site-packages\\mercurial-1.0.1.egg-info\\PKG_INFO',
'C:\\Users\\
Gustav\\Data\\pep376\\site-packages\\mercurial-1.0.1.egg-info\\RECORD']
!= ['C:\\Users\\Gustav\\Data\\pep376\\site-
packages\\mercurial-1.0.1.egg-info/PKG_INFO',
'C:\\Users\\Gustav\\Data\\pep376\\site-packages\\mercurial-1.0.1.egg-
info/RECORD']

----------------------------------------------------------------------
Ran 7 tests in 0.019s

FAILED (errors=2, failures=1)

13:40 C:\Users\Gustav\Data\pep376
>unzip -l site-packages.zip
Archive:  site-packages.zip
  Length     EAs   ACLs    Date   Time    Name
 --------    ---   ----    ----   ----    ----
     2531      0      0  19/06/09 17:14   mercurial/filelog.py
     3449      0      0  19/06/09 17:14   mercurial/filelog.pyc
      234      0      0  19/06/09 17:14   mercurial-1.0.1.egg-info/PKG-INFO
      162      0      0  19/06/09 17:14   mercurial-1.0.1.egg-info/RECORD
        0      0      0  19/06/09 17:14   processing/__init__.py
     3482      0      0  19/06/09 17:14   processing-0.52.egg-info/PKG-INFO
      165      0      0  19/06/09 17:14   processing-0.52.egg-info/RECORD
 --------  -----  -----                   -------
    10023      0      0                   7 files

Paul.


More information about the Python-Dev mailing list