Hi,
I am trying to use lein.py, from above, on Windows (Vista).
It works nicely for some commands (e.g. lein.py compile),
after removing the extra space in two places e.g.
'leiningen-%s-standalone .jar' ->
'leiningen-%s-standalone.jar'
and
'1.1.0-alpha-SNAPSHOT/cloju re-1.1.0-alpha-SNAPSHOT.jar' ->
'1.1.0-alpha-SNAPSHOT/clojure-1.1.0-alpha-SNAPSHOT.jar'
But I still have the following error with the 'lein.py install' and
'lein.py jar' commands:
E:\temp\leiningen\myproject> E:\etc\clojure\Leiningen\lein.py install
Exception in thread "main" java.util.regex.PatternSyntaxException:
Illegal/unsupported escape sequence near index 9
^E:\temp\leiningen\myproject
^ (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5274)
at clojure.lang.Compiler.eval(Compiler.java:5226)
...
E:\temp\leiningen\myproject> E:\etc\clojure\Leiningen\lein.py jar
Exception in thread "main" java.util.regex.PatternSyntaxException:
Illegal/unsupported escape sequence near index 9
^E:\temp\leiningen\myproject
^ (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5274)
at clojure.lang.Compiler.eval(Compiler.java:5226)
...
I am guessing that this means that the backslash in 'temp\leiningen'
needs to be escaped
somewhere in the python script (lein.py) above.
(I am not clear why the first backslash (in E:\temp) is not reported
as the error (index 4).)
I have tried many guesses (I am not familiar with python (V2.6)).
Can anyone make some suggestions?
Regards,
John.
On Dec 12, 10:31 pm, Rob Wolfe <[email protected]> wrote:
> Mike K <[email protected]> writes:
> > All,
>
> > I tried to use this script on Windows and it blew up real good! I'm a
> > Clojure, Java, and Leiningen newbie, so perhaps a kind soul can help
> > me out.
>
> > 1. lein self-install "worked". It downloaded leiningen-1.0.0-
> > standalone.jar. However, that contradicts the description at
> >http://zef.me/2470/building-clojure-projects-with-leiningenwhich
> > indicates that self-install should download several jars, including
> > clojure itself. That didn't happen, and it looks like it would never
> > happen according to the python script. Also, I'd rather use one and
> > only one clojure, clojure-contrib, etc. for everything rather than
> > Leiningen using its own. Is this possible?
>
> As you have already found out you need only standalone leiningen jar,
> which is downloaded by "lein.py".
>
>
>
>
>
> > 2. Any other lein command seems to require the clojure jar in the
> > repository ~/.m2/repository/org/clojure/clojure/1.1.0-alpha-SNAPSHOT/
> > clojure-1.1.0-alpha-SNAPSHOT.jar. Since I don't have one there, I
> > modified CLOJURE_JAR to point to my existing jar. Everything still
> > fails with this sort of error:
>
> > lein help
> > java.lang.NoClassDefFoundError: Files
> > Caused by: java.lang.ClassNotFoundException: Files
> > at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> > at java.security.AccessController.doPrivileged(Native Method)
> > at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
> > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
> > Could not find the main class: Files. Program will exit.
> > Exception in thread "main"
>
> > I suspect the suspicious "Files" class name is coming from the fact
> > that I now have CLOJURE_JAR set as follows:
>
> > CLOJURE_JAR = expanduser("C:\\Program Files (x86)\\Clojure Box\\clojure
> > \\clojure-1.0.0.jar")
>
> > Looks like I'm getting bit by spaces in the path name. This would not
> > be an issue if lein had downloaded its own clojure jar during step 1
> > (no spaces in that path).
>
> Yes, there are some escaping problems on Windows. I changed a little bit
> "lein.py" and this worked for me on Windows and Linux:
>
> <lein.py>
> #!/usr/bin/env python
>
> import sys
> from glob import glob
> from os import makedirs, system, getenv
> from os.path import expanduser, dirname, exists
> from urllib import urlretrieve
>
> ### inits
>
> VERSION = "1.0.0"
>
> if sys.platform == "win32":
> CP_SEP = ";"
> else:
> CP_SEP = ":"
>
> LEIN_JAR =
> expanduser("~/.m2/repository/leiningen/leiningen/%s/leiningen-%s-standalone
> .jar" % (VERSION, VERSION))
>
> CLOJURE_JAR =
> expanduser("~/.m2/repository/org/clojure/clojure/1.1.0-alpha-SNAPSHOT/cloju
> re-1.1.0-alpha-SNAPSHOT.jar")
>
> CPS = glob("lib/*")
>
> LEIN_URL = "http://repo.technomancy.us/leiningen-%s-standalone.jar" %
> (VERSION)
>
> # leiningen installation checks
>
> LEIN_BIN_DIR = dirname(sys.argv[0])
>
> if exists(LEIN_BIN_DIR + "../src/leiningen/core.clj"):
> # running from source-checkout
> LEIN_LIBS = glob(LEIN_BIN_DIR + "/*")
> CLASSPATH = CPS + [LEIN_LIBS]
> if len(LEIN_LIBS) < 1 and sys.argv[1] != 'self-install':
> print "Your Leiningen development checkout is missing its
> dependencies."
> print "Please download a stable version of Leiningen to fetch the
> deps."
> print "See the \"Hacking\" section of the readme for details."
> exit(1)
> else:
> # not running from a checkout
> CLASSPATH = CPS + [LEIN_JAR]
> if not exists(LEIN_JAR) and sys.argv[1] != 'self-install':
> print "Leiningen is not installed. Please run \"lein self-install\"."
> exit(1)
>
> if getenv("DEBUG"):
> print CP_SEP.join(CLASSPATH)
>
> ### defs
>
> def quote_cp(cp):
> return CP_SEP.join("\"%s\"" % p for p in cp)
>
> def download_lein_jar():
> # TODO: wget / curl?
> print("downloading %s -> %s ..." % (LEIN_URL, LEIN_JAR)),
> sys.stdout.flush()
> LEIN_JAR_DIR = dirname(LEIN_JAR)
> if not exists(LEIN_JAR_DIR):
> makedirs(LEIN_JAR_DIR)
> # 'urlretrieve' is incrediblly slow! but it is portable anyway...
> urlretrieve(LEIN_URL, LEIN_JAR)
> print("done")
>
> def start_repl(argv):
> # TODO: rlwrap?
> cp = ['src', 'classes'] + CLASSPATH
> CMD = 'java -cp %s clojure.main %s' % (quote_cp(cp), " ".join(argv))
> system(CMD)
>
> def run_leiningen(argv):
> def escape_arg(s):
> return s.replace("\\", "\\\\").replace("\"", "\\\"")
>
> ARGS = " ".join([ '"' + escape_arg(s) + '"' for s in argv ])
> CMD = "java -Xbootclasspath/a:%s -client -cp %s clojure.main -e \"(use
> 'leiningen.core) (-main \\\"%s\\\")\"" \
> % (quote_cp([CLOJURE_JAR]), quote_cp(CLASSPATH), ARGS)
> system(CMD)
>
> ### main
>
> if __name__ == '__main__':
> if len(sys.argv) > 1 and sys.argv[1] == 'self-install':
> download_lein_jar()
> elif len(sys.argv) > 1 and sys.argv[1] == 'repl':
> start_repl(sys.argv[2:])
> else:
> run_leiningen(sys.argv[1:])
>
> ### EOF
> </lein.py>
>
>
>
> > 3. My clojure jar is clojure-1.0.0.jar from clojure org. The script
> > uses clojure-1.1.0-alpha-SNAPSHOT.jar, but a comment from the link
> > implies that this has been supplanted by 1.1.0-master.jar. In any
> > event, I don't know where either of these two things are. I tried
> > going to build.clojure.org, but all the build artifiacts there are
> > named clojure.jar.
>
> > 4. BTW, what's the deal with this ".m2" directory (i.e., where does
> > the name come from)?
>
> It comes from maven world:http://maven.apache.org/
>
>
>
> > Thanks for any help you can provide!
>
> > Mike
>
> HTH,
> Rob
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en