Re: Leiningen in Python

2009-12-21 Thread John
Hi Rob,

Thanks for your helpful reply. I have finally had success.

On Dec 20, 7:10 pm, Rob Wolfe  wrote:
> Are you really sure that function `copy-to-jar` looks exactly like this:
> ...
> I mean `unix-path` function is called twice not only once.

Evidently not.
So I started from fresh again, just to be certain.

> In order to see what is exactly the problem you need to comment out
> `try-except` clause in core.clj in "-main" function.

This wasn't necessary in the end, in my case.

>> E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py new
>> Wrong number of arguments to task new.
>
>And this message is totally OK. "new" command requires at least one
>argument, e.g. project name: lein.py new test_proj

My mistake, sorry.
(I should have remembered that new requires 2 args from before.)

>Anyway I came up with this not very elegant soultion:
># part of lein.py
>
>def run_leiningen(argv):
>...

I added your amended code to the python script to handle a second
argument.
Aside: if anyone cuts and pastes Rob's python code from a browser,
you may have to delete the whitespace after the 6 continuation
symbols (\) or else python (V2.6) complains.

So I have got past yesterday's issues and now have a standalone jar
file.
In case, it is helpful to others, the commands that I used
(virtually the same as in your last email) were:

E:\etc\clojure\Leiningen\lein.py clean
E:\etc\clojure\Leiningen\lein.py deps
E:\etc\clojure\Leiningen\lein.py compile
E:\etc\clojure\Leiningen\lein.py jar
E:\etc\clojure\Leiningen\lein.py uberjar
:: WARNING: Not 'java -jar helloworld.jar'. D'oh!
java -jar helloworld-standalone.jar

Thanks for your time with this.

Regards,

John.

