如何发布Python3无源RPM?

2024-04-25 19:37:03 发布

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

我们有一个Python2产品发布为RPM。RPM只包含pyo/pyc文件,运行的脚本引用某些pyo文件来运行产品。我们使用setuptools打包这些RPM:

python setup.py bdist_rpm --release=... --requires=... --bdist-base=...

我们现在将产品移植到python3.6,发现pyc文件no longer reside in the same location作为py文件。它们位于py文件文件夹下的\uuu pycache\uuuu文件夹中,而且,如果相应的py文件不存在,它们将无法工作。如果pyc文件正在替换py文件,并且不在pycache中,则仍然支持遗留行为。你知道吗

documentation显示python compileall可以接受a-b标志:

Write the byte-code files to their legacy locations and names, which may overwrite byte-code files created by another version of Python. The default is to write files to their PEP 3147 locations and names, which allows byte-code files from multiple versions of Python to coexist.

但是,由于我们使用setuptools,所以我们不控制编译命令行。你知道吗

问题:

  1. 有没有办法告诉setuptools用-b标志编译代码并保留pyc文件的遗留位置?你知道吗
  2. 在Python3中有没有更好的方法来发布源代码较少的RPM,并且仍然能够从脚本调用pyc文件?你知道吗

Tags: 文件thetopy脚本文件夹产品code