[Jython-checkins] jython: Relocate cache to working directory (fixes #2862)
jeff.allen
jython-checkins at python.org
Sun Feb 23 10:13:31 EST 2020
https://hg.python.org/jython/rev/33ea06302061
changeset: 8330:33ea06302061
user: Jeff Allen <ja.py at farowl.co.uk>
date: Sun Feb 23 13:50:18 2020 +0000
summary:
Relocate cache to working directory (fixes #2862)
We no longer try to cache every user's JARs in the installation
directory, ineffective since fix of #2044. Behaviour for applications
that set an absolute location (or skip) is unchanged.
files:
.gitignore | 1 +
.hgignore | 1 +
Lib/test/test_httpservers.py | 5 +----
NEWS | 5 ++++-
build.xml | 9 +++++++--
registry | 6 ++++--
src/org/python/core/PySystemState.java | 6 ++++--
7 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -39,6 +39,7 @@
build
build2
cachedir
+.jython_cache
dist
target
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -35,6 +35,7 @@
build
build2
cachedir
+.jython_cache
dist
publications
reports
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -417,10 +417,7 @@
os.chdir(self.cwd)
if self.pythonexe != sys.executable:
os.remove(self.pythonexe)
- os.remove(self.file1_path)
- os.remove(self.file2_path)
- os.rmdir(self.cgi_dir)
- os.rmdir(self.parent_dir)
+ test_support.rmtree(self.parent_dir)
finally:
BaseTestCase.tearDown(self)
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -8,7 +8,7 @@
Jython 2.7.2b4
Bugs fixed
-
+ - [ 2862 ] Jython fails on Linux for normal user when installed by root
Jython 2.7.2b3
Bugs fixed
@@ -122,6 +122,9 @@
- There is much improved support for locale, but as a backward-incompatible change, it is
provided as an opt-in. Define property python.locale.control=settable on the command line
or via the Jython registry, to enable. This may become the default in a later version.
+ - The default location of the Jython package cache has moved from the installation directory
+ to the current working directory and called ".jython_cache". Previously, Jython installed
+ system-wide either exposed the cache as world read-write (a security risk) or disabled it.
Jython 2.7.2a1
Bugs fixed
diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -157,6 +157,9 @@
<property name="python.lib" value="${basedir}/lib-python/2.7" />
<property name="extlibs.dir" value="${basedir}/extlibs" />
+ <!-- Cache we need to clean (now it is not in dist.dir) -->
+ <property name="cache.dir" value="${basedir}/.jython_cache" />
+
<!-- Source specifically for test: -->
<property name="test.source.dir" value="${basedir}/tests/java" />
<property name="bugtests.dir" value="${basedir}/bugtests" />
@@ -413,12 +416,14 @@
<target name="clean" depends="common-dirs, clean-test"
description="Delete contents of working directories">
<delete includeemptydirs="true" failonerror="false">
+ <!-- the package cache (now it is not in dist.dir). -->
+ <fileset dir="${cache.dir}" includes="**/*" erroronmissingdir="false" />
<!-- all files and subdirectories of ${build.dir}, without ${build.dir} itself. -->
<fileset dir="${build.dir}" includes="**/*" defaultexcludes="false" />
<!-- all files and subdirectories of ${dist.dir}, without ${dist.dir} itself. -->
<fileset dir="${dist.dir}" includes="**/*" defaultexcludes="false" />
<!-- all files and subdirectories of ${pubs.dir}, without ${pubs.dir} itself. -->
- <fileset dir="${pubs.dir}" includes="**/*" />
+ <fileset dir="${pubs.dir}" includes="**/*" erroronmissingdir="false" />
</delete>
</target>
@@ -428,7 +433,7 @@
<!-- all files and subdirectories of ${build.dir}, without ${build.dir} itself. -->
<fileset dir="${build.dir}" includes="**/*" excludes="gensrc/**" />
<!-- all files and subdirectories of ${dist.dir}, without ${dist.dir} itself. -->
- <fileset dir="${dist.dir}" includes="**/*" excludes="cachedir/**, Lib/**" />
+ <fileset dir="${dist.dir}" includes="**/*" excludes="Lib/**" />
</delete>
</target>
diff --git a/registry b/registry
--- a/registry
+++ b/registry
@@ -15,8 +15,8 @@
# Set the directory to use for caches (currently just package information)
# This directory should be writable by the user. If this is an absolute path it is used as given,
-# otherwise it is interpreted relative to sys.prefix (typically the directory of this file).
-python.cachedir = cachedir
+# otherwise it is interpreted relative to the current working directory (at initialisation).
+#python.cachedir = .jython_cache
# Setting this property to true disables the package scan for the cachedir.
# Please be aware that disabling this will break importing * from java packages
@@ -24,6 +24,7 @@
# Properties to check for initializing and updating the package cache
# Values shown here are those hard-coded in Jython's cache manager.
+
# Treat JARs on the classpath and (up to Java 8) in the JRE as a source of Python packages.
#python.packages.paths = java.class.path, sun.boot.class.path # up to Java 8
#python.packages.paths = java.class.path # from Java 9
@@ -31,6 +32,7 @@
#python.packages.directories = java.ext.dirs # up to Java 8
#python.packages.directories # undefined from Java 9
+
# DEPRECATED way to set the verbosity of messages output by Jython. If
# specified, "python.verbose" will set logging level for "org.python" when
# the runtime is initialised. It is better to use java.util.logging
diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java
--- a/src/org/python/core/PySystemState.java
+++ b/src/org/python/core/PySystemState.java
@@ -62,7 +62,7 @@
private static final Logger logger = Logger.getLogger("org.python.core");
- protected static final String CACHEDIR_DEFAULT_NAME = "cachedir";
+ private static final String CACHEDIR_DEFAULT_NAME = ".jython_cache";
public static final String JYTHON_JAR = "jython.jar";
public static final String JYTHON_DEV_JAR = "jython-dev.jar";
@@ -1270,9 +1270,11 @@
}
cachedir = new File(props.getProperty(PYTHON_CACHEDIR, CACHEDIR_DEFAULT_NAME));
if (!cachedir.isAbsolute()) {
- String prefixString = Py.fileSystemDecode(prefix);
+ String prefixString = props.getProperty("user.dir", "");
cachedir = new File(prefixString, cachedir.getPath());
+ cachedir = cachedir.getAbsoluteFile();
}
+ logger.log(Level.CONFIG, "cache at {0}", cachedir);
}
private static void initPackages(Properties props) {
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list