Reputation: 1
I have a python project and I use maven to create an rpm file, using rpm-maven-plugin v2.1.3. My project is written using python3. When I create the rpm file, as part of a larger process of ms creation (with mvn install) I get syntax error on specific python3 syntax. I can see that bytecompilation is done during the process, using /usr/bin/python which points to python2.7. How can I force the bytecompile to use /usr/bin/python3? I cannot change the global env variable since other ms are using python2.7 Also I cannot change the way mvn install is revoked since it's also used for all ms together. I'm looking for somathing in the project itself I can define or change to force it to use python3. I don't use a cmake file and I don't write my spec file (it is created as part of the rpm build)
Thank you!
spec file creation:
[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
Exception Trace:
[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:
<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>
I am trying to build my project using mvn install.
Upvotes: 0
Views: 199
Reputation: 1
Just went through this ... here is what worked for me ... <defineStatement>__python 3</defineStatement>
<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>
Make sure you have /usr/bin/python3
Upvotes: 0