Creating Zip file like java jar file

zaheer.agadi at gmail.com zaheer.agadi at gmail.com
Sun Mar 1 00:16:53 EST 2009


On Mar 1, 1:32 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Sat, 28 Feb 2009 16:51:04 -0200, <zaheer.ag... at gmail.com> escribió:
>
>
>
> > On Feb 28, 11:33 pm, Lie Ryan <lie.1... at gmail.com> wrote:
> >> zaheer.ag... at gmail.com wrote:
> >> > On Feb 28, 11:15 pm, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> >> > wrote:
> >> >> En Sat, 28 Feb 2009 14:34:15 -0200, <zaheer.ag... at gmail.com>
> >> escribió:
>
> >> >>> I want to create zip file equivalent to java jar file,I created a
> >> zip
> >> >>> file of my sources and added some __main__.py
> >> >>> it says __Main__.py not found in Copyproject.zip..?
> >> >> __main__.py must exist in the root directory.
>
> >> > What do you mean by root directory..?What is this directory in
> >> > Windows..?You mean the top level folder of the project?in my case
> >> > copyproject folder..?
>
> >> root directory is the topmost directory (imagine a tree, the root is
> >> where all the branches branched from), in this case the root directory
> >> is your copyproject main folder.
>
> > I wonder, I do have the __main__.py  in the root directory,but still
> > getting
> > python.exe cannot find __main__.py in CopyProject.zip
>
> The top of the tree inside the zip file. Depth zero. Not inside any
> directory. Above anything else. Just a bare name.
>
> Open your zip using the zipfile module:
>
> import zipfile
> z = zipfile.ZipFile("xxx.zip")
> z.printdir()
>
> You should see a line starting with __main__.py *without* any / in it.
>
> > I used the following command
> > python Copyproject.zip -m __main__.py --uploadFile and also tried with
> > python Copyproject.zip --uploadFile
>
> Use the second one.
>
> > both give me the same error , I can see the sys.path contains the
> > project folder.
>

> --
> Gabriel Genellina

> Uh? Which project folder? Isn't it in the .zip?
>
 Yeah I meant zip file.
I can get to work but is it is not able to locate the packages,says
import error cant find the package and module

here is my code

import sys
import os.path as op
sys.path.insert(0, op.join(op.dirname(op.abspath(__file__)),
"somezip.zip"))

import zipfile
z = zipfile.ZipFile("somezip.zip")
z.printdir()

import some.storagepackage.somemodule
print "upload"
print "syspath",sys.path

#do something

should it not find the modules when the zip files is in sys.path..?



More information about the Python-list mailing list