File: Package-jystilts.patch

package info (click to toggle)
starjava-ttools 3.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 23,000 kB
  • sloc: java: 170,407; xml: 19,593; javascript: 670; python: 641; sh: 107; makefile: 29
file content (145 lines) | stat: -rw-r--r-- 5,898 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
From: Ole Streicher <olebole@debian.org>
Date: Thu, 16 Mar 2017 09:27:43 +0100
Subject: Package jystilts

---
 build.xml                                          |  4 +-
 src/docs/sun256.xml                                | 56 ++++------------------
 src/main/uk/ac/starlink/ttools/build/JyStilts.java | 33 +++++++++++--
 3 files changed, 39 insertions(+), 54 deletions(-)

diff --git a/build.xml b/build.xml
index 8330b77..dfe2df1 100644
--- a/build.xml
+++ b/build.xml
@@ -685,9 +685,7 @@
       <classpath refid="jar.classpath" />
     </manifestclasspath>
     <jar destfile="${dist.lib.pkg}/${name}.jar">
-      <fileset dir="${build.classes}"
-               excludes="uk/ac/starlink/ttools/gpl/*
-                         uk/ac/starlink/ttools/gpl"/>
+      <fileset dir="${build.classes}"/>
       <fileset dir="${build.javadocs}"/>
       <fileset dir="${build.etc}"/>
       <manifest>
diff --git a/src/docs/sun256.xml b/src/docs/sun256.xml
index 39801e7..7365097 100644
--- a/src/docs/sun256.xml
+++ b/src/docs/sun256.xml
@@ -1556,53 +1556,15 @@ is given in the following subsections.
 <subsect id="jyrun">
 <subhead><title>Running JyStilts</title></subhead>
 
-<p>The easiest way to run JyStilts is to download the standalone
-<code>jystilts.jar</code> file from the STILTS web page,
-and simply run
-<verbatim>
-java -jar jystilts.jar   
-</verbatim>
-This file includes jython itself and all the STILTS and JyStilts classes.
-To use the JyStilts commands, you will need to import the stilts
-module using a line like "<code>import stilts</code>"
-from Jython in the usual Python way.
-</p>
-
-<p>Alternatively, you can run JyStilts from an existing Jython installation
-using just the <code>stilts.jar</code> file.
-First, make sure that Jython is installed;
-it is available from <webref url="http://www.jython.org/"/>,
-and comes as a self-installing jar file.
-JyStilts has been tested, and appears to work, with jython version 2.7.2.
-It also works with jython 2.5.* under Java 8 and Java 11,
-but jystilts with jython 2.5.* and Java 17 can fail with security problems.
-Some earlier versions of JyStilts worked with jython 2.2.1, 
-but that no longer seems to be the case; it might be possible
-to reinstate this if there is some pressing need.
-</p>
-
-<p>To use JyStilts, you then just need to
-start jython with the <code>stilts.jar</code> file on your classpath,
-for instance like this:
-<verbatim>
-jython -J-classpath /some/where/stilts.jar
-</verbatim>
-or (C-shell):
-<verbatim>
-setenv CLASSPATH /some/where/stilts.jar
-jython
-</verbatim>
-</p>
-
-<p>Optionally, you can extract the <code>stilts.py</code> module 
-from the stilts.jar file 
-(using a command like "<code>unzip stilts.jar stilts.py</code>")
-and put it in a directory on your jython 
-<code>sys.path</code> (e.g. <code>jythondir/Lib</code>);
-this may cause jython to compile it to bytecode (<code>stilts$py.class</code>)
-and thus improve startup time.
-Note that in this case you will still need the <code>stilts.jar</code> 
-file on your classpath as above.
+<p>You can run JyStilts from an existing Jython installation.
+Just make sure that the
+<webref url="https://packages.debian.org/jython-stils">
+<code>jython-stilts</code></webref> Debian package is installed.
+Then you can just do an
+<verbatim><![CDATA[
+>>> import stilts
+]]></verbatim>
+to have the stilts package available.
 </p>
 
 </subsect>
diff --git a/src/main/uk/ac/starlink/ttools/build/JyStilts.java b/src/main/uk/ac/starlink/ttools/build/JyStilts.java
index e3a6fd1..9cb56df 100644
--- a/src/main/uk/ac/starlink/ttools/build/JyStilts.java
+++ b/src/main/uk/ac/starlink/ttools/build/JyStilts.java
@@ -168,9 +168,36 @@ public class JyStilts {
             "for tutorial and full usage information.",
             "'''",
             "",
-            "from __future__ import generators",
             "__author__ = 'Mark Taylor'",
             "",
+	    "import sys",
+	    "import java.io",
+	    "import java.nio.file",
+	    "import java.util.jar",
+	    "",
+            "# see also http://bugs.jython.org/issue547727",
+            "def _recursivelyAddJar(jarfile):",
+            "    if jarfile.canonicalPath in sys.path:",
+            "        return",
+            "    sys.path.append(jarfile.canonicalPath)",
+            "    try:",
+            "        jar = java.util.jar.JarFile(jarfile)",
+            "        if jar and jar.manifest:",
+            "            jarAttrs = jar.manifest.mainAttributes",
+            "            jarClassPath = jarAttrs.get(java.util.jar.Attributes.Name.CLASS_PATH)",
+            "            if jarClassPath:",
+            "                for p in jarClassPath.split():",
+            "                    _recursivelyAddJar(java.io.File(jarfile.parent, p))",
+            "    except java.io.FileNotFoundException:",
+            "        pass # ignore jars that are not there",
+            "    except java.nio.file.NoSuchFileException:",
+            "        pass # ignore jars that are not there",
+            "",
+            "_recursivelyAddJar(java.io.File('/usr/share/java/starlink-ttools.jar'))",
+            "",
+            "del _recursivelyAddJar",
+            "del sys",
+            "",
         };
     }
 
@@ -318,9 +345,7 @@ public class JyStilts {
             /* Utility to raise an error if a handler can't write multiple
              * tables. */
             "def _check_multi_handler(handler):",
-            "    if not " + getImportName( Class.class )
-                          + ".forName('" + MultiStarTableWriter.class.getName()
-                                         + "')"
+            "    if not " + "_MultiStarTableWriter"
                           + ".isInstance(handler):",
             "        raise TypeError('Handler %s cannot write multiple tables' "
                                     + "% handler.getFormatName())",