简体   繁体   中英

Why a .pth file is created sometime on package installation?

Sometime, when I install a package, I can notice that a .pth file has been created in the site-packages dir just at the same level as the package code. For example, if I do a

pip install DjangoDevKit

I can see in site-packages directory :

djangodevkit                        (a directory)
DjangoDevKit-1.0.7.dist-info        (a directory)
DjangoDevKit-1.0.7-py3.5-nspkg.pth

The .pth file contains:

import sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('djangodevkit',));ie = os.path.exists(os.path.join(p,'__init__.py'));m = not ie and sys.modules.setdefault('djangodevkit', types.ModuleType('djangodevkit'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)

How this DjangoDevKit-1.0.7-py3.5-nspkg.pth has been created ? The setup.py does not tell to create such a .pth file. I searched into the code but there is nothing obvious.

Do you have an idea ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM