Skip to content

Commit

Permalink
Several improvements
Browse files Browse the repository at this point in the history
Add support for bdist_dumb packaging, set default path for setup.py,
and add documentation of new features to readme file.
  • Loading branch information
Joel Croteau committed Feb 28, 2018
1 parent 04b0eee commit 0012205
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 18 deletions.
64 changes: 48 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ 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.
* 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:
::
Add the following to your *pom.xml* build section::

<plugin>
<groupId>maven-python-mojos</groupId>
Expand All @@ -43,19 +43,59 @@ Add the following to your *pom.xml* build section:
</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.
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(
Expand All @@ -65,22 +105,14 @@ Set the *name* field in your *setup-template.py* to a hardcoded constant of **${
packages = find_packages('.')
)


Maven Repository
----------------

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

::
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>





Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public abstract class AbstractSetupCommandMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException {
final File buildDirectory = Paths.get(project.getBuild().getDirectory(), "maven-python").toFile();
final String setupOutputCanonicalPath = project.getProperties().getProperty("python.distribute.plugin.setup.path");
final String setupOutputCanonicalPath = project.getProperties().getProperty("python.distribute.plugin.setup.path", "src/main/python/setup.py");

try {
List<String> args = new ArrayList<>();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/github/mojos/distribute/PackageMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static String getDistributionTypeArg(String distributionType) throws MojoExecuti
case "wheel":
case "wininst":
case "rpm":
case "dumb":
return "bdist_" + distributionType;
case "bdist":
return "bdist";
Expand All @@ -47,7 +48,7 @@ static String getDistributionTypeArg(String distributionType) throws MojoExecuti
case "docs":
return "build_sphinx";
default:
throw new MojoExecutionException("Invalid distributionType (egg, wheel, wininst, rpm, bdist, source, or docs supported): " + distributionType);
throw new MojoExecutionException("Invalid distributionType (egg, wheel, wininst, rpm, bdist, dumb, source, or docs supported): " + distributionType);
}
}

Expand Down

0 comments on commit 0012205

Please sign in to comment.