[Jython-checkins] jython (merge default -> default): Merge commit
jeff.allen
jython-checkins at python.org
Sat Jul 20 17:16:30 EDT 2019
https://hg.python.org/jython/rev/91d69ae5d35d
changeset: 8256:91d69ae5d35d
parent: 8252:f3baccd1fc34
parent: 8255:5deb7d7984e8
user: Jeff Allen <ja.py at farowl.co.uk>
date: Sat Jul 20 20:07:46 2019 +0100
summary:
Merge commit
files:
NEWS | 5 +
README.md | 88 ++++++++-
README.txt | 34 +++
installer/src/java/org/python/util/install/ChildProcess.java | 54 ++++-
installer/src/java/org/python/util/install/JarInstaller.java | 2 +
5 files changed, 156 insertions(+), 27 deletions(-)
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@
Development tip
Bugs fixed
- [ 2708 ] test_urllib2net fails (on Travis CI)
+ - [ 2764 ] Readme is not displayed when using the GUI installer
+ - [ 2345 ] Installing pip fails if JYTHON_HOME points to old installation
- [ 2774 ] test_ssl failures from weak certificate
- [ 2768 ] Allow bytearray + and += to accept buffer protocol objects
- [ 2742 ] JARs for bouncycastle out of date (upgrade to 1.16)
@@ -69,6 +71,9 @@
- We no longer recommend overriding toString in PyObject sub-classes as a way of defining
string forms. Override __repr__, and if necessary __str__, as is usual in Python. We
recommend toString should return the same as __str__ (or __unicode__).
+ - Experimentally, we use Gradle to build a JAR and POM that may be cited as a dependency by
+ other projects. The Jython project would like to know if this is being done suitably
+ for downstream use.
Jython 2.7.2a1
Bugs fixed
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,20 +1,88 @@
# Jython: Python for the Java Platform
-[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.python/jython-standalone/badge.svg)](https://search.maven.org/artifact/org.python/jython-standalone/) [![Javadocs](https://www.javadoc.io/badge/org.python/jython-standalone.svg)](https://www.javadoc.io/doc/org.python/jython-standalone)
+[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.python/jython-standalone/badge.svg)](https://search.maven.org/artifact/org.python/jython-standalone/)
+[![Javadocs](https://www.javadoc.io/badge/org.python/jython-standalone.svg)](https://www.javadoc.io/doc/org.python/jython-standalone)
+
+This is the development repository of Jython,
+the implementation of Python 2.7 in Java.
+Along with good (not perfect!) language
+and runtime compatibility with CPython 2.7,
+Jython 2.7 provides substantial support of the Python ecosystem.
+This includes built-in support of *pip/setuptools*
+(you can use `bin/pip` if the targets do not include `C` extensions)
+and a native launcher for Windows (`bin/jython.exe`)
+that works essentially as the `python` command.
+
+Jim Baker presented a talk at PyCon 2015 about Jython 2.7,
+including demos of new features: https://www.youtube.com/watch?v=hLm3garVQFo
-This is the development repository of Jython. Along with language and runtime compatibility with CPython 2.7, Jython 2.7 provides substantial support of the Python ecosystem. This includes built-in support of *pip/setuptools* (you can use with `bin/pip`) and a native launcher for Windows (`bin/jython.exe`), with the implication that you can finally install Jython scripts on Windows.
+See [ACKNOWLEDGMENTS](ACKNOWLEDGMENTS) for details about Jython's copyright,
+license, contributors, and mailing lists.
+Consult [NEWS](NEWS) for detailed release notes, including bugs fixed,
+backwards breaking changes, and new features.
+We sincerely thank all who contribute to Jython, by bug reports, patches,
+pull requests, documentation changes and e-mail discussions.
-**Note that if you have `JYTHON_HOME` set, you should unset it to avoid problems with the installer and pip/setuptools.**
+## How to build Jython
-Jim Baker presented a talk at PyCon 2015 about Jython 2.7, including demos of new features: https://www.youtube.com/watch?v=hLm3garVQFo
+The project uses Mercurial for version-control,
+and the master repository is at https://hg.python.org/jython/,
+while the repository on GitHub is just a mirror of that.
+You may clone either repository to create a buildable copy of the latest state
+of the Jython source.
+
+### Build using `ant` for development
-The release was compiled on OSX using JDK 7 and requires a minimum of Java 7 to run.
+Jython is normally built using `ant`.
+It is necessary to have Ant and at least a Java 7 SDK on the path.
+To build Jython development use, we generally use the command:
+```
+ant
+```
+This leaves an executable in `dist/bin`
+that you may run from the check-out root with:
+```
+dist/bin/jython
+```
+Other `ant` targets exist, notably `clean`, and `jar`.
-Please try this release out and report any bugs at http://bugs.jython.org
+You can test your build of Jython (by running the regression tests),
+with the command:
+```
+dist/bin/jython -m test.regrtest -e -m regrtest_memo.txt
+```
-You can test your installation of Jython (not the standalone jar) by running the regression tests, with the command:
+### Build an installer using `ant`
+
+If you want to install a snapshot build of Jython, use the command:
+```
+ant installer
```
-jython -m test.regrtest -e -m regrtest_memo.txt
+This will leave you with a snapshot installer JAR in `dist`,
+that you can run with:
+```
+java -jar jython-installer.jar
+```
+for the graphical installer, or:
+```
+java -jar jython-installer.jar --console
```
-For Windows, there is a simple script to do this: `jython_regrtest.bat`. In either case, the memo file `regrtest_memo.txt` will be useful in the bug report if you see test failures. The regression tests can take about half an hour.
+For the console version. (A `--help` option gives you the full story.)
+
+### Build a JAR using Gradle
-See [ACKNOWLEDGMENTS](ACKNOWLEDGMENTS) for details about Jython's copyright, license, contributors, and mailing lists; and [NEWS](NEWS) for detailed release notes, including bugs fixed, backwards breaking changes, and new features. We sincerely thank all who contribute to Jython, including - but not limited to - bug reports, patches, pull requests, documentation changes, support emails, and fantastic conversation on Freenode at #jython. Join us there for your questions and answers!
+Experimentally, we have a Gradle build that results in a family of JARs,
+and a POM.
+This is intended to provide the Jython core in a form that Gradle and Maven
+users can consume as a dependency.
+Invoke this with:
+```
+PS> .\gradlew publish
+```
+and a JAR and POM are delivered to ` .build2\repo`
+
+Whereas the JARs delivered by the installer are somewhat "fat",
+embedding certain dependencies in shaded (renamed) form,
+the JARs from the Gradle build are "spare"
+and cite their dependencies externally through a POM.
+The project would like to know if this is being done suitably
+for downstream use.
diff --git a/README.txt b/README.txt
new file mode 100644
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,34 @@
+Jython: Python for the Java Platform
+
+Welcome to Jython 2.7.2a1.
+
+This is an alpha release of the 2.7.2 version of Jython. Along with
+language and runtime compatibility with CPython 2.7, Jython 2.7
+provides substantial support of the Python ecosystem. This includes
+built-in support of pip/setuptools (you can use with bin/pip) and a
+native launcher for Windows (bin/jython.exe).
+
+Jim Baker presented a talk at PyCon 2015 about Jython 2.7, including
+demos of new features: https://www.youtube.com/watch?v=hLm3garVQFo
+
+The release was compiled on OSX using JDK 7 and requires a minimum of
+Java 7 to run.
+
+Please try this release out and report any bugs at
+http://bugs.jython.org You can test your installation of Jython (not
+the standalone jar) by running the regression tests, with the command:
+
+jython -m test.regrtest -e -m regrtest_memo.txt
+
+For Windows, there is a simple script to do this: jython_regrtest.bat.
+In either case, the memo file regrtest_memo.txt will be useful in the
+bug report if you see test failures. The regression tests can take
+about half an hour.
+
+See ACKNOWLEDGMENTS for details about Jython's copyright, license,
+contributors, and mailing lists; and NEWS for detailed release notes,
+including bugs fixed, backwards breaking changes, and new features.
+
+We sincerely thank all who contributed to this release of Jython,
+through bug reports, patches, pull requests, documentation changes,
+email and conversation in all media.
diff --git a/installer/src/java/org/python/util/install/ChildProcess.java b/installer/src/java/org/python/util/install/ChildProcess.java
--- a/installer/src/java/org/python/util/install/ChildProcess.java
+++ b/installer/src/java/org/python/util/install/ChildProcess.java
@@ -6,7 +6,9 @@
import java.io.InputStreamReader;
import java.nio.file.Path;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Easy start of a child process.
@@ -86,6 +88,11 @@
private String _command[] = null;
/**
+ * Environment name-value pairs to add or remove (if null) at the start of {@link #run()}.
+ */
+ private Map<String, String> _environmentChanges = new HashMap<>();
+
+ /**
* The timeout (in milliseconds)
*/
private long _timeout = INFINITE_TIMEOUT;
@@ -170,6 +177,16 @@
public void setCWD(Path cwd) { _cwd = cwd; }
+ /**
+ * Set or delete an environment variable for the subsequently run command.
+ *
+ * @param key name of variable
+ * @param value new value or {@code null} to delete it.
+ */
+ public void putEnvironment(String key, String value) {
+ _environmentChanges.put(key, value);
+ }
+
public Path getCWD() { return _cwd; }
/**
@@ -263,14 +280,23 @@
try {
// determine start time
_startTime = System.currentTimeMillis();
- // start the process
+ // Create and configure the process specification
ProcessBuilder pb = new ProcessBuilder();
pb.command(getCommand());
if (getCWD() != null) {
pb.directory(getCWD().toFile());
}
+ // Adjust the environment variables from the default System.getenv()
+ for (Map.Entry<String, String> change : _environmentChanges.entrySet()) {
+ if (change.getValue() == null) {
+ pb.environment().remove(change.getKey());
+ } else {
+ pb.environment().put(change.getKey(), change.getValue());
+ }
+ }
+ // Run the process with redirected input and error streams.
+ debugCommand(pb);
_process = pb.start();
- debugCommand();
// handle stdout and stderr
OutputMonitor stdoutMonitor = new OutputMonitor(_process.getInputStream());
stdoutMonitor.start();
@@ -349,21 +375,15 @@
/**
* Lists the submitted command (if so indicated)
*/
- private void debugCommand() {
+ private void debugCommand(ProcessBuilder pb) {
if (isDebug()) {
- String[] command = getCommand();
- if (command != null) {
- System.out.print("[ChildProcess] command '");
- for (int i = 0; i < command.length; i++) {
- String commandPart = command[i];
- if (i == 0) {
- System.out.print(commandPart);
- } else {
- System.out.print(" " + commandPart);
- }
- }
- System.out.println("' is now running...");
- }
+ System.out.print("[ChildProcess] command = ");
+ System.out.println(pb.command());
+ System.out.print("[ChildProcess] environment = ");
+ System.out.println(pb.environment());
+ System.out.print("[ChildProcess] working directory = ");
+ System.out.println(pb.directory());
}
}
-}
\ No newline at end of file
+}
+
diff --git a/installer/src/java/org/python/util/install/JarInstaller.java b/installer/src/java/org/python/util/install/JarInstaller.java
--- a/installer/src/java/org/python/util/install/JarInstaller.java
+++ b/installer/src/java/org/python/util/install/JarInstaller.java
@@ -188,6 +188,8 @@
}
ChildProcess childProcess = new ChildProcess(command);
childProcess.setCWD(bindir);
+ // JYTHON_HOME will be wrong if set: see https://bugs.jython.org/issue2345
+ childProcess.putEnvironment("JYTHON_HOME", null);
errorCode = childProcess.run();
} catch (Throwable t) {
errorCode = 1;
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list