[Distutils] ImportError running 'test' on namespace package - other package in namespace not found

Jason R. Coombs jaraco at jaraco.com
Mon Jun 30 02:06:14 CEST 2008

Okay.  I narrowed the problem down and created a minimal test case.  I created 
two projects, myns.projA and myns.projB.  myns.projA is stock basic_namespace 
project with one module added.

First, I created myns.projA with the basic_namespace template from ZopeSkel:

> paster create -t basic_namespace
Selected and implied templates:
  zopeskel#basic_namespace  A project with a namespace package

Enter project name: myns.projA
  egg:      myns.projA
  package:  mynsproja
  project:  myns.projA
Enter namespace_package (Namespace package (like plone)) ['plone']: myns
Enter package (The package contained namespace package (like example)) 
['example']: projA
... (rest are defaults)

Then I added a single module with a simple function

> cat > myns.projA\myns\projA\modA.py
def funcA():
  print "funcA called"

myns.projB is another project created basically the same way, but they key to 
getting the bug to surface was to put the packages in a sub-directory... so I 
modified setup.py with the following parameters to setup:
      package_dir={'': 'src'},

And of course, I moved the myns directory to src/myns.  Note, this only had to 
happen for myns.projB.

Finally, I created a test directory and a file testBasic.py

> cat > test/testBasic.py
from myns.projA.modA import funcA

Note, I could add a dependency from myns.projB on myns.projA, but it's not 
necessary for this demonstration.

Then, I either setup myns.projA with either "install" or "develop" so that 
it's visible to the Python installation.

Thereafter, if I try to run "setup.py test" on myns.projB, I get the 
ImportError.  See error.txt, attached, for the transcript.  I've also attached 
the two test packages as described.  I notice now that the error appears to 
only occur when nose.collector is used... and when the package_dir of the 
child package is overridden.  Perhaps this needs to go to the nose project and 
instead of the distutils project.

Please advise on what I might do next to help resolve this issue.  Obviously I 
could restructure my projects to avoid the problem, but I would much rather 
help resolve the problem, as I suspect it may affect other users' deployments 
as well.

Much obliged,

-----Original Message-----
From: Phillip J. Eby [mailto:pje at telecommunity.com]
Sent: Friday, 20 June, 2008 08:46
To: Jason R. Coombs; distutils-sig at python.org
Subject: Re: [Distutils] ImportError running 'test' on namespace package - 
other package in namespace not found

At 08:07 PM 6/18/2008 -0600, Jason R. Coombs wrote:
>If there's not something obvious I should be doing differently, I'm happy to
>put together a minimal test case that reproduces the problem.

Please do.  Thanks!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: myns.zip
Type: application/x-zip-compressed
Size: 15371 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20080629/58e79b8c/attachment-0002.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: error.txt
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20080629/58e79b8c/attachment-0001.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6580 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20080629/58e79b8c/attachment-0003.bin>

More information about the Distutils-SIG mailing list