@@ -114,10 +114,36 @@ default Environment delete() throws BuildException {
114114 * @see #groovy To create a service for Groovy script execution.
115115 */
116116 default Service python () {
117+ // NB: This method may appear redundant with python(String[])
118+ // below, but it is included for two reasons:
119+ //
120+ // 1. So that it can have a distinct javadoc; and
121+ // 2. For backwards compatibility with existing bytecode tied
122+ // to this method signature (avoids NoSuchMethodError).
123+ return python (new String [0 ]);
124+ }
125+
126+ /**
127+ * Launches a Python process with the given arguments.
128+ * <p>
129+ * This is a <b>lower level</b> function for launching Python with any
130+ * arguments of your choice. This can be useful to perform actions such
131+ * as installing a wheel (`python -m pip install /path/to/wheel-file`),
132+ * without the usual bother of platform-specific special casing.
133+ * </p>
134+ *
135+ * @param args Optional alternate args to pass to the python process. If
136+ * empty, a normal Appose {@code python_worker} will be started.
137+ * @return The newly created process within a {@link Service} object.
138+ * Useful for calling {@link Service#waitFor()} to await completion.
139+ */
140+ default Service python (String ... args ) {
117141 List <String > pythonExes = Arrays .asList ("python" , "python3" , "python.exe" );
118- return service (pythonExes , "-c" ,
119- "import appose.python_worker; appose.python_worker.main()" )
120- .syntax ("python" );
142+ String [] pythonArgs = args .length > 0 ? args : new String [] {
143+ "-c" ,
144+ "import appose.python_worker; appose.python_worker.main()"
145+ };
146+ return service (pythonExes , pythonArgs ).syntax ("python" );
121147 }
122148
123149 /**
0 commit comments