简体   繁体   English

为什么在安装软件包时有时会创建.pth文件?

[英]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. 有时,当我安装软件包时,我可以注意到在site-packages目录中已经创建了一个.pth文件,它与软件包代码处于同一级别。 For example, if I do a 例如,如果我做一个

pip install DjangoDevKit

I can see in site-packages directory : 我可以在site-packages目录中看到:

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

The .pth file contains: .pth文件包含:

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 ? 这个DjangoDevKit-1.0.7-py3.5-nspkg.pth是如何创建的? The setup.py does not tell to create such a .pth file. setup.py不会告诉您创建这样的.pth文件。 I searched into the code but there is nothing obvious. 我搜索了代码,但没有发现明显的问题。

Do you have an idea ? 你有想法吗 ?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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