Skip to content

Commit

Permalink
Should fix #168 (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrongestNumber9 authored Feb 4, 2025
1 parent 0e0bfbb commit a32b62b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 8 additions & 0 deletions python/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;

/**
Expand Down Expand Up @@ -121,6 +123,8 @@ private void createGatewayServerAndStartScript() throws IOException {
outputStream = new InterpreterOutputStream(LOGGER);
Map<String, String> env = setupPythonEnv();
env.put("PY4J_GATEWAY_SECRET", secret);
// Do not write bytecode cache as .pyc files are not tracked
env.put("PYTHONDONTWRITEBYTECODE", "true");
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Launching Python Process Command: {} {}",
cmd.getExecutable(), StringUtils.join(cmd.getArguments(), " "));
Expand Down Expand Up @@ -166,17 +170,9 @@ private void createPythonScript() throws IOException {

private void copyResourceToPythonWorkDir(String srcResourceName,
String dstFileName) throws IOException {
FileOutputStream out = null;
try {
out = new FileOutputStream(pythonWorkDir.getAbsoluteFile() + "/" + dstFileName);
IOUtils.copy(
getClass().getClassLoader().getResourceAsStream(srcResourceName),
out);
} finally {
if (out != null) {
out.close();
}
}
Path outputPath = Path.of(pythonWorkDir.getAbsoluteFile() + "/" + dstFileName);
Files.copy(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(srcResourceName)), outputPath);
outputPath.toFile().deleteOnExit();
}

protected Map<String, String> setupPythonEnv() throws IOException {
Expand Down

0 comments on commit a32b62b

Please sign in to comment.