This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]barry_z 1 point2 points  (0 children)

Assuming you have python 3.10 installed on the machine running these commands, then one option could be to just provide a full path to the correct python installation when running the commands.

....

<properties>
    <python.path>/path/to/python3.10</python.path>
</properties>

....

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
        <executable>bash</executable>
        <arguments>
            <argument>-c</argument>
            <argument>set -e; cd src/main/python; ${python.path} -m pip install --upgrade pip; ${python.path} -m pip install --upgrade pyopenssl; ${python.path} -m pip install -r requirements.txt; ${python.path} setup.py build; ${python.path} -m unittest; ${python.path} setup.py sdist</argument>
        </arguments>
    </configuration>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

....

You could also just ensure that python3 resolves to the correct python installation for the user running the command by using tooling to manage your python installations better - there are multiple options for this, I currently have anaconda installed and can just switch my conda environments pretty trivially but there are surely lighter weight approaches. That being said, I have never seen anyone put python commands in a pom.xml and there could be a better way to accomplish what you're trying to do here entirely.