10

In an existing java project that uses python (think python plugin for libre office)

would like to use mvn to install a pypi (Python Package Index). Right now we have the solution to package the tar in mvn and then use maven-dependency-plugin to unpack and maven-antrun-plugin to move the files into the python path (the libre office python path).

Any suggestions on a better way to manage this on Linux and Windows? Ideally it would be as simple as a maven plugin for pypi.

thanks for any input.

user2646177
  • 175
  • 1
  • 1
  • 7

2 Answers2

6

I don't know if a maven plugin that can install pip package exist. But what you could do is use the maven-exec plug-in to invoke pip on a specific goal. Here is the documentation on the exec plug-in http://www.mojohaus.org/exec-maven-plugin/usage.html Hope it helped

Edit: Updated link

drgn
  • 1,080
  • 1
  • 11
  • 21
4

I have used the following and it's working (pulling from an internal pypi repo).
NOTE: The requirements.txt is basically an output of: pip freeze > requirements.txt

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
    <executions>
        <execution>
            <id>pip-install</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>pip</executable>
                <arguments>
                    <argument>install</argument>
                    <argument>-r</argument>
                    <argument>${project.basedir}/requirements.txt</argument>
                    <argument>-i</argument>
                    <argument> http://artifactoryhost.domain.com/artifactory/api/pypi/<repo-name>/simple</argument>
                    <argument>--trusted-host</argument>
                    <argument>artifactoryhost.domain.com</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>
Nigel
  • 59
  • 4
  • 2
    I have no idea how I came back here, but this should be the accepted answer as it provides a clear example of how to do it. +1 For the pip command example. – drgn Jun 17 '21 at 00:27