Skip to content

Latest commit

 

History

History
118 lines (92 loc) · 3.39 KB

README.rst

File metadata and controls

118 lines (92 loc) · 3.39 KB

Maven Python Distribute Plugin

version: 0.2.6

This plugin integrates the Python distribute module into the Maven build:

http://packages.python.org/distribute/

This allows you to build and package Python code together with your Java code, which is useful for IT shops that develop in both of these languages.

Functionality

  • Keeps the setup.py version in sync with the Maven project version by updating setup.py in the process-sources phase.
  • Packages the Python module during the Maven package phase.
  • Allows specifying which format should the Python module be distributed as: source, RPM, egg, tar, zip, etc.
  • Supports uploading packages to PyPI during the deploy phase.

Configuration

Add the following to your pom.xml build section:

<plugin>
        <groupId>maven-python-mojos</groupId>
        <artifactId>maven-python-distribute-plugin</artifactId>
        <version>..</version>
        <executions>
                <execution>
                        <id>package</id>
                        <goals>
                                <goal>package</goal>
                        </goals>
                </execution>
                <execution>
                        <id>process</id>
                        <goals>
                                <goal>process-sources</goal>
                        </goals>
                </execution>
        </executions>
</plugin>

This defaults to building an egg file. If you would like to use another distribution type, you may specify something else:

<execution>
    <id>package</id>
    <goals>
        <goal>package</goal>
    </goals>
    <configuration>
        <distributionType>rpm</distributionType>
    </configuration>
</execution>

If you wish to build multiple different distribtion types, you can add multiple <execution> blocks with different types. Supported types are egg, wheel, wininst, rpm, bdist, dumb, source, or docs.

If you wish to upload your packaged files to PyPI, add the following:

<execution>
    <id>deploy</id>
    <goals>
        <goal>deploy</goal>
    </goals>
</execution>

This will default to uploading all of the packages generated by the package goal. If you don't want that, you can specify a distribution type in the same way as you can for packaging. The deploy goal supports all distribution types except for docs.

You can also optionally specify a repository to upload to:

<execution>
    <id>deploy</id>
    <goals>
        <goal>deploy</goal>
    </goals>
    <configuration>
        <repository>https://pypi.myserver.com</repository>
    </configuration>
</execution>

setup.py

To make the code runnable outside maven you can have a setup.py. If a setup-template.py is there in your source root setup.py will be replaced.

setup-template.py

Setup template allows for using maven controlled variables in your setup.py file. Set the version field in your setup-template.py to a hardcoded constant of ${VERSION}, e.g. Set the name field in your setup-template.py to a hardcoded constant of ${PROJECT_NAME}, e.g.

from setuptools import setup, find_packages

setup(
      install_requires=['distribute'],
      name = '${PROJECT_NAME}',
      version = '${VERSION}',
      packages = find_packages('.')
)

Maven Repository

Add the following plugin repository to your pom.xml in order to use this plugin:

<pluginRepositories>
        <pluginRepository>
                <id>jitpack.io</id>
                <url>https://jitpack.io</url>
        </pluginRepository>
</pluginRepositories>