字节编译是用/usr/bin/python完成的,而不是/usr/bin/python3

2hh7jdfx  于 4个月前  发布在  Python
关注(0)|答案(1)|浏览(135)

我有一个python项目,我使用maven创建一个rpm文件,使用rpm-maven-plugin v2.1.3。我的项目是使用python3编写的。当我创建rpm文件时,作为ms创建的更大过程的一部分(使用mvn install)我在特定的python3语法上得到语法错误。我可以看到在这个过程中完成了bytecompilation,使用指向python2.7的/usr/bin/python。如何强制bytecompile使用/usr/bin/python3?我不能改变全局env变量,因为其他ms正在使用python2.7我也不能改变mvn install被撤销的方式,因为它也用于所有ms。在项目本身中,我可以定义或更改以强制它使用python3。我不使用cmake文件,也不编写spec文件(它是作为rpm构建的一部分创建的)
谢谢你,谢谢
等级库文件创建:

[2023-01-03T16:22:00.431Z] [INFO] Creating directory /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael
[2023-01-03T16:22:00.431Z] [INFO] Creating directory /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/BUILD
[2023-01-03T16:22:00.431Z] [INFO] Creating directory /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/RPMS
[2023-01-03T16:22:00.431Z] [INFO] Creating directory /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/SOURCES
[2023-01-03T16:22:00.431Z] [INFO] Creating directory /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/SPECS
[2023-01-03T16:22:00.431Z] [INFO] Creating directory /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/SRPMS
[2023-01-03T16:22:00.431Z] [INFO] Creating directory /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot
[2023-01-03T16:22:00.431Z] [INFO] Creating directory /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/buildroot
[2023-01-03T16:22:00.431Z] [INFO] Copying files to /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot/usr/share/yael
[2023-01-03T16:22:00.431Z] [INFO] Copying files to /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot/usr/share/yael
[2023-01-03T16:22:00.431Z] [INFO] Copying files to /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot/usr/share/yael
[2023-01-03T16:22:00.431Z] [INFO] Copying files to /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot/usr/share/yael
[2023-01-03T16:22:00.431Z] [INFO] Copying files to /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot/usr/share/yael
[2023-01-03T16:22:00.431Z] [INFO] Copying files to /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot/usr/share/yael
[2023-01-03T16:22:00.431Z] [INFO] Copying files to /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot/usr/share/yael
[2023-01-03T16:22:00.431Z] [INFO] Copying files to /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/tmp-buildroot/usr/share/yael
[2023-01-03T16:22:00.431Z] [INFO] Creating spec file /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/SPECS/ms-yael.spec

字符串
异常跟踪:

[2023-01-03T16:22:00.773Z] [INFO] + /usr/lib/rpm/check-buildroot
[2023-01-03T16:22:00.773Z] [INFO] + /usr/lib/rpm/redhat/brp-compress
[2023-01-03T16:22:00.773Z] [INFO] + /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
[2023-01-03T16:22:00.773Z] [INFO] + /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
[2023-01-03T16:22:00.773Z] [INFO] + /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
[2023-01-03T16:22:00.773Z] [INFO] + /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
[2023-01-03T16:22:00.773Z] [INFO] Compiling /home/jenkins/workspace/ms_side-pipeline/yael-packer/target/rpm/ms-yael/buildroot/usr/share/yael/yael/yaelFramework/yael1.py ...
[2023-01-03T16:22:00.773Z] [INFO]   File "/usr/share/yael/yael/yaelFramework/yael1.py", line 33
[2023-01-03T16:22:00.773Z] [INFO]     def send_response(self, response: Response, metadata: ResponseMetadata) -> None:
[2023-01-03T16:22:00.773Z] [INFO]                                     ^
[2023-01-03T16:22:00.773Z] [INFO] SyntaxError: invalid syntax


POM插件:

<plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>rpm-maven-plugin</artifactId>
                        <version>2.1.3</version>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <inherited>false</inherited>
                                <phase>install</phase>
                                <goals>
                                    <goal>rpm</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <group>Networking/Admin</group>
                            <name>myProject</name>
                            <packager>Yael</packager>
                            <prefix>/usr/share</prefix>
                            <version>0</version>
                            <release>0</release>
                            <needarch>x86_64</needarch>
                            <mappings>
                                <mapping>
                                    <directory>myProjectDir/</directory>
                                    <filemode>777</filemode>
                                    <sources>
                                        <source>
                                            <location>../yaelDir/</location>
                                        </source>
                                    </sources>
                                </mapping>
                            </mappings>
                        </configuration>
                    </plugin>
                     <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>attach-artifacts</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>target/rpm/ms-yael/RPMS/x86_64/yaelRPM-0-0.x86_64.rpm</file>
                                            <type>rpm</type>
                                        </artifact>
                                        <artifact>
                                            <file>../git-commit.txt</file>
                                            <classifier>git-commit</classifier>
                                            <type>txt</type>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>

                    </plugin>
                </plugins>


我正在尝试使用mvn install构建我的项目。

tcbh2hod

tcbh2hod1#

刚刚经历了这个..

<build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rpm-maven-plugin</artifactId>
                <version>2.3.0</version>
                <configuration>
                    <defineStatements>
                        <defineStatement>__python 3</defineStatement>
                    </defineStatements>

字符串
确保您有/usr/bin/python3

相关问题