gpt4 book ai didi

python-3.x - cmake : brp-python-bytecompile and python3

转载 作者:行者123 更新时间:2023-12-02 18:27:00 24 4
gpt4 key购买 nike

我正在尝试使用 cpack (cmake) 创建一个 python3 包。由于某种原因,它失败并显示一条神秘消息:

+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
error: Bad exit status from /var/tmp/rpm-tmp.rt2mTp (%install)
Bad exit status from /var/tmp/rpm-tmp.rt2mTp (%install)
***
CPackRPM:Debug: - /mnt/source/bin2/_CPack_Packages/Linux/RPM/rpmbuildsource-python.out
CPackRPM:Debug: *** Building target platforms: x86_64
Building for target x86_64
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.mxEjdh
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.rt2mTp
Compiling /mnt/source/bin/_CPack_Packages/Linux/RPM/project-0.0.8-Linux/python/usr/lib/python3/dist-packages/project/__init__.py ...
File "/usr/lib/python3/dist-packages/project/__init__.py", line 27
raise ValueError(f"Not a {obj.__class__.__name__} reference")
^
SyntaxError: invalid syntax

有没有办法跳过brp-python-bytecompile步骤,或者有没有办法指示cpack python包仅针对python3.

供引用:

# head -1 source/python/__init__.py
#!/usr/bin/env python3

最佳答案

有两种解决方案:

  1. 依赖 /bin 黑客
  2. 更改 __python 的默认值

对于解决方案 #1,您只需使用 bin 子文件夹。任何发生在 /bin 子目录中的 python 字节编译都不会完成:

对于解决方案#2,您只需遵循:

对于 cmake,语法是:

set(CPACK_RPM_SPEC_MORE_DEFINE "%define __python python3")

另请参阅替代解决方案:

关于python-3.x - cmake : brp-python-bytecompile and python3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69988093/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com