Leiningen in Python

181 views
Skip to first unread message

Jonghyouk, Yun

unread,
Dec 7, 2009, 8:15:39 AM12/7/09
to Clojure
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.

liebke

unread,
Dec 7, 2009, 10:28:18 AM12/7/09
to Clojure
That's great. Roland Sadowski has also written a Windows-friendly lein
script in PowerShell: http://gist.github.com/239210

Phil Hagelberg

unread,
Dec 8, 2009, 10:33:32 PM12/8/09
to clo...@googlegroups.com
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

Mike K

unread,
Dec 11, 2009, 10:55:48 PM12/11/09
to Clojure
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

Mike K

unread,
Dec 12, 2009, 3:01:58 PM12/12/09
to Clojure
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

Rob Wolfe

unread,
Dec 12, 2009, 5:31:19 PM12/12/09
to clo...@googlegroups.com
Mike K <mbk....@gmail.com> 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:

<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/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:
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

Jonghyouk, Yun

unread,
Dec 12, 2009, 11:26:13 PM12/12/09
to Clojure
Thanks, I'll fix reported those problems, soon :-)

Thanks!

On 12월13일, 오전7시31분, Rob Wolfe <r...@smsnet.pl> wrote:
> 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")

Phil Hagelberg

unread,
Dec 15, 2009, 10:42:03 PM12/15/09
to clo...@googlegroups.com
Rob Wolfe <r...@smsnet.pl> 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

Rob Wolfe

unread,
Dec 16, 2009, 2:36:23 AM12/16/09
to Clojure


Phil Hagelberg napisał(a):
Sure.

Br,
Rob

John

unread,
Dec 19, 2009, 10:04:24 AM12/19/09
to Clojure
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 <r...@smsnet.pl> wrote:

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

Rob Wolfe

unread,
Dec 19, 2009, 5:25:30 PM12/19/09
to clo...@googlegroups.com
John <john.b...@gmail.com> 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.


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

<patch>

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)

</patch>


HTH,
Rob

Phil Hagelberg

unread,
Dec 19, 2009, 5:46:02 PM12/19/09
to clo...@googlegroups.com
John <john.b...@gmail.com> 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

John

unread,
Dec 20, 2009, 10:55:22 AM12/20/09
to Clojure
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 <r...@smsnet.pl> wrote:

Rob Wolfe

unread,
Dec 20, 2009, 2:10:17 PM12/20/09
to clo...@googlegroups.com
John <john.b...@gmail.com> writes:

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

<code>


(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)))))
</codec>

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


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\\\")\"") \


% (quote_cp([CLOJURE_JAR]), quote_cp(CLASSPATH),

ARGS[0], ARGS[1], ARGS[2])
system(CMD)
</code>

I hope there is no command which requires more than 2 arguments. ;)

And now I managed to do what you were trying:

c:\src\clojure\test>c:\tools\bin\lein.py new test_proj
Created new project in: test_proj

c:\src\clojure\test>dir test_proj
2009-12-20 19:29 <DIR> .
2009-12-20 19:29 <DIR> ..
2009-12-20 19:29 56 .gitignore
2009-12-20 19:29 173 project.clj
2009-12-20 19:29 119 README
2009-12-20 19:29 <DIR> src
2009-12-20 19:29 <DIR> test


C:\src\clojure\test\helloworld>dir
2009-12-20 19:31 <DIR> .
2009-12-20 19:31 <DIR> ..
2009-12-20 19:05 187 project.clj
2009-12-20 19:06 <DIR> src


C:\src\clojure\test\helloworld>c:\tools\bin\lein.py compile
[copy] Copying 2 files to C:\src\clojure\test\helloworld\lib
Compiling helloworld

C:\src\clojure\test\helloworld>c:\tools\bin\lein.py jar

C:\src\clojure\test\helloworld>c:\tools\bin\lein.py uberjar
Including helloworld.jar
Including clojure-1.1.0-master-20091218.160125-7.jar
Including clojure-contrib-1.0-20091212.214557-33.jar

C:\src\clojure\test\helloworld>dir
2009-12-20 19:33 <DIR> .
2009-12-20 19:33 <DIR> ..
2009-12-20 19:32 <DIR> classes
2009-12-20 19:33 5 261 247 helloworld-standalone.jar
2009-12-20 19:33 5 498 helloworld.jar
2009-12-20 19:32 <DIR> lib
2009-12-20 19:05 187 project.clj
2009-12-20 19:06 <DIR> src


HTH,
Rob

John

unread,
Dec 21, 2009, 11:59:26 AM12/21/09
to Clojure
Hi Rob,

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

On Dec 20, 7:10 pm, Rob Wolfe <r...@smsnet.pl> 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
><code>
>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 <r...@smsnet.pl> wrote:

Reply all
Reply to author
Forward
0 new messages