On Dec 20, 7:10 pm, Rob Wolfe  wrote:
> John  writes:
> > Hi Rob,
>
> > I made the changes src/leiningen/jar.clj that you suggested.
> > Then issued the commands:
>
> > E:\etc\clojure\Leiningen\lein.py clean
> > E:\etc\clojure\Leiningen\lein.py deps
> > E:\etc\clojure\Leiningen\lein.py compile
> > E:\etc\clojure\Leiningen\lein.py jar
> > E:\etc\clojure\Leiningen\lein.py uberjar
>
> > and they all work to compile the new Leiningen.
> > (Fyi, I originally didn’t have the 'lein.py deps' step
> > and this seems to be essential, in my case.)
>
> > Then in the python script (lein.py), I set
>
> > LEIN_JAR   = expanduser("E:/keep/eclipse/3.5/git-leiningen/src/
> > leiningen-standalone.jar")
> > CLOJURE_JAR = expanduser("E:/keep/eclipse/3.5/git-leiningen/src/lib/
> > clojure-1.1.0-master-20091218.160125-7.jar")
>
> > i.e. to point at the newly compiled leiningen and the version of
> > clojure
> > that it downloaded into its 'lib' folder.
>
> > I then tried the simple example at
> >http://zef.me/2470/building-clojure-projects-with-leiningen
> > using this project.clj
>
> > (defproject helloworld "0.1"
> > :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
> >[org.clojure/clojure-contrib "1.0-SNAPSHOT"]]
> > :main helloworld)
>
> > to correspond to the project.clj in E:/keep/eclipse/3.5/git-leiningen/
> > src
> > which contains
>
> > (defproject leiningen "1.1.0-SNAPSHOT"
> >   :description "A build tool designed not to set your hair on fire."
> >   :url "http://github.com/technomancy/leiningen";
> >   :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
> >  [org.clojure/clojure-contrib "1.0-SNAPSHOT"]
> >  [ant/ant-launcher "1.6.2"]
> >  [jline "0.9.94"]
> >  [org.apache.maven/maven-ant-tasks "2.0.10"]]
> >   :dev-dependencies [[leiningen/lein-swank "1.0.0-SNAPSHOT"]]
> >   :main leiningen.core)
>
> > I am able to compile the helloworld example:
>
> > E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py compile
> >  [copy] Copying 2 files to E:\keep\clojure\helloworld\lib
> > Compiling helloworld
>
> > But 'lein.py uberjar' or 'lein.py jar' both produce stange errors:
>
> > E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py uberjar
> > Wrong number of arguments to task uberjar.
> > E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py jar
> > Wrong number of arguments to task jar.
>
> Are you really sure that function `copy-to-jar` looks exactly like this:
>
> 
> (defmethod copy-to-jar :path [project jar-os spec]
>   (doseq [child (file-seq (file (:path spec)))]
> (when-not (.isDirectory child)
>   (let [path (unix-path (str child))
> path (re-sub (re-pattern (str "^" (unix-path (:root project
>  "" path)
> path (re-sub #"^/resources" "" path)
> path (re-sub #"^/classes" "" path)
> path (re-sub #"^/src" "" path)
> path (re-sub #"^/" "" path)]
> (.putNextEntry jar-os (JarEntry. path))
> (copy child jar-os)
> 
>
> I mean `unix-path` function is called twice not only once.
>
> In order to see what is exactly the problem you need to comment out
> `try-except` clause in core.clj in "-main" function.
>
>
>
> > and so does

Re: Leiningen in Python

2009-12-20 Thread Rob Wolfe
John  writes:

> Hi Rob,
>
> I made the changes src/leiningen/jar.clj that you suggested.
> Then issued the commands:
>
> E:\etc\clojure\Leiningen\lein.py clean
> E:\etc\clojure\Leiningen\lein.py deps
> E:\etc\clojure\Leiningen\lein.py compile
> E:\etc\clojure\Leiningen\lein.py jar
> E:\etc\clojure\Leiningen\lein.py uberjar
>
> and they all work to compile the new Leiningen.
> (Fyi, I originally didn’t have the 'lein.py deps' step
> and this seems to be essential, in my case.)
>
> Then in the python script (lein.py), I set
>
> LEIN_JAR   = expanduser("E:/keep/eclipse/3.5/git-leiningen/src/
> leiningen-standalone.jar")
> CLOJURE_JAR = expanduser("E:/keep/eclipse/3.5/git-leiningen/src/lib/
> clojure-1.1.0-master-20091218.160125-7.jar")
>
> i.e. to point at the newly compiled leiningen and the version of
> clojure
> that it downloaded into its 'lib' folder.
>
> I then tried the simple example at
> http://zef.me/2470/building-clojure-projects-with-leiningen
> using this project.clj
>
> (defproject helloworld "0.1"
> :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
>[org.clojure/clojure-contrib "1.0-SNAPSHOT"]]
> :main helloworld)
>
> to correspond to the project.clj in E:/keep/eclipse/3.5/git-leiningen/
> src
> which contains
>
> (defproject leiningen "1.1.0-SNAPSHOT"
>   :description "A build tool designed not to set your hair on fire."
>   :url "http://github.com/technomancy/leiningen";
>   :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
>  [org.clojure/clojure-contrib "1.0-SNAPSHOT"]
>  [ant/ant-launcher "1.6.2"]
>  [jline "0.9.94"]
>  [org.apache.maven/maven-ant-tasks "2.0.10"]]
>   :dev-dependencies [[leiningen/lein-swank "1.0.0-SNAPSHOT"]]
>   :main leiningen.core)
>
> I am able to compile the helloworld example:
>
> E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py compile
>  [copy] Copying 2 files to E:\keep\clojure\helloworld\lib
> Compiling helloworld
>
> But 'lein.py uberjar' or 'lein.py jar' both produce stange errors:
>
> E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py uberjar
> Wrong number of arguments to task uberjar.
> E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py jar
> Wrong number of arguments to task jar.

Are you really sure that function `copy-to-jar` looks exactly like this:


(defmethod copy-to-jar :path [project jar-os spec]
  (doseq [child (file-seq (file (:path spec)))]
(when-not (.isDirectory child)
  (let [path (unix-path (str child))
path (re-sub (re-pattern (str "^" (unix-path (:root project
 "" path)
path (re-sub #"^/resources" "" path)
path (re-sub #"^/classes" "" path)
path (re-sub #"^/src" "" path)
path (re-sub #"^/" "" path)]
(.putNextEntry jar-os (JarEntry. path))
(copy child jar-os)


I mean `unix-path` function is called twice not only once.

In order to see what is exactly the problem you need to comment out
`try-except` clause in core.clj in "-main" function.

>
> and so does 'lein.py new'
>
> E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py new
> Wrong number of arguments to task new.

And this message is totally OK. "new" command requires at least one
argument, e.g. project name:
lein.py new test_proj
But see below.

> E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py version
> Leiningen nil on Java 1.6.0_18-ea Java HotSpot(TM) Client VM
>
> This seems to be a different issue (possibly with the lein.py
> script?).
> Any pointers would be very welcome.

But there is still problem with passing arguments from windows
command line to leiningen. All arguments are considered as one
by Leiningen, so:
lein.py "new" "test_proj"
means for Leiningen:
lein.py "new test_proj"

I'm starting to think that it would be
nice to call leiningen as regular jar (I mean adding leiningen.clj
with "-main" function). Using "clojure.main" and "-e" is really
difficult on Windows.
@Phil what do you think about it?

Anyway I came up with this not very elegant soultion:

# part of lein.py

def run_leiningen(argv):
def escape_arg(s):
return s.replace("\\", "").replace("\"", "\\\"")

ARGS = ['"' + 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[0])

if len(ARGS) == 2:
CMD = ("java -Xbootclasspath/a:%s -client -cp %s clojure.main" \
   + " -e \"(use 'leiningen.core) (-main \\\"%s\\\" \\\"%s\\\")\"") 
\
   % (quote_cp([CLOJURE_JAR]), quote_cp(CLASSPATH), ARGS[0], 
ARGS[1])

elif len(ARGS) == 3:
CMD = ("java -Xbootclasspath/a:%s -client -cp %s clojure.main" \
   + " -e \"(use 'leiningen.core) (-main \\\"%s\\\" \\\"%s\\\" 
\\\"%s\\\")\"") \

Re: Leiningen in Python

2009-12-20 Thread John
Hi Rob,

I made the changes src/leiningen/jar.clj that you suggested.
Then issued the commands:

E:\etc\clojure\Leiningen\lein.py clean
E:\etc\clojure\Leiningen\lein.py deps
E:\etc\clojure\Leiningen\lein.py compile
E:\etc\clojure\Leiningen\lein.py jar
E:\etc\clojure\Leiningen\lein.py uberjar

and they all work to compile the new Leiningen.
(Fyi, I originally didn’t have the 'lein.py deps' step
and this seems to be essential, in my case.)

Then in the python script (lein.py), I set

LEIN_JAR   = expanduser("E:/keep/eclipse/3.5/git-leiningen/src/
leiningen-standalone.jar")
CLOJURE_JAR = expanduser("E:/keep/eclipse/3.5/git-leiningen/src/lib/
clojure-1.1.0-master-20091218.160125-7.jar")

i.e. to point at the newly compiled leiningen and the version of
clojure
that it downloaded into its 'lib' folder.

I then tried the simple example at
http://zef.me/2470/building-clojure-projects-with-leiningen
using this project.clj

(defproject helloworld "0.1"
:dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
   [org.clojure/clojure-contrib "1.0-SNAPSHOT"]]
:main helloworld)

to correspond to the project.clj in E:/keep/eclipse/3.5/git-leiningen/
src
which contains

(defproject leiningen "1.1.0-SNAPSHOT"
  :description "A build tool designed not to set your hair on fire."
  :url "http://github.com/technomancy/leiningen";
  :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
 [org.clojure/clojure-contrib "1.0-SNAPSHOT"]
 [ant/ant-launcher "1.6.2"]
 [jline "0.9.94"]
 [org.apache.maven/maven-ant-tasks "2.0.10"]]
  :dev-dependencies [[leiningen/lein-swank "1.0.0-SNAPSHOT"]]
  :main leiningen.core)

I am able to compile the helloworld example:

E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py compile
 [copy] Copying 2 files to E:\keep\clojure\helloworld\lib
Compiling helloworld

But 'lein.py uberjar' or 'lein.py jar' both produce stange errors:

E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py uberjar
Wrong number of arguments to task uberjar.
E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py jar
Wrong number of arguments to task jar.

and so does 'lein.py new'

E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py new
Wrong number of arguments to task new.
E:\keep\clojure\helloworld>E:\etc\clojure\Leiningen\lein.py version
Leiningen nil on Java 1.6.0_18-ea Java HotSpot(TM) Client VM

This seems to be a different issue (possibly with the lein.py
script?).
Any pointers would be very welcome.

Regards,

John.

On Dec 19, 10:25 pm, Rob Wolfe  wrote:
> John  writes:
> > 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'
>
> It's really strange. These additional spaces don't exist in my original 
> script.
> They were added by google groups or something.
>
>
>
>
>
> > 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?
>
> I don't think it is `lein.py` problem anymore.
> Leiningen uses regular expressions on paths and as usually
> there is a problem with windows path separator.
> I took a look in leiningen source and this small patch made
> command "jar" working for me on Windows
> (I haven't looked at "install" command, but probably it is the same
> problem):
>
> 
>
> diff --git a/src/leiningen/jar.clj b/src/leiningen/jar.clj
> index 227bccd..d1dd766 100644
> --- a/src/leiningen/jar.clj
> +++ b/src/leiningen/jar.clj
> @@ -22,13 +22,17 @@
>                          (str "Main

Re: Leiningen in Python

2009-12-19 Thread Phil Hagelberg
John  writes:

> I am trying to use lein.py, from above, on Windows (Vista).
> But I still have the following error with the 'lein.py install' and
> 'lein.py jar' commands:

I don't know Python myself, so I will wait until I hear about these
being resolved before I check this in.

-Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen in Python

2009-12-19 Thread Rob Wolfe
John  writes:

> 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'

It's really strange. These additional spaces don't exist in my original script.
They were added by google groups or something.

> 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?


I don't think it is `lein.py` problem anymore. 
Leiningen uses regular expressions on paths and as usually 
there is a problem with windows path separator.
I took a look in leiningen source and this small patch made
command "jar" working for me on Windows
(I haven't looked at "install" command, but probably it is the same
problem):



diff --git a/src/leiningen/jar.clj b/src/leiningen/jar.clj
index 227bccd..d1dd766 100644
--- a/src/leiningen/jar.clj
+++ b/src/leiningen/jar.clj
@@ -22,13 +22,17 @@
 (str "Main-Class: " main))])
"\n")
 
+(defn unix-path [path]
+  (.replaceAll path "" "/"))
+
 (defmulti copy-to-jar (fn [project jar-os spec] (:type spec)))
 
 (defmethod copy-to-jar :path [project jar-os spec]
   (doseq [child (file-seq (file (:path spec)))]
 (when-not (.isDirectory child)
-  (let [path (str child)
-path (re-sub (re-pattern (str "^" (:root project))) "" path)
+  (let [path (unix-path (str child))
+path (re-sub (re-pattern (str "^" (unix-path (:root project
+ "" path)
 path (re-sub #"^/resources" "" path)
 path (re-sub #"^/classes" "" path)
 path (re-sub #"^/src" "" path)




HTH,
Rob

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen in Python

2009-12-19 Thread John
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  wrote:
> Mike K  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:
>
> 
> #!/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 ch

Re: Leiningen in Python

2009-12-15 Thread Rob Wolfe


Phil Hagelberg napisał(a):
> Rob Wolfe  writes:
>
> > Yes, there are some escaping problems on Windows. I changed a little bit
> > "lein.py" and this worked for me on Windows and Linux:
>
> Can I include this in Leiningen 1.1.0+ with a note saying it's only
> experimentally supported?

Sure.

Br,
Rob

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen in Python

2009-12-15 Thread Phil Hagelberg
Rob Wolfe  writes:

> Yes, there are some escaping problems on Windows. I changed a little bit
> "lein.py" and this worked for me on Windows and Linux:

Can I include this in Leiningen 1.1.0+ with a note saying it's only
experimentally supported?

-Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen in Python

2009-12-13 Thread Jonghyouk, Yun
Thanks, I'll fix reported those problems, soon :-)

Thanks!

On 12월13일, 오전7시31분, Rob Wolfe  wrote:
> Mike K  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:
>
> 
> #!/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\\\")

Re: Leiningen in Python

2009-12-12 Thread Rob Wolfe
Mike K  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-leiningen which
> 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:


#!/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/clojure-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:
ru

Re: Leiningen in Python

2009-12-12 Thread Mike K
I could not get the python script to work, so I switched to the
powershell version.

I now understand that the leiningen-1.0.0-SNAPSHOT.jar is a so-called
"uberjar" and contains all the dependencies for leiningen.

However, the python script assumes clojure is from a separate jar
which is not installed via lein self-install:

CLOJURE_JAR = expanduser("~/.m2/repository/org/clojure/clojure/1.1.0-
alpha-SNAPSHOT/clojure-1.1.0-alpha-SNAPSHOT.jar")

I don't know how to modify this to use the leiningen uberjar instead.

   Mike

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen in Python

2009-12-11 Thread Mike K
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-leiningen which
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?

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).

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)?

Thanks for any help you can provide!

   Mike

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen in Python

2009-12-08 Thread Phil Hagelberg
"Jonghyouk, Yun"  writes:

> I've write some python script for leiningen for Windows machines
> without wget/curl.
>
> I expect it is nicer than as-is bourne-shell-script version of 'lein'.
>
> here is my little script: 
> http://github.com/ageldama/configs/blob/master/lein/lein.py

It'd be nice if we bundled a script that Windows users could run without
installing any further dependencies. But until we have something like
that, I'll bundle this python version.

Thanks!

-Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen in Python

2009-12-07 Thread liebke
That's great. Roland Sadowski has also written a Windows-friendly lein
script in PowerShell: http://gist.github.com/239210



On Dec 7, 8:15 am, "Jonghyouk, Yun"  wrote:
> Hi,
>
> I've write some python script for leiningen for Windows machines
> without wget/curl.
>
> I expect it is nicer than as-is bourne-shell-script version of 'lein'.
>
> here is my little 
> script:http://github.com/ageldama/configs/blob/master/lein/lein.py
>
> Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en