Creating Zip file like java jar file

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sat Feb 28 15:32:05 EST 2009


En Sat, 28 Feb 2009 16:51:04 -0200, <zaheer.agadi 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.

Uh? Which project folder? Isn't it in the .zip?

-- 
Gabriel Genellina




More information about the Python-list mailing list