Mercurial > jython
changeset 8330:33ea06302061
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.
author | Jeff Allen <ja.py@farowl.co.uk> |
---|---|
date | Sun, 23 Feb 2020 13:50:18 +0000 |
parents | 2a77fdc4417c |
children | 57e47c817d26 |
files | .gitignore .hgignore Lib/test/test_httpservers.py NEWS build.xml registry src/org/python/core/PySystemState.java |
diffstat | 7 files changed, 22 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ bin build build2 cachedir +.jython_cache dist target
--- a/.hgignore +++ b/.hgignore @@ -35,6 +35,7 @@ ant.properties build build2 cachedir +.jython_cache dist publications reports
--- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -417,10 +417,7 @@ class CGIHTTPServerTestCase(BaseTestCase 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)
--- a/NEWS +++ b/NEWS @@ -8,7 +8,7 @@ https://github.com/jythontools/jython 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 @@ Jython 2.7.2b1 - 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
--- a/build.xml +++ b/build.xml @@ -157,6 +157,9 @@ informix.jar = ../support/jdbc-4.10.12.j <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 @@ informix.jar = ../support/jdbc-4.10.12.j <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 @@ informix.jar = ../support/jdbc-4.10.12.j <!-- 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>
--- 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 @@ python.cachedir = cachedir # 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.cachedir = cachedir #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
--- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -62,7 +62,7 @@ public class PySystemState extends PyObj 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 @@ public class PySystemState extends PyObj } 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) {