如何用setuptools3以与setuptools相同的方式在bitbake recipe中存储pyc文件?

2024-03-29 08:06:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我将来自https://github.com/yoctocookbook/meta-custom/tree/master/recipes-python/python-helloworld的python helloworld添加到我的yocto构建中,效果很好。这些文件将被预编译并复制到映像:

ls /usr/lib/python2.7/site-packages/helloworld
__init__.py   __init__.pyc  main.py       main.pyc

我需要用Python3。将配方中的inherit setuptools更改为inherit setuptools3会将python 3.7改为2.7添加到我的图像中,脚本也可以工作,但预编译的文件现在位于子文件夹__pycache__中,扩展名为:

ls /usr/lib/python3.7/site-packages/helloworld/__pycache__/
__init__.cpython-37.pyc  main.cpython-37.pyc

我想从目标版本中删除.py源代码文件。 使用setuptools我可以删除.py文件,并且脚本可以使用.pyc文件正常工作。使用setuptools3,python3在删除.py文件后引发ModuleNotFoundError。你知道吗

移动和重命名(如__pycache__/main.cpython-37.pycmain.pyc)它又能工作了。你知道吗

告诉setuptools3以与setuptools相同的方式创建precompiles.pyc文件以避免这种移动和重命名的正确方法是什么?你知道吗


Tags: 文件pyinitmainlibpackagesusrsite