[Distutils] wierd namespaces: nspkh.pth makes a package builtin

Alessandro Dentella sandro at e-den.it
Thu Apr 12 07:14:18 EDT 2018


Hi,


I'm trying to debug a complex situazion in which a *nspkg.pth file
creates a builtin package that brakes the import in a uwsgi process.

In this case I'm still working with Python2.7.

To be sure the package is correct I started with an "almost empty" one
(whose content is shown below) and I have this strage behaviour:
if I install using 'python setup.py install' everithing is ok, if I
install with pip the namespace seems a builtin:

   root at argo-stretch:/tmp/jmb.vega# python setup.py install
   ...
   root at argo-stretch:/tmp/jmb.vega# python -c 'import jmb; print(jmb)'
   <module 'jmb' from '/usr/local/lib/python2.7/dist-packages/jmb.vega-0.1-py2.7.egg/jmb/__init__.pyc'>

In this case the file 'jmb.vega-0.1-nspkg.pth' is NOT created
and the egg is added to 'easy-install.pth'

When doing the installation with pip

   root at argo-stretch:/tmp/jmb.vega# pip install .
   Processing /tmp/jmb.vega
   Requirement already satisfied: setuptools in /usr/lib/python2.7/dist-packages (from jmb.vega==0.1)
   Installing collected packages: jmb.vega
     Running setup.py install for jmb.vega ... done
   Successfully installed jmb.vega-0.1

the file 'jmb.tools-0.7-py2.7-nspkg.pth' is created and the modules
seems a built-in

   root at argo-stretch:/tmp/jmb.vega# (cd ; python -c 'import jmb; print(jmb)')
   <module 'jmb' (built-in)>

In the real case this is enought to break the import system of any
call to namespace 'jmb'.

the test package is

   jmb.vega/
   ├── jmb
   │   ├── __init__.py
   │   └── vega
   │       └── __init__.py
   └── setup.py


sandro at bluff:/tmp/jmb.vega$ cat setup.py
from setuptools import setup, find_packages


setup(
    name='jmb.vega',
    namespace_packages=['jmb'],
    version="0.1",
    description='Test package',
    author='Alessandro Dentella',
    packages=find_packages(exclude=['tests', 'tests.*']),
    platforms='any',
    zip_safe=False,
    install_requires=[
        'setuptools',
    ],
)

While __init__ in jmb is:

sandro at bluff:/tmp/jmb.vega$ cat jmb/__init__.py
__import__('pkg_resources').declare_namespace(__name__)


What's wrong with the configuration?
Why pip makes it a builtin package?

thanks in advance
sandro
*:-)

--
Sandro Dentella  *:-)
http://trepalchi.it                Il portale degli artisti

http://www.reteisi.org             Soluzioni libere per le scuole
http://sqlkit.argolinux.org        SQLkit home page - PyGTK/python/sqlalchemy


More information about the Distutils-SIG mailing list