Fridrich Strba 2023-09-19 13:40:30 +00:00 committed by Git OBS Bridge
parent 1e77489c8f
commit 9214c6ae80
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,59 @@
diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java
index 1fb701d..ee9b38f 100644
--- a/src/org/python/core/PySystemState.java
+++ b/src/org/python/core/PySystemState.java
@@ -1278,9 +1278,11 @@ public class PySystemState extends PyObject
}
cachedir = new File(props.getProperty(PYTHON_CACHEDIR, CACHEDIR_DEFAULT_NAME));
if (!cachedir.isAbsolute()) {
- String prefixString = props.getProperty("user.dir", "");
- cachedir = new File(prefixString, cachedir.getPath());
- cachedir = cachedir.getAbsoluteFile();
+ File jythondir = new File(System.getProperty("user.home"), ".jython-cache");
+ if (!jythondir.isDirectory()) {
+ jythondir.mkdirs();
+ }
+ cachedir = new File(jythondir, cachedir.getPath());
}
logger.log(Level.CONFIG, "cache at {0}", cachedir);
}
diff --git a/src/org/python/modules/posix/PosixModule.java b/src/org/python/modules/posix/PosixModule.java
index e3a8dd9..07d4b43 100644
--- a/src/org/python/modules/posix/PosixModule.java
+++ b/src/org/python/modules/posix/PosixModule.java
@@ -1144,7 +1144,7 @@ public class PosixModule implements ClassDictInit {
if (times == Py.None) {
// FIXME dynamically bind to java.time.Instant, available in Java 8,
// to potentially get higher resolution (nanosecond) time
- atime = mtime = FileTime.from(
+ atime = mtime = FileTime.from(System.getenv("SOURCE_DATE_EPOCH") != null ? 1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")) :
System.currentTimeMillis(), TimeUnit.MILLISECONDS);
} else if (times instanceof PyTuple && times.__len__() == 2) {
atime = getFileTime(times.__getitem__(0));
diff --git a/src/org/python/modules/random/PyRandom.java b/src/org/python/modules/random/PyRandom.java
index f5ea8d9..0dc4881 100644
--- a/src/org/python/modules/random/PyRandom.java
+++ b/src/org/python/modules/random/PyRandom.java
@@ -45,7 +45,7 @@ public class PyRandom extends PyObject {
final void Random_seed(PyObject seed) {
long n;
if (seed == null) {
- seed = new PyLong(System.currentTimeMillis());
+ seed = new PyLong(System.getenv("SOURCE_DATE_EPOCH") != null ? 1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")) : System.currentTimeMillis());
}
if (seed instanceof PyLong) {
PyLong max = new PyLong(Long.MAX_VALUE);
diff --git a/src/org/python/modules/time/Time.java b/src/org/python/modules/time/Time.java
index ebd9871..cf2218d 100644
--- a/src/org/python/modules/time/Time.java
+++ b/src/org/python/modules/time/Time.java
@@ -131,6 +131,9 @@ public class Time implements ClassDictInit
}
public static double time() {
+ if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+ return Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")).doubleValue();
+ }
return System.currentTimeMillis()/1000.0;
}

View File

@ -32,6 +32,7 @@ Patch0: %{name}-build.patch
Patch1: %{name}-dont-validate-pom.patch
Patch2: %{name}-cachedir.patch
Patch3: %{name}-fix-tty-detection.patch
Patch4: %{name}-reproducible-now.patch
BuildRequires: ant
BuildRequires: ant-junit
BuildRequires: antlr3-